From 545c7f132183d40f7ed873a43ebe3eed661138dd Mon Sep 17 00:00:00 2001 From: pvshvp-oss Date: Mon, 11 Mar 2024 05:16:33 -0500 Subject: [PATCH] Fix coverage CI --- .github/workflows/actions-rs/grcov.yml | 13 -- .github/workflows/api_documentation.yml | 14 +- .github/workflows/code_test_coverage.yml | 166 ++++++++----------- .github/workflows/security_audit.yml | 48 +----- .github/workflows/templates/multi_target.yml | 21 +-- 5 files changed, 89 insertions(+), 173 deletions(-) delete mode 100644 .github/workflows/actions-rs/grcov.yml diff --git a/.github/workflows/actions-rs/grcov.yml b/.github/workflows/actions-rs/grcov.yml deleted file mode 100644 index 001c63e..0000000 --- a/.github/workflows/actions-rs/grcov.yml +++ /dev/null @@ -1,13 +0,0 @@ -ignore: - - "/*" - - "C:/*" - - "C:\\*" - - "../*" - - "*/.cargo/*" - - "*\\.cargo\\*" - - "*github.com*" -branch: true -ignore-not-existing: true -llvm: true -filter: covered -output-type: lcov diff --git a/.github/workflows/api_documentation.yml b/.github/workflows/api_documentation.yml index 810b98c..cc5effe 100644 --- a/.github/workflows/api_documentation.yml +++ b/.github/workflows/api_documentation.yml @@ -38,36 +38,36 @@ jobs: - name: ๐ŸŽŸ Checkout Git Repository Step id: repository_checkout_step uses: actions/checkout@v4 - - name: โ†•๏ธ Install Ubuntu Dependencies + - name: โ†•๏ธ Install Ubuntu Dependencies Step id: dependencies_install_step if: ${{ matrix.cicd_runner == 'ubuntu-latest' }} uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libgtk-4-dev version: 1.0 - - name: ๐Ÿงฐ Install Rust Toolchain + - name: ๐Ÿงฐ Install Rust Toolchain Step id: toolchain_install_step uses: dtolnay/rust-toolchain@master with: toolchain: nightly targets: ${{ matrix.compilation_target }} components: rustc, cargo - - name: ๐Ÿ”„ Install Cross-Compilation Tools + - name: ๐Ÿ”„ Install Cross-Compilation Tools Step id: cross_install_step if: ${{ matrix.cpu_architecture != 'x86_64' }} uses: taiki-e/setup-cross-toolchain-action@v1 with: targets: ${{ matrix.compilation_target }} - - name: ๐Ÿ—‚ Setup Cache + - name: ๐Ÿ—‚ Setup Cache Step id: cache_setup_step uses: Swatinem/rust-cache@v2 - - name: ๐Ÿ“œ Cargo Doc + - name: ๐Ÿ“œ Cargo Doc Step id: cargo_doc_step env: RUSTDOCFLAGS: "--enable-index-page -Zunstable-options" run: | cargo doc --all-features --workspace --no-deps --document-private-items - - name: โฌ† Upload Docs Artifact + - name: โฌ† Upload Docs Artifact Step id: documentation_upload_step uses: actions/upload-pages-artifact@v3 with: @@ -86,7 +86,7 @@ jobs: name: github-pages url: ${{ steps.deployment_step.outputs.page_url }} steps: - - name: โœˆ Deploy to GitHub Pages + - name: โœˆ Deploy to GitHub Pages Step id: deployment_step uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.github/workflows/code_test_coverage.yml b/.github/workflows/code_test_coverage.yml index 0454e90..afba697 100644 --- a/.github/workflows/code_test_coverage.yml +++ b/.github/workflows/code_test_coverage.yml @@ -1,112 +1,82 @@ on: - workflow_dispatch: - workflow_call: push: - branches: [main] + paths: + - '.github/workflows/code_test_coverage.yml' # Run when this workflow changes + - '**/src/**' pull_request: branches: [main] + workflow_dispatch: # Run when manually triggered + workflow_call: # Run when called by another workflow -name: ๐Ÿ”Ž Code Test Coverage +name: ๐Ÿ”Ž Code Test Coverage Workflow jobs: - grcov: - name: ๐Ÿ”Ž grcov Code Coverage - if: | - !startsWith(github.event.head_commit.message, 'ci:') - && !startsWith(github.event.head_commit.message, 'ci(') - && !startsWith(github.event.head_commit.message, 'docs:') - && !startsWith(github.event.head_commit.message, 'docs(') - && !startsWith(github.event.head_commit.message, 'style:') - && !startsWith(github.event.head_commit.message, 'style(') + coverage_job: + name: ๐Ÿ”Ž Code Test Coverage Job strategy: - fail-fast: false + fail-fast: true matrix: - target: - - x86_64-unknown-linux-gnu - - x86_64-pc-windows-msvc - - x86_64-apple-darwin - # - aarch64-unknown-linux-gnu - # - aarch64-apple-darwin + platform: + - linux + # - windows + # - apple + cpu_architecture: [x86_64] include: - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - - target: x86_64-pc-windows-msvc - os: windows-latest - - target: x86_64-apple-darwin - os: macos-latest - # - target: aarch64-unknown-linux-gnu - # os: ubuntu-latest - # - target: aarch64-apple-darwin - # os: macos-latest - runs-on: ${{ matrix.os }} + - platform: linux + cicd_runner: ubuntu-latest + # - platform: windows + # cicd_runner: windows-latest + # - platform: apple + # cicd_runner: macos-latest + - compilation_target: x86_64-unknown-linux-gnu + cpu_architecture: x86_64 + platform: linux + toolchain: gnu + # - compilation_target: x86_64-pc-windows-msvc + # cpu_architecture: x86_64 + # platform: windows + # toolchain: msvc + # - compilation_target: x86_64-apple-darwin + # cpu_architecture: x86_64 + # platform: apple + # toolchain: darwin + runs-on: ${{ matrix.cicd_runner }} + if: | + ( + github.event_name == 'push' + && github.ref == 'refs/heads/main' + ) || ( + !startsWith(github.event.head_commit.message, 'style:') + && !startsWith(github.event.head_commit.message, 'style(') + && !startsWith(github.event.head_commit.message, 'chore:') + && !startsWith(github.event.head_commit.message, 'chore(') + ) steps: - - name: ๐ŸŽŸ Checkout Git Repository - id: checkout_repository_step - uses: actions/checkout@v2 - - name: ๐Ÿงฐ Install Rust Toolchain - id: install_toolchain_step - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly # Required for -Zprofile - override: true - target: ${{ matrix.target }} - - name: ๐Ÿ—‚ Set up cargo cache - id: setup_cache_step - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo- - - name: ๐Ÿงช Execute tests - id: execute_tests_step - uses: actions-rs/cargo@v1 - env: - CARGO_INCREMENTAL: 0 - RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" + - name: ๐ŸŽŸ Checkout Git Repository Step + id: repository_checkout_step + uses: actions/checkout@v4 + - name: ๐Ÿงฐ Install Rust Toolchain Step + id: toolchain_install_step + uses: dtolnay/rust-toolchain@master with: - command: test - args: --workspace --target ${{ matrix.target }} - - name: ๐Ÿ’ฝ Pre-Installing grcov - id: preinstall_grcov_step - uses: actions-rs/install@v0.1 + toolchain: nightly + targets: ${{ matrix.compilation_target }} + components: rustc, cargo + - name: ๐Ÿ”„ Install Cross-Compilation Tools Step + id: cross_install_step + if: ${{ matrix.cpu_architecture != 'x86_64' }} + uses: taiki-e/setup-cross-toolchain-action@v1 with: - crate: grcov - use-tool-cache: true - - name: ๐Ÿ”Ž Gather Coverage Data - id: coverage_gather_step - uses: actions-rs/grcov@v0.1 - with: - config: .github/actions-rs/grcov.yml - coveralls-token: ${{ secrets.COVERALLS_TOKEN }} - - name: โฌ† Coveralls Upload - id: coveralls_upload_step - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel: true - path-to-lcov: ${{ steps.coverage_gather_step.outputs.report }} - - grcov_finalize: - name: โœ” Finalize grcov Code Coverage - if: | - !startsWith(github.event.head_commit.message, 'ci:') - && !startsWith(github.event.head_commit.message, 'ci(') - && !startsWith(github.event.head_commit.message, 'docs:') - && !startsWith(github.event.head_commit.message, 'docs(') - && !startsWith(github.event.head_commit.message, 'style:') - && !startsWith(github.event.head_commit.message, 'style(') - runs-on: ubuntu-latest - needs: grcov - steps: - - name: โœ” Coveralls Finalization - id: coveralls_finalization_step - uses: coverallsapp/github-action@master + targets: ${{ matrix.compilation_target }} + - name: ๐Ÿ—‚ Setup Cache Step + id: cache_setup_step + uses: Swatinem/rust-cache@v2 + - name: ๐Ÿ”Ž Generate Code Coverage Step + id: coverage_generation_step + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + - name: ๐Ÿ“Š Upload coverage to Codecov Step + id: coverage_upload_step + uses: codecov/codecov-action@v3 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true + files: lcov.info + fail_ci_if_error: true diff --git a/.github/workflows/security_audit.yml b/.github/workflows/security_audit.yml index dc8ed16..b495b8c 100644 --- a/.github/workflows/security_audit.yml +++ b/.github/workflows/security_audit.yml @@ -19,15 +19,8 @@ jobs: strategy: fail-fast: false matrix: - platform: - - linux - - windows - - apple - cpu_architecture: - # - i686 - - x86_64 - # - aarch64 - # - riscv64gc + platform: [linux, windows, apple] + cpu_architecture: [x86_64] include: - platform: linux cicd_runner: ubuntu-latest @@ -39,42 +32,14 @@ jobs: cpu_architecture: x86_64 platform: linux toolchain: gnu - # - compilation_target: x86_64-unknown-linux-musl - # cpu_architecture: x86_64 - # platform: linux - # toolchain: musl - compilation_target: x86_64-pc-windows-msvc cpu_architecture: x86_64 platform: windows toolchain: msvc - # - compilation_target: x86_64-pc-windows-gnu - # cpu_architecture: x86_64 - # platform: windows - # toolchain: gnu - compilation_target: x86_64-apple-darwin cpu_architecture: x86_64 platform: apple toolchain: darwin - # - compilation_target: aarch64-unknown-linux-gnu - # cpu_architecture: aarch64 - # platform: linux - # toolchain: gnu - # - compilation_target: aarch64-unknown-linux-musl - # cpu_architecture: aarch64 - # platform: linux - # toolchain: musl - # - compilation_target: aarch64-pc-windows-msvc - # cpu_architecture: aarch64 - # platform: windows - # toolchain: msvc - # - compilation_target: aarch64-apple-darwin - # cpu_architecture: aarch64 - # platform: apple - # toolchain: darwin - # - compilation_target: riscv64gc-unknown-linux-gnu - # cpu_architecture: riscv64gc - # platform: linux - # toolchain: gnu permissions: contents: read issues: write @@ -89,14 +54,15 @@ jobs: with: python-version: '3.11' cache: 'pip' - - name: โ†•๏ธ Install dependencies + - name: โ†•๏ธ Install Dependencies Step id: dependencies_install_step run: | python -m pip install --upgrade pip pip install requests + - name: ๐Ÿ—‚ Setup Cache Step + id: cache_setup_step + uses: Swatinem/rust-cache@v2 - name: ๐Ÿ•ต๏ธโ€โ™‚๏ธ Security Audit Step id: audit_step uses: actions-rust-lang/audit@v1 - - name: ๐Ÿ—‚ Setup Cache - id: cache_setup_step - uses: Swatinem/rust-cache@v2 + \ No newline at end of file diff --git a/.github/workflows/templates/multi_target.yml b/.github/workflows/templates/multi_target.yml index 4dafa46..85825b2 100644 --- a/.github/workflows/templates/multi_target.yml +++ b/.github/workflows/templates/multi_target.yml @@ -91,36 +91,29 @@ jobs: - name: ๐ŸŽŸ Checkout Git Repository Step id: repository_checkout_step uses: actions/checkout@v4 - - name: โ†•๏ธ Install Ubuntu Dependencies - id: dependencies_install_step - if: ${{ matrix.cicd_runner == 'ubuntu-latest' }} - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libgtk-4-dev - version: 1.0 - - name: ๐Ÿงฐ Install Rust Toolchain + - name: ๐Ÿงฐ Install Rust Toolchain Step id: toolchain_install_step uses: dtolnay/rust-toolchain@master with: toolchain: nightly targets: ${{ matrix.compilation_target }} components: rustc, cargo - - name: ๐Ÿ”„ Install Cross-Compilation Tools + - name: ๐Ÿ”„ Install Cross-Compilation Tools Step id: cross_install_step if: ${{ matrix.cpu_architecture != 'x86_64' }} uses: taiki-e/setup-cross-toolchain-action@v1 with: targets: ${{ matrix.compilation_target }} - - name: ๐Ÿ—‚ Setup Cache + - name: ๐Ÿ—‚ Setup Cache Step id: cache_setup_step uses: Swatinem/rust-cache@v2 - - name: ๐Ÿ“œ Cargo Doc + - name: ๐Ÿ“œ Cargo Doc Step id: cargo_doc_step env: RUSTDOCFLAGS: "--enable-index-page -Zunstable-options" run: | cargo doc --all-features --workspace --no-deps --document-private-items - - name: โฌ† Upload Docs Artifact + - name: โฌ† Upload Docs Artifact Step id: documentation_upload_step uses: actions/upload-pages-artifact@v3 with: @@ -139,6 +132,6 @@ jobs: name: github-pages url: ${{ steps.deployment_step.outputs.page_url }} steps: - - name: โœˆ Deploy to GitHub Pages + - name: โœˆ Deploy to GitHub Pages Step id: deployment_step - uses: actions/deploy-pages@v4 \ No newline at end of file + uses: actions/deploy-pages@v4 \ No newline at end of file