From 8d576cd1f9d2b1c274c40977ae4521a6be30eb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Thu, 9 Nov 2023 08:34:01 +0100 Subject: [PATCH] worflow upgrade --- .github/workflows/benches.yml | 25 ++++++-- .github/workflows/clippy.yml | 35 +++++++++++ .github/workflows/coverage.yml | 28 ++++++--- .github/workflows/fmt.yml | 14 ++--- .github/workflows/rust.yml | 89 ++++++++++++++++------------ .github/workflows/rust_beta.yml | 27 +++------ .github/workflows/rust_doc.yml | 36 ++++++++--- .github/workflows/rust_doc_check.yml | 22 ++++--- .github/workflows/rust_test.yml | 69 +++++++++++++++++++++ 9 files changed, 248 insertions(+), 97 deletions(-) create mode 100644 .github/workflows/clippy.yml create mode 100644 .github/workflows/rust_test.yml diff --git a/.github/workflows/benches.yml b/.github/workflows/benches.yml index aed868b2..84a1eea6 100644 --- a/.github/workflows/benches.yml +++ b/.github/workflows/benches.yml @@ -3,28 +3,41 @@ name: Benches on: push: branches: [ main, develop ] - + workflow_call: + inputs: + toolchain: + description: 'rust toolchain' + required: true + default: 'stable' + type: choice + 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 diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 00000000..08ca36bc --- /dev/null +++ b/.github/workflows/clippy.yml @@ -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 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0d2e997b..8ee0b068 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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: @@ -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 diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index 716b848f..83eb8fd2 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -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: @@ -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 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1025f0e8..d943d3b7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,16 +2,26 @@ 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: ABouttefeux/lattice-qcd-rs/.github/workflows/fmt.yml + + rustdoc-check: + name: rustdoc check + uses: ABouttefeux/lattice-qcd-rs/.github/workflows/rust_doc_check.yml + with: + toolchain: stable + + rust_test: + name: rust test + needs: [format] strategy: matrix: os: [ubuntu-latest, windows-latest] @@ -19,47 +29,48 @@ jobs: exclude: - os: windows-latest profile: release - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - default: true + uses: ABouttefeux/lattice-qcd-rs/.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: Run tests with serd - run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize" + # - name: Install Rust stable toolchain + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: stable + # default: true - - name: Run examples tests with serd - run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize" --examples + # - 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 # 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: ABouttefeux/lattice-qcd-rs/.github/workflows/clippy.yml + with: + features_flag: --all-features + + coverage: + name: coverage + uses: ABouttefeux/lattice-qcd-rs/.github/workflows/coverage.yml + with: + profile_file_name_prefix: lattice-qcd-rs + features_flag: --no-default-features --features="serde-serialize" diff --git a/.github/workflows/rust_beta.yml b/.github/workflows/rust_beta.yml index 2935a3fe..4fda0821 100644 --- a/.github/workflows/rust_beta.yml +++ b/.github/workflows/rust_beta.yml @@ -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: ABouttefeux/lattice-qcd-rs/.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 }} \ No newline at end of file diff --git a/.github/workflows/rust_doc.yml b/.github/workflows/rust_doc.yml index 72a15a1c..e5198ffe 100644 --- a/.github/workflows/rust_doc.yml +++ b/.github/workflows/rust_doc.yml @@ -3,28 +3,46 @@ name: Rust doc publish on: push: branches: [ main ] - + workflow_call: + inputs: + toolchain: + description: 'rust toolchain' + required: true + default: 'stable' + type: choice + options: + - stable + - nightly + - beta + env: CARGO_TERM_COLOR: always jobs: + check_doc: + uses: ABouttefeux/lattice-qcd-rs/.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: diff --git a/.github/workflows/rust_doc_check.yml b/.github/workflows/rust_doc_check.yml index 2a1eaf2b..628edca8 100644 --- a/.github/workflows/rust_doc_check.yml +++ b/.github/workflows/rust_doc_check.yml @@ -1,16 +1,23 @@ name: Rust Doc check on: - push: - pull_request: - branches: [ main, develop ] - + workflow_call: + inputs: + toolchain: + description: 'rust toolchain' + required: false + type: choice + options: + - stable + - nightly + - beta + env: CARGO_TERM_COLOR: always jobs: rustdoc-check: - + name: Rust Doc check runs-on: ubuntu-latest steps: @@ -20,8 +27,9 @@ 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 + run: cargo doc --verbose --all --no-deps --document-private-items --all-features diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml new file mode 100644 index 00000000..00849eeb --- /dev/null +++ b/.github/workflows/rust_test.yml @@ -0,0 +1,69 @@ +name: Rust-Beta + +on: + workflow_call: + inputs: + features_flag_1: + description: 'feature flag used on the cargo command for the firts test' + required: true + default: '--all-features' + type: string + features_flag_2: + description: 'feature flag used on the cargo command for the second test' + required: false + type: string + toolchain: + description: 'rust toolchain' + required: false + type: choice + options: + - stable + - nightly + - beta + os: + description: 'os to run the CI' + required: true + default: 'ubuntu-latest' + type: string + profile: + description: 'rust compilation profile' + required: true + default: 'test' + type: choice + options: + - test + - debug + - release + +env: + CARGO_TERM_COLOR: always + +jobs: + rust_test: + name: rust test + runs-on: ${{ inputs.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust beta toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ inputs.toolchain }} + default: true + + - name: Run tests 1 + run: cargo +beta test --profile ${{ inputs.profile }} --all --verbose --no-fail-fast ${{ inputs.features_flag_1 }} + + - name: Run example tests 1 + run: cargo +beta test --profile ${{ inputs.profile }} --all --verbose --no-fail-fast ${{ inputs.features_flag_1 }} --examples + + + - name: Run tests 2 + if: ${{ inputs.features_flag_2 != null }} + run: cargo +beta test --profile ${{ inputs.profile }} --all --verbose --no-fail-fast ${{ inputs.features_flag_2 }} + + - name: Run example tests 2 + if: ${{ inputs.features_flag_2 != null }} + run: cargo +beta test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast ${{ inputs.features_flag_2 }} --examples