From 872571f6af7a24a6840740f3649667f4a3493283 Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Sat, 3 Feb 2024 12:47:43 +0100 Subject: [PATCH] ci: update workflow --- .github/workflows/ci.yml | 124 ++++++++++++++++++++++++--------- .github/workflows/coverage.yml | 24 ------- 2 files changed, 91 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c84c28..7548bd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,42 +1,100 @@ +on: + push: + pull_request: + merge_group: + name: CI -permissions: - contents: read +jobs: -on: [pull_request, push] + coverage: + name: Test Suite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + run: | + cd auctioning_platform + cargo llvm-cov --all-features --workspace --codecov --output-path codecov.json + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-ubuntu + path: codecov.json -jobs: - build: - name: ${{ matrix.task.name }} (${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - rust: [stable] - task: - - name: Check format - run: cargo fmt -- --check - allow_failure: false - - name: Clippy - run: cargo clippy - allow_failure: true - - name: Test - run: cargo test --all - allow_failure: false + upload-coverage: + name: Upload test coverage to CodeCov + needs: [coverage] + runs-on: ubuntu-latest + permissions: + statuses: write steps: - - uses: actions/checkout@v2 + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v4 - - name: Install Rust ${{ matrix.rust }} - uses: actions-rs/toolchain@v1 + - name: download coverage files + uses: actions/download-artifact@v4 with: - toolchain: ${{ matrix.rust }} - profile: minimal - override: true - components: rustfmt, clippy + pattern: coverage-* - - name: ${{ matrix.task.name }} - run:| + - name: display files + run: | + ls -aR + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + # directory: ./coverage + # env_vars: OS,PYTHON + fail_ci_if_error: false + files: ./coverage-ubuntu/codecov.json + # flags: unittests + # name: codecov-umbrella + verbose: true + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + components: rustfmt + - run: | + cd auctioning_platform + cargo fmt --check --all + + lint: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + components: clippy + - run: | cd auctioning_platform - ${{ matrix.task.run }} - continue-on-error: ${{ matrix.task.allow_failure }} + cargo clippy -- -D warnings + + # https://github.com/marketplace/actions/alls-green#why used for branch protection checks + check: + if: always() + needs: [lint, coverage, fmt] + runs-on: ubuntu-latest + permissions: {} + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + allowed-failures: lint diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index e34e8cf..0000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: coverage - -on: [push] -jobs: - test: - name: coverage - runs-on: ubuntu-latest - container: - image: xd009642/tarpaulin:develop-nightly - options: --security-opt seccomp=unconfined - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Generate code coverage - run: | - cd auctioning_platform - cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml - - - name: Upload to codecov.io - uses: codecov/codecov-action@v2 - with: - # token: ${{secrets.CODECOV_TOKEN}} # not required for public repos - fail_ci_if_error: true \ No newline at end of file