-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yuki WADA
committed
Apr 12, 2023
1 parent
24b1f4d
commit 5309f69
Showing
1 changed file
with
51 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,31 @@ on: | |
|
||
env: | ||
image_name: ghcr.io/giganticminecraft/seichi-poral-backend | ||
RUST_BACKTRACE: full | ||
SCCACHE_CACHE_SIZE: 2G | ||
SCCACHE_VERSION: 0.3.3 | ||
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out | ||
|
||
jobs: | ||
rustfmt: | ||
name: rustfmt check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
components: rustfmt | ||
override: true | ||
- uses: LoliGothick/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
flags: --all | ||
args: --config-path=./.cargo-husky/hooks/rustfmt.toml | ||
working-directory: ./server | ||
|
||
lint-and-test: | ||
needs: [ rustfmt ] | ||
name: Lint and test server | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -23,32 +45,48 @@ jobs: | |
target: x86_64-unknown-linux-musl | ||
components: clippy, rustfmt | ||
|
||
# > selecting a toolchain either by action or manual `rustup` calls should happen | ||
# > before the plugin, as it uses the current rustc version as its cache key | ||
# https://github.com/Swatinem/rust-cache/tree/cb2cf0cc7c5198d3364b9630e2c3d457f160790c#example-usage | ||
- uses: Swatinem/[email protected] | ||
with: | ||
workspaces: "./server -> target" | ||
|
||
# buf CLIがビルドに必要 | ||
- uses: bufbuild/buf-setup-action@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Cargo fmt | ||
run: cargo fmt --all -- --check | ||
working-directory: ./server | ||
- name: Save sccache | ||
id: restore-sccache | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
/home/runner/.cache/sccache | ||
~/.cargo/bin/sccache | ||
key: sccache-${{ env.SCCACHE_VERSION }}-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
sccache-${{ env.SCCACHE_VERSION }}- | ||
- if: ${{ steps.restore-sccache.outputs.cache-hit == false }} | ||
name: Install sccache | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: install | ||
args: --version=${{ env.SCCACHE_VERSION }} --force sccache | ||
|
||
- name: Start sccache server | ||
run: sccache --start-server | ||
|
||
- name: Cargo build | ||
run: cargo build | ||
working-directory: ./server | ||
|
||
- name: Clippy check | ||
uses: LoliGothick/[email protected] | ||
- uses: LoliGothick/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
options: --all-features --manifest-path ./server/Cargo.toml | ||
deny: warnings | ||
working-directory: ./server | ||
|
||
- name: Cargo test | ||
run: cargo test --all-features | ||
working-directory: ./server | ||
|
||
- name: Print sccache stats | ||
run: sccache --show-stats | ||
- name: Stop sccache server | ||
run: sccache --stop-server || true |