Skip to content

Commit

Permalink
worflow upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ABouttefeux committed Nov 10, 2023
1 parent 088e0de commit 4034efd
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 98 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/benches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,42 @@ name: Benches

on:
push:
branches: [ main, develop ]

# branches: [ main, develop ]
workflow_call:
inputs:
toolchain:
description: 'rust toolchain'
required: true
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
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: ${{ inputs.toolchain }}
# toolchain: stable
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
# run: |
# # upload the files
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: clippy check

on:
workflow_call:
inputs:
features_flag:
description: 'feature flag used on the cargo command'
required: true
default: '--all-features'
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: nightly
components: cargo, clippy
default: true

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

- name: Linter release
run: cargo +nightly clippy --all --verbose --tests --release ${{ inputs.features_flag }} -- --no-deps --deny warnings
28 changes: 20 additions & 8 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
name: coverage
name: coverage call

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 ${{ inputs.features_flag }}
cargo +nightly test --verbose --all ${{ inputs.features_flag }} --examples
- 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
89 changes: 50 additions & 39 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,75 @@ name: Rust

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, coverage, rust_test]
uses: ./.github/workflows/clippy.yml
with:
features_flag: --all-features

coverage:
name: coverage
uses: ./.github/workflows/coverage.yml
with:
profile_file_name_prefix: lattice-qcd-rs
features_flag: --no-default-features --features="serde-serialize"
27 changes: 7 additions & 20 deletions .github/workflows/rust_beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,14 @@ env:
jobs:
build-beta:
name: rust beta check
runs-on: ubuntu-latest
strategy:
matrix:
profile: [test, release]

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

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

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

- name: Run tests beta without serd
run: cargo +beta test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test"
- name: Run example tests beta without serd
run: cargo +beta test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test" --examples
uses: ./.github/workflows/rust_test.yml
with:
features_flag_1: --features="serde-serialize"
features_flag_2: --no-default-features --features="overflow-test"
toolchain: beta
os: ubuntu-latest
profile: ${{ matrix.profile }}
36 changes: 27 additions & 9 deletions .github/workflows/rust_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,46 @@ name: Rust doc publish
on:
push:
branches: [ main ]

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

env:
CARGO_TERM_COLOR: always

jobs:
check_doc:
uses: ./.github/workflows/rust_doc_check.yml
with:
toolchain: ${{ inputs.toolchain }}

rustdoc:

name: Rust doc publish
needs: check_doc
runs-on: ubuntu-latest

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

- 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 doc --all --no-deps --all-features

- name: build Doc
run: cargo doc --verbose --all --no-deps --all-features

- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
Loading

0 comments on commit 4034efd

Please sign in to comment.