Files
matrix-authentication-service/.github/workflows/check.yaml
T
2021-07-16 23:22:17 +02:00

220 lines
5.4 KiB
YAML

name: Check
on:
push:
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
fetch:
name: Fetch Cargo dependencies (${{ matrix.os.name }})
runs-on: ${{ matrix.os.runner }}
strategy:
matrix:
os:
- name: "macOS"
runner: "macos-latest"
target: "x86_64-apple-darwin"
- name: "Windows"
runner: "windows-latest"
target: "x86_64-pc-windows-msvc"
- name: "Linux"
runner: "ubuntu-latest"
target: "x86_64-unknown-linux-musl"
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.os.target }}
profile: minimal
override: true
- name: Setup Cargo cache
uses: actions/cache@v2.1.6
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-${{ hashFiles('**/Cargo.lock') }}-${{ runner.os }}
- name: Fetch dependencies
id: fetch
uses: actions-rs/cargo@v1
continue-on-error: true
with:
command: fetch
args: --locked
- name: Fetch dependencies (retry)
id: fetch-2
uses: actions-rs/cargo@v1
if: steps.fetch.outcome == 'failure'
continue-on-error: true
with:
command: fetch
args: --locked
- name: Fetch dependencies (second retry)
uses: actions-rs/cargo@v1
if: steps.fetch.outcome == 'failure' && steps.fetch-2.outcome == 'failure'
with:
command: fetch
args: --locked
rustfmt:
name: Check style
needs: [fetch]
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Install toolchain
id: toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
profile: minimal
override: true
- name: Setup Cargo cache
uses: actions/cache@v2.1.6
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-${{ hashFiles('**/Cargo.lock') }}-${{ runner.os }}
- name: Setup build cache
uses: actions/cache@v2.1.6
with:
path: |
target
key: cargo-fmt-${{ hashFiles('**/Cargo.lock') }}-${{ steps.toolchain.outputs.rustc_hash }}
- name: Check style
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Run Clippy
needs: [fetch]
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Install toolchain
id: toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
override: true
- name: Setup Cargo cache
uses: actions/cache@v2.1.6
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-${{ hashFiles('**/Cargo.lock') }}-${{ runner.os }}
- name: Setup build cache
uses: actions/cache@v2.1.6
with:
path: |
target
key: cargo-clippy-${{ hashFiles('**/Cargo.lock') }}-${{ steps.toolchain.outputs.rustc_hash }}
- name: Run Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
test:
name: Run test suite on ${{ matrix.os.name }} / ${{ matrix.toolchain }}
needs: [rustfmt, clippy, fetch]
runs-on: ${{ matrix.os.runner }}
strategy:
fail-fast: false # Continue other jobs if one fails to help filling the cache
matrix:
os:
- name: "macOS"
runner: "macos-latest"
target: "x86_64-apple-darwin"
- name: "Windows"
runner: "windows-latest"
target: "x86_64-pc-windows-msvc"
- name: "Linux"
runner: "ubuntu-latest"
target: "x86_64-unknown-linux-musl"
toolchain:
- stable
- beta
- nightly
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Install toolchain
id: toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.os.target }}
profile: minimal
override: true
- name: Setup Cargo cache
uses: actions/cache@v2.1.6
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-${{ hashFiles('**/Cargo.lock') }}-${{ runner.os }}
- name: Setup build cache
uses: actions/cache@v2.1.6
with:
path: |
target
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.os.target }}-${{ steps.toolchain.outputs.rustc_hash }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --offline
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --offline