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
121 changes: 32 additions & 89 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ name: CI
on:
workflow_dispatch:
pull_request:
push:
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
branches:
- main
path:
- '**/*.rs'
- '**/*.txt'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/deny.toml'
- 'docker/**'
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
- '.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 +252,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/[email protected]
with:
command: check
args: --locked --all-features --all-targets
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved

- name: cargo fetch
uses: actions-rs/[email protected]
with:
Expand All @@ -265,94 +278,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/[email protected]
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 }}"
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved

- name: Run clippy
uses: actions-rs/[email protected]
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/[email protected]
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/[email protected]
with:
command: check bans
args: --all-features --workspace

- name: Check crate sources
uses: EmbarkStudios/[email protected]
with:
command: check sources
args: --all-features --workspace
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
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' }}
teor2345 marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/[email protected]
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/[email protected]
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
11 changes: 7 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ on:
pull_request:
branches:
- main
push:
branches:
- main
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
path:
- '**/*.rs'
- '**/*.txt'
- '**/Cargo.toml'
- '**/Cargo.lock'
- 'codecov.yml'
- '.github/workflows/coverage.yml'
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved

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'
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved

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'
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved

env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full

jobs:
clippy:
name: Clippy
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
timeout-minutes: 30
runs-on: ubuntu-latest

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

- name: Run clippy
uses: actions-rs/[email protected]
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
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved

- uses: actions-rs/[email protected]
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