Skip to content

Commit

Permalink
ci: Optimize and streamline CI process for testing and formatting (#2)
Browse files Browse the repository at this point in the history
- Extended continuous integration (CI) triggers to include the "dev" branch.
- Refactored Github workflows to enhance and simplify CI execution.
- Enabled `git` access for private repositories within the CI environment.
- Incorporated doctests in the CI process.
  • Loading branch information
huitseeker authored Jun 5, 2024
1 parent f54b0e7 commit a52a460
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 111 deletions.
10 changes: 10 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[alias]
# Collection of project wide clippy lints. This is done via an alias because
# clippy doesn't currently allow for specifiying project-wide lints in a
# configuration file. This is a similar workaround to the ones presented here:
# <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
# TODO: add support for --all-features
xclippy = [
"clippy", "--all-targets", "--",
"-Wclippy::all",
]
12 changes: 12 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[profile.ci]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"
# Show skipped tests in the CI output.
status-level = "skip"
# Do not cancel the test run on the first failure.
fail-fast = false
# Mark tests as slow after 5mins, kill them after 20mins
slow-timeout = { period = "300s", terminate-after = 4 }
# Retry failed tests once, marked flaky if test then passes
retries = 1
154 changes: 43 additions & 111 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
branches: [ "main" ]
branches: [ "main", "dev" ]
pull_request:
branches: [ "*" ]

Expand All @@ -11,117 +11,49 @@ env:
CARGO_INCREMENTAL: 1

jobs:
build_and_test:
name: Build and Test
test:
# Change to warp-ubuntu-latest-x64-16x for a more powerful runner
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"

steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
id: rs-stable

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: rust-${{ steps.rs-stable.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.toml') }}

- name: Build
run: cargo build --verbose --all-targets

- name: Check with parallel
run: cargo check --verbose --all-targets --features parallel

- name: Test
run: cargo test --verbose

- name: Test with parallel
run: cargo test --verbose --features parallel

lint:
name: Formatting and Clippy
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"

steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
id: rs-stable

- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: rust-${{ steps.rs-stable.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.toml') }}

- name: Clippy
run: cargo +stable clippy --all-targets -- -D warnings

- name: Format
run: cargo +nightly fmt --all -- --check

check_crates:
name: Check Crates
- name: Set up git private repo access
run: |
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://[email protected]
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Linux Tests
run: |
cargo nextest run --profile ci --workspace
- name: Linux Tests with the parallel feeature
run: |
cargo nextest run --profile ci --workspace --features parallel
clippy:
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"

steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
id: rs-stable

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: rust-${{ steps.rs-stable.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}

- name: Cargo Check Crates
run: |
cargo check --verbose --package p3-air
cargo check --verbose --package p3-baby-bear
cargo check --verbose --package p3-blake3
cargo check --verbose --package p3-challenger
cargo check --verbose --package p3-commit
cargo check --verbose --package p3-dft
cargo check --verbose --package p3-field
cargo check --verbose --package p3-field-testing
cargo check --verbose --package p3-fri
cargo check --verbose --package p3-goldilocks
cargo check --verbose --package p3-interpolation
cargo check --verbose --package p3-keccak
cargo check --verbose --package p3-keccak-air
cargo check --verbose --package p3-matrix
cargo check --verbose --package p3-maybe-rayon
cargo check --verbose --package p3-mds
cargo check --verbose --package p3-merkle-tree
cargo check --verbose --package p3-mersenne-31
cargo check --verbose --package p3-monolith
cargo check --verbose --package p3-poseidon
cargo check --verbose --package p3-poseidon2
cargo check --verbose --package p3-rescue
cargo check --verbose --package p3-symmetric
cargo check --verbose --package p3-uni-stark
cargo check --verbose --package p3-util
- name: Set up git private repo access
run: |
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://[email protected]
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Check Rustfmt Code Style
run: cargo fmt --all --check
- name: check *everything* compiles
run: cargo check --all-targets --all-features --workspace --examples --tests --benches
# See '.cargo/config' for list of enabled/disabled clippy lints
- name: Check clippy warnings
run: cargo xclippy -D warnings
- name: Doctests
run: cargo test --doc --workspace

0 comments on commit a52a460

Please sign in to comment.