youmubot/.github/workflows/build_test.yml

89 lines
2.7 KiB
YAML

name: Build and Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
format_check:
name: Format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
- name: Run rustfmt
run: cargo fmt -- --check
check:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
id: cargo
with:
toolchain: stable
components: clippy
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-${{ steps.cargo.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}-lint
- name: Run cargo check
run: cargo check
env:
SQLX_OFFLINE: "true"
- name: Run clippy
run: cargo clippy
env:
SQLX_OFFLINE: "true"
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
id: cargo
with:
toolchain: stable
components: clippy
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-${{ steps.cargo.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}-debug-build
- name: Run cargo test
run: cargo test
env:
SQLX_OFFLINE: "true"
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
id: cargo
with:
toolchain: stable
components: clippy
- uses: cachix/cachix-action@v15
with:
name: natsukagami
# If you chose API tokens for write access OR if you have a private cache
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run nix build
run: nix build