ci: rustfmt-check の toolchain を stable にする #1158
Workflow file for this run
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
name: CI | |
on: | |
push: | |
paths-ignore: | |
- '**.md' | |
env: | |
IMAGE: ghcr.io/giganticminecraft/seichi-game-data-server | |
jobs: | |
app-lint-and-test: | |
name: Lint and test application | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
# TODO: read from rust-toolchain.toml | |
toolchain: 1.82.0 | |
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/rust-cache@v2 | |
with: | |
working-directory: server | |
# buf CLIがビルドに必要 | |
- uses: bufbuild/buf-setup-action@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cargo fmt | |
uses: LoliGothick/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
flags: --all | |
toolchain: 'stable' | |
options: --manifest-path ./server/Cargo.toml | |
args: --config-path=./server/rustfmt.toml | |
working-directory: ./server | |
- name: Cargo clippy | |
uses: LoliGothick/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
working-directory: ./server | |
- name: Cargo test | |
run: cargo test --all-features | |
working-directory: ./server | |
build-image: | |
name: Build docker image (and publish on master) | |
needs: [ app-lint-and-test ] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
tags: | | |
type=sha,prefix=sha-,suffix=,format=short | |
type=schedule,pattern={{date 'YYYYMMDD'}} | |
- name: Build (and push if on master) | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./server | |
file: ./Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
push: ${{ github.ref == 'refs/heads/master' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
# すべてのビルドステージのすべてのレイヤーをキャッシュして欲しいのでmode=max | |
cache-to: type=gha,mode=max |