Skip to content

Commit

Permalink
worflow upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ABouttefeux committed Nov 17, 2023
1 parent 088e0de commit ec5e8b9
Show file tree
Hide file tree
Showing 12 changed files with 333 additions and 124 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/benches.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
name: Benches
name: Rust benches

on:
push:
branches: [ main, develop ]

workflow_call:
inputs:
toolchain:
description: 'rust toolchain'
required: false
default: 'stable'
type: string
# options:
# - stable
# - nightly
# - beta

env:
CARGO_TERM_COLOR: always

jobs:
bench:
name: Run benches for Lattice QCD rs
name: Run criterion benches
runs-on: ubuntu-latest
# env:
# CRITERION_TOKEN: ${{ secrets.CRITERION_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust stable toolchain

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: ${{ inputs.toolchain }}
default: true

- name: Run benchmarks
run: |
# run benchmarks and save baseline in a directory called "new"
cargo bench
run: cargo bench --verbose

# - name: Upload benchmarks
# env:
# CRITERION_TOKEN: ${{ secrets.CRITERION_TOKEN }}
# run: |
# # upload the files
# bash <(curl -s https://criterion.dev/bash)
39 changes: 39 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: clippy check

on:
workflow_call:
inputs:
features_flag:
description: 'feature flag used on the cargo command'
required: false
default: '--all-features'
type: string
toolchain:
description: 'rust toolchain'
required: false
type: string

env:
CARGO_TERM_COLOR: always

jobs:
linter:
name: lint code with clippy on nightly
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.toolchain }}
components: cargo, clippy
default: true

- name: Linter
run: cargo clippy --all --verbose --all-targets ${{ inputs.features_flag }} -- --no-deps --deny warnings

- name: Linter release
run: cargo clippy --all --verbose --all-targets --release ${{ inputs.features_flag }} -- --no-deps --deny warnings
26 changes: 19 additions & 7 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ name: coverage
env:
CARGO_TERM_COLOR: always

on:
push:
on:
workflow_call:
inputs:
profile_file_name_prefix:
description: 'prefix of the LLVM profile file'
required: true
default: 'profile'
type: string
features_flag:
description: 'feature flag used on the cargo command'
required: true
default: '--all-features'
type: string

jobs:
coverage:
Expand All @@ -25,12 +36,13 @@ jobs:
run: curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf -

- name: Generate code coverage
env:
RUSTFLAGS: -Cinstrument-coverage
RUSTDOCFLAGS: -Cinstrument-coverage -Zunstable-options --persist-doctests target/debug/doctestbins
LLVM_PROFILE_FILE: ${{ inputs.profile_file_name_prefix }}-%p-%m.profraw
run: |
export RUSTFLAGS="-Cinstrument-coverage"
export RUSTDOCFLAGS="-Cinstrument-coverage -Zunstable-options --persist-doctests target/debug/doctestbins"
export LLVM_PROFILE_FILE="lattice_qcd_rs-%p-%m.profraw"
cargo +nightly test --verbose --all --no-default-features --features="serde-serialize"
cargo +nightly test --verbose --all --no-default-features --features="serde-serialize" --examples
cargo +nightly test --verbose --all --all-targets ${{ inputs.features_flag }}
cargo +nightly test --verbose --all --doc ${{ inputs.features_flag }}
- name: parse code coverage
run: ./grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: fmt
name: fmt check

on:
push:
pull_request:
branches: [ main, develop ]
workflow_call:

env:
CARGO_TERM_COLOR: always

jobs:
fmt:

name: check the format of the code
runs-on: ubuntu-latest

steps:
Expand All @@ -21,8 +19,8 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
components: rustfmt, cargo
default: true

- name: fmt
run: cargo +nightly fmt --all -- --check
- name: rustfmt check
run: cargo +nightly fmt --all --check
108 changes: 68 additions & 40 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,93 @@
name: Rust
name: Rust checks

on:
push:
pull_request:
branches: [ main, develop ]
# pull_request:
# branches: [ main, develop ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ${{ matrix.os }}
format:
name: check the format of the code
uses: ./.github/workflows/fmt.yml

rustdoc-check:
name: rustdoc check
uses: ./.github/workflows/rust_doc_check.yml
with:
toolchain: stable

rust_test:
name: rust test
needs: [format]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
profile: [test, release]
exclude:
- os: windows-latest
profile: release
steps:
- name: Checkout repository
uses: actions/checkout@v4

uses: ./.github/workflows/rust_test.yml
with:
features_flag_1: --features="serde-serialize"
features_flag_2: --no-default-features --features="overflow-test"
toolchain: stable
os: ${{ matrix.os }}
profile: ${{ matrix.profile }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
# - name: Install Rust stable toolchain
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# default: true

- name: Run tests with serd
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize"
# - name: Run tests with serd
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize"

- name: Run examples tests with serd
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize" --examples
# - name: Run examples tests with serd
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize" --examples

# it is faster to keep the going and reuse previous compilation artefact than using
# a matrix strategy and starting all over again
- name: Run tests no features
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test"
# - name: Run tests no features
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test"

- name: Run examples tests no features
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test" --examples
# - name: Run examples tests no features
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test" --examples

linter:
name: lint code on nightly release
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
default: true

- name: Linter
run: cargo +nightly clippy --all --verbose --tests --all-features -- --no-deps --deny warnings

- name: Linter release
run: cargo +nightly clippy --all --verbose --tests --release --all-features -- --no-deps --deny warnings
needs: [format, rustdoc-check]
uses: ./.github/workflows/clippy.yml
with:
features_flag: --all-features
toolchain: nightly

coverage:
name: coverage
uses: ./.github/workflows/coverage.yml
with:
profile_file_name_prefix: lattice-qcd-rs
features_flag: --no-default-features --features="serde-serialize"

benches:
name: benches
needs: [format, coverage, rust_test]
if: ${{ github.ref_name == 'main' || github.ref_name == 'develop' }}
uses: ./.github/workflows/benches.yml
with:
toolchain: stable

doc_publish:
name: publish rust doc
needs: [format, coverage, rust_test, rustdoc-check, linter]
if: ${{ github.ref_name == 'main' }}
uses: ./.github/workflows/rust_doc_publish.yml
with:
toolchain: stable
36 changes: 0 additions & 36 deletions .github/workflows/rust_beta.yml

This file was deleted.

36 changes: 27 additions & 9 deletions .github/workflows/rust_doc_check.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
name: Rust Doc check
name: Rust doc check

on:
push:
pull_request:
branches: [ main, develop ]

workflow_call:
inputs:
toolchain:
description: 'rust toolchain'
required: false
type: string
# options:
# - stable
# - nightly
# - beta
check_private_items:
description: 'wether to check documentation for private item'
required: false
default: true
type: boolean

env:
CARGO_TERM_COLOR: always

jobs:
rustdoc-check:

name: Rust Doc check
runs-on: ubuntu-latest

steps:
Expand All @@ -20,8 +32,14 @@ jobs:
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: ${{ inputs.toolchain }}
components: rust-docs, cargo
default: true

- name: Doc
run: cargo +stable doc --all --no-deps --document-private-items --all-features
- name: Doc check
if: ${{ inputs.check_private_items }}
run: cargo doc --verbose --all --no-deps --document-private-items --all-features

- name: Doc check
if: ${{ !inputs.check_private_items }}
run: cargo doc --verbose --all --no-deps --all-features
Loading

0 comments on commit ec5e8b9

Please sign in to comment.