Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve GitHub Actions for faster checks and better readability #3377

Merged
merged 11 commits into from
Jan 25, 2022
123 changes: 32 additions & 91 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
path:
- '**/*.rs'
- '**/*.txt'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/deny.toml'
- 'docker/**'
- '.github/workflows/ci.yml'

jobs:

test:
name: Test (+${{ matrix.rust }}) on ${{ matrix.os }}
# The large timeout is to accommodate:
Expand Down Expand Up @@ -246,6 +250,13 @@ jobs:

- uses: Swatinem/rust-cache@v1

# This check makes sure the crate dependency check is accurate
- name: Check Cargo.lock is up to date
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --locked --all-features --all-targets

- name: cargo fetch
uses: actions-rs/cargo@v1.0.3
with:
Expand All @@ -265,94 +276,24 @@ jobs:
command: build
args: --verbose --release

clippy-deps:
name: Clippy (stable)
timeout-minutes: 30
cargo-deny:
name: Check deny.toml crate dependencies and validate licenses
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full

steps:
- uses: actions/checkout@v2.4.0
with:
persist-credentials: false

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

- uses: Swatinem/rust-cache@v1

- name: Show env vars
run: |
echo "Common env vars:"
echo "RUST_BACKTRACE=${{ env.RUST_BACKTRACE }}"
echo "Build env vars:"
echo "CARGO_INCREMENTAL=${{ env.CARGO_INCREMENTAL }}"
echo "CARGO_TARGET_DIR=${{ env.CARGO_TARGET_DIR }}"

- name: Run clippy
uses: actions-rs/clippy-check@v1.0.7
with:
# GitHub displays the clippy job and its results as separate entries
name: Clippy (stable) Results
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings

# This check makes sure the crate dependency check is accurate
- name: Check Cargo.lock is up to date
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --locked --all-features --all-targets

# Edit zebra/deny.toml to allow duplicate dependencies
- name: Check for dependent crates with different versions
uses: EmbarkStudios/cargo-deny-action@v1.2.9
with:
command: check bans
args: --all-features --workspace

- name: Check crate sources
uses: EmbarkStudios/cargo-deny-action@v1.2.9
with:
command: check sources
args: --all-features --workspace
strategy:
matrix:
checks:
- bans
- sources

fmt:
name: Rustfmt
timeout-minutes: 30
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'advisories' }}

steps:
- uses: actions/checkout@v2.4.0
with:
persist-credentials: false

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

- uses: Swatinem/rust-cache@v1

- name: Show env vars
run: |
echo "Common env vars:"
echo "RUST_BACKTRACE=${{ env.RUST_BACKTRACE }}"
echo "Build env vars:"
echo "CARGO_INCREMENTAL=${{ env.CARGO_INCREMENTAL }}"
echo "CARGO_TARGET_DIR=${{ env.CARGO_TARGET_DIR }}"

- name: Check rustfmt
uses: actions-rs/cargo@v1.0.3
with:
command: fmt
args: --all -- --check
- uses: actions/checkout@v2
with:
persist-credentials: false

- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
args: --all-features --workspace
13 changes: 7 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: Coverage
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
path:
- '**/*.rs'
- '**/*.txt'
- '**/Cargo.toml'
- '**/Cargo.lock'
- 'codecov.yml'
- '.github/workflows/coverage.yml'

jobs:

coverage:
name: Coverage (+nightly)
# The large timeout is to accommodate:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ on:
push:
branches:
- main
path:
- 'book/**'
- '**/firebase.json'
- 'katex-header.html'
- '.github/workflows/docs.yml'

jobs:

build:
name: Build and Deploy Docs (+beta)
timeout-minutes: 30
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Lint Rust files

on:
push:
branches:
- "**"
- "!main"
path:
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- 'clippy.toml'
- '.cargo/config.toml'
- '.github/workflows/lint.yml'

env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full

jobs:
clippy:
name: Clippy
timeout-minutes: 30
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
persist-credentials: false

- name: Run clippy
uses: actions-rs/clippy-check@v1.0.7
with:
# GitHub displays the clippy job and its results as separate entries
name: Clippy (stable) Results
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings

fmt:
name: Rustfmt
timeout-minutes: 30
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
persist-credentials: false

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

- uses: Swatinem/rust-cache@v1 # TODO: No cache is being found

- uses: actions-rs/cargo@v1.0.3
with:
command: fmt
args: --all -- --check
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ on:
push:
branches:
- main
path:
- '**/*.rs'
- '**/*.txt'
- '**/Cargo.toml'
- '**/Cargo.lock'
- 'docker/**'
- '.github/workflows/test.yml'

env:
PROJECT_ID: zealous-zebra
Expand Down