From ec5e8b9e7b130b09848625bd927040ceaee26f39 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 | 34 ++++-- .github/workflows/clippy.yml | 39 +++++++ .github/workflows/coverage.yml | 26 +++-- .github/workflows/fmt.yml | 14 +-- .github/workflows/rust.yml | 108 +++++++++++------- .github/workflows/rust_beta.yml | 36 ------ .github/workflows/rust_doc_check.yml | 36 ++++-- .../{rust_doc.yml => rust_doc_publish.yml} | 33 ++++-- .github/workflows/rust_experimental.yml | 45 ++++++++ .github/workflows/rust_test.yml | 81 +++++++++++++ .gitignore | 1 - rust-toolchain.toml | 4 + 12 files changed, 333 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/clippy.yml delete mode 100644 .github/workflows/rust_beta.yml rename .github/workflows/{rust_doc.yml => rust_doc_publish.yml} (54%) create mode 100644 .github/workflows/rust_experimental.yml create mode 100644 .github/workflows/rust_test.yml create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/benches.yml b/.github/workflows/benches.yml index aed868b2..51751524 100644 --- a/.github/workflows/benches.yml +++ b/.github/workflows/benches.yml @@ -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) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 00000000..646d7476 --- /dev/null +++ b/.github/workflows/clippy.yml @@ -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 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0d2e997b..189d80c9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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: @@ -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 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..3aee1f6f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,17 +1,27 @@ -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] @@ -19,47 +29,65 @@ jobs: 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 diff --git a/.github/workflows/rust_beta.yml b/.github/workflows/rust_beta.yml deleted file mode 100644 index 2935a3fe..00000000 --- a/.github/workflows/rust_beta.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Rust-Beta - -on: - push: - branches: [ main, develop ] - -env: - CARGO_TERM_COLOR: always - -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 diff --git a/.github/workflows/rust_doc_check.yml b/.github/workflows/rust_doc_check.yml index 2a1eaf2b..e4b3b04c 100644 --- a/.github/workflows/rust_doc_check.yml +++ b/.github/workflows/rust_doc_check.yml @@ -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: @@ -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 diff --git a/.github/workflows/rust_doc.yml b/.github/workflows/rust_doc_publish.yml similarity index 54% rename from .github/workflows/rust_doc.yml rename to .github/workflows/rust_doc_publish.yml index 72a15a1c..afec558b 100644 --- a/.github/workflows/rust_doc.yml +++ b/.github/workflows/rust_doc_publish.yml @@ -1,30 +1,41 @@ name: Rust doc publish on: - push: - branches: [ main ] - + workflow_call: + inputs: + toolchain: + description: 'rust toolchain' + required: false + default: 'stable' + type: string + # options: + # - stable + # - nightly + # - beta + env: CARGO_TERM_COLOR: always jobs: + rustdoc: - + name: Rust doc publish 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_experimental.yml b/.github/workflows/rust_experimental.yml new file mode 100644 index 00000000..fc0065f4 --- /dev/null +++ b/.github/workflows/rust_experimental.yml @@ -0,0 +1,45 @@ +name: Rust experimental + +on: + push: + branches: [ main, develop ] + schedule: + - cron: '0 12 * * 5' + +env: + CARGO_TERM_COLOR: always + +jobs: + build-beta-push: + name: rust experimental tests on push + if: ${{ github.event_name == 'push' }} + strategy: + matrix: + profile: [test, release] + toolchain: [beta, nightly] + + uses: ./.github/workflows/rust_test.yml + with: + features_flag_1: --features="serde-serialize" + features_flag_2: --no-default-features --features="overflow-test" + toolchain: ${{ matrix.toolchain }} + os: ubuntu-latest + profile: ${{ matrix.profile }} + + build-beta-schedule: + name: rust experimental tests on schedule + if: ${{ github.event_name == 'schedule' }} + strategy: + matrix: + profile: [test, release] + toolchain: [beta, nightly] + branche: [main, develop] + + uses: ./.github/workflows/rust_test.yml + with: + features_flag_1: --features="serde-serialize" + features_flag_2: --no-default-features --features="overflow-test" + toolchain: ${{ matrix.toolchain }} + os: ubuntu-latest + profile: ${{ matrix.profile }} + ref: ${{ matrix.branche }} diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml new file mode 100644 index 00000000..8860dbfa --- /dev/null +++ b/.github/workflows/rust_test.yml @@ -0,0 +1,81 @@ +name: Rust test + +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: string + # 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: string + # options: + # - test + # - debug + # - release + update: + description: 'should we run cargo update' + required: false + default: false + type: boolean + ref: + description: 'The branch, tag or SHA to checkout.' + required: false + type: string + +env: + CARGO_TERM_COLOR: always + +jobs: + rust_test: + name: rust test + runs-on: ${{ inputs.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ inputs.toolchain }} + default: true + + - name: cargo update + if: ${{ inputs.update }} + run: cargo update --verbose + + - name: Run tests 1 + run: cargo test --verbose --profile ${{ inputs.profile }} --all --all-targets --no-fail-fast ${{ inputs.features_flag_1 }} + - name: Run doc tests 1 + run: cargo test --verbose --profile ${{ inputs.profile }} --all --doc --no-fail-fast ${{ inputs.features_flag_1 }} + + - name: Run tests 2 + if: ${{ inputs.features_flag_2 != null && inputs.features_flag_2 != '' }} + run: cargo test --verbose --profile ${{ inputs.profile }} --all --all-targets --no-fail-fast ${{ inputs.features_flag_2 }} + - name: Run doc tests 2 + if: ${{ inputs.features_flag_2 != null && inputs.features_flag_2 != '' }} + run: cargo test --verbose --profile ${{ inputs.profile }} --all --doc --no-fail-fast ${{ inputs.features_flag_2 }} diff --git a/.gitignore b/.gitignore index 6ef88089..e10c054a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,3 @@ Cargo.lock data/ .vscode/settings.json logo.png -rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..445603b2 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly" +profile = "default" +components = ["cargo", "rustfmt", "rust-docs", "clippy"]