Skip to content

Commit

Permalink
Merge pull request #305 from Lodestone-Team/monorepo-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ynng committed Jul 17, 2023
2 parents 45dfe0e + a6e97fb commit 835a075
Show file tree
Hide file tree
Showing 616 changed files with 38,092 additions and 148 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=sqlite://dev.db
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/client-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Client Issue Template
about: Organized layout for issue
title: ''
labels: ''
assignees: ''

---

# Description

# Steps to reproduce (optional)
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Description

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. -->



## Type of change

<!-- Please put 'x' next to the type of change you are making.
Ex.
- [x] Bug fix (non-breaking change which fixes an issue) -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

*Note: make sure your files are formatted with rust-analyzer*
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Main CI Workflow

on:
push:
branches:
- dev
- main
- releases/**

pull_request:
branches:
- dev
- main
- releases/**
jobs:
workspace-check:
uses: ./.github/workflows/workspace-check.yml
secrets: inherit

core-cargo-test:
uses: ./.github/workflows/core-cargo-test.yml
secrets: inherit

dashboard-build-and-draft:
uses: ./.github/workflows/dashboard-build-and-draft.yml
needs: [workspace-check, core-cargo-test]
with:
debug: false
version: null
secrets: inherit

core-build-and-draft:
uses: ./.github/workflows/core-build-and-draft.yml
needs: [workspace-check, core-cargo-test]
with:
version: null
secrets: inherit
141 changes: 141 additions & 0 deletions .github/workflows/core-build-and-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Core - Build and Draft

on:
workflow_dispatch:
inputs:
version:
description: "Version to tag the release with, leave empty to not make a release"
required: false
type: string
workflow_call:
inputs:
version:
description: "Version to tag the release with, leave empty to not make a release"
required: false
type: string

env:
CARGO_TERM_COLOR: always

jobs:
core-build-and-draft:
strategy:
fail-fast: false
matrix:
include:
- platform: "windows-latest"
target: "x86_64-pc-windows-msvc"
os: "windows"
arch: "x86_64"
postfix: ".exe"
cross: false
- platform: "ubuntu-latest"
target: "x86_64-unknown-linux-gnu"
os: "linux"
arch: "x86_64"
postfix: ""
cross: false
- platform: "self-hosted"
target: "aarch64-unknown-linux-gnu"
os: "linux"
arch: "aarch64"
postfix: ""
cross: false
- platform: "macos-latest"
target: "x86_64-apple-darwin"
os: "macos"
arch: "x86_64"
postfix: ""
cross: false

runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}

- name: Install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: rust-cache
shared-key: ${{ matrix.target }}-release-build
key: workspace

- name: Find Version (Linux, MacOS)
id: find_version
if: runner.os != 'Windows'
run: |
VERSION="v$(grep "^version" Cargo.toml | cut -d = -f 2 | sed -E "s/\"//g" | sed -E "s/ //g")"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
FILENAME="lodestone_core_${{matrix.os}}_${{matrix.arch}}_${VERSION}${{matrix.postfix}}"
echo "FILENAME=${FILENAME}" >> $GITHUB_ENV
- name: Find Version (Windows)
id: find_version_windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$VERSION = "v" + (Get-Content Cargo.toml | Select-String -Pattern "^version" | ForEach-Object { $_.ToString().Split("=")[1].Trim().Replace("`"", "") })
echo "VERSION=$VERSION" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
$FILENAME = "lodestone_core_${{matrix.os}}_${{matrix.arch}}_$VERSION${{matrix.postfix}}"
echo "FILENAME=$FILENAME" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
# - name: Verify Version
# if: inputs.version && false
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# if (process.env.VERSION != ${{ inputs.version }}) {
# core.setFailed("Version mismatch: " + process.env.VERSION + " != " + ${{ inputs.version }});
# }

- name: Build Lodestone Core
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --features "vendored-openssl" --target ${{ matrix.target }}

- name: Rename File (Linux, MacOS)
if: runner.os != 'Windows'
run: |
mv ./target/${{ matrix.target }}/release/main${{ matrix.postfix }} ./${{ env.FILENAME }}
- name: Rename File (Windows)
if: runner.os == 'Windows'
run: |
echo "::debug::$(ls)"
Move-Item -Path "./target/${{ matrix.target }}/release/main${{ matrix.postfix }}" -Destination "./${{ env.FILENAME }}"
# for debugging
echo "::debug::Listing files in current directory"
echo "::debug::$(ls)"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{env.FILENAME}}
path: ./${{env.FILENAME}}

- name: Draft Release
uses: softprops/action-gh-release@v1
if: inputs.version
with:
files: ./${{env.FILENAME}}
tag_name: ${{env.VERSION}}
draft: true
prerelease: true
43 changes: 43 additions & 0 deletions .github/workflows/core-cargo-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Core - Cargo Test

on:
workflow_dispatch:
workflow_call:

env:
CARGO_TERM_COLOR: always

jobs:
core-cargo-test:
strategy:
matrix:
include:
- platform: windows-latest
target: x86_64-pc-windows-msvc
- platform: ubuntu-latest
target: x86_64-unknown-linux-gnu
- platform: macos-latest
target: x86_64-apple-darwin

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v1

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal

- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: rust-cache
shared-key: workspace-${{ matrix.target }}-debug-build

- name: Cargo Test Backend
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast -- --test-threads=1
32 changes: 32 additions & 0 deletions .github/workflows/core-clippy-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Core - Clippy Check

on:
workflow_dispatch:
workflow_call:

env:
CARGO_TERM_COLOR: always

jobs:
core-clippy-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true

- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: rust-cache
shared-key: workspace-x86_64-unknown-linux-gnu-release-check

- name: Run Clippy Check
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --release
63 changes: 63 additions & 0 deletions .github/workflows/core-release-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Core - Release Docker

on:
release:
types: [released]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
core-release-docker:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./core

steps:
- name: checkout repository
uses: actions/checkout@v3
- name: set up QEMU
uses: docker/setup-qemu-action@v2
- name: set up docker buildx
uses: docker/setup-buildx-action@v2
- name: log in to the container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: string_tag
uses: ASzc/change-string-case-action@v5
with:
string: ${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}

- id: release_asset
name: Download release assets
uses: dsaltares/fetch-gh-release-asset@master
with:
regex: true
file: "lodestone_core_*"
target: release/
version: "tags/${{ github.event.release.tag_name }}"
token: ${{ secrets.GITHUB_TOKEN }}

# https://stackoverflow.com/questions/73402042/github-action-expressions-split-string
- name: set version string
env:
VERSION: ${{ steps.release_asset.outputs.version }}
id: substring
run: echo "version=${VERSION:1}" >> $GITHUB_OUTPUT

- name: build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./githubactions.Dockerfile
build-args: |
lodestone_version=${{ steps.release_asset.outputs.version }}
push: true
tags: ${{ steps.string_tag.outputs.lowercase }}:latest,${{ steps.string_tag.outputs.lowercase }}:${{ steps.substring.outputs.version }}
Loading

0 comments on commit 835a075

Please sign in to comment.