From 89ddc388e823b883084f59443bc21d21859b777f Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 02:26:00 -0400 Subject: [PATCH 01/14] chore: add llvm-cov --- .github/workflows/coverage.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000000..b6e33c47fa --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,29 @@ +name: Coverage + +on: + push: + branches: ["main"] + pull_request: + branches: ["**"] + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Rust toolchain (nightly) + run: rustup toolchain install nightly --component llvm-tools-preview + + - name: Install cargo-llvm-cov + run: cargo install cargo-llvm-cov + + - name: Run coverage + run: cargo llvm-cov --report-html --lcov --output-path=coverage + + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: coverage/ \ No newline at end of file From a4f639f9a107692bf84bb6ff3d26290fe0eb1846 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 02:32:25 -0400 Subject: [PATCH 02/14] chore: change to runs-on --- .github/workflows/coverage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b6e33c47fa..86d3f1cec1 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -8,7 +8,10 @@ on: jobs: coverage: - runs-on: ubuntu-latest + runs-on: + - runs-on=${{ github.run_id }} + - runner=16cpu-linux-arm64 + - tag=coverage steps: - name: Checkout code uses: actions/checkout@v3 From b5869f6c74fe88ff331a9e5714819d06b272de4b Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 02:40:34 -0400 Subject: [PATCH 03/14] chore: fix flag --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 86d3f1cec1..d98388392f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: cargo llvm-cov --report-html --lcov --output-path=coverage + run: cargo llvm-cov --html --lcov --output-path=coverage - name: Upload coverage report uses: actions/upload-artifact@v3 From 44b00f0e1e02937c12582c36e4ee3cc9f5940415 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 02:47:12 -0400 Subject: [PATCH 04/14] chore: comment --- .github/workflows/coverage.yml | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d98388392f..9e75522038 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,10 +23,29 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: cargo llvm-cov --html --lcov --output-path=coverage + run: cargo llvm-cov --json --output-path=coverage - - name: Upload coverage report - uses: actions/upload-artifact@v3 + - name: Parse detailed coverage report + id: parse + run: | + # Parse file-level coverage data into a markdown table format + echo "| File | Coverage | Total Lines | Covered Lines |" > coverage_table.md + echo "|--------------------|----------|-------------|---------------|" >> coverage_table.md + jq -r '.files[] | "| \(.file) | \(.coverage.lines.percent)% | \(.coverage.lines.total) | \(.coverage.lines.covered) |"' coverage.json >> coverage_table.md + + # Read the markdown table as an output + table=$(cat coverage_table.md) + echo "table=$table" >> $GITHUB_ENV + + - name: Post detailed coverage results as PR comment + uses: actions/github-script@v6 with: - name: coverage-report - path: coverage/ \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const table = process.env.table; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `### Detailed Coverage Report\n\n${table}` + }); \ No newline at end of file From 1ea29d299c442467e3ae695da2161bf30a682c6d Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 02:48:52 -0400 Subject: [PATCH 05/14] chore: comment --- .github/workflows/coverage.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9e75522038..bdc5292129 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -25,17 +25,19 @@ jobs: - name: Run coverage run: cargo llvm-cov --json --output-path=coverage - - name: Parse detailed coverage report + - name: Parse detailed coverage report id: parse run: | - # Parse file-level coverage data into a markdown table format + # Initialize the markdown table header echo "| File | Coverage | Total Lines | Covered Lines |" > coverage_table.md echo "|--------------------|----------|-------------|---------------|" >> coverage_table.md + + # Parse each file's data and append it to the table jq -r '.files[] | "| \(.file) | \(.coverage.lines.percent)% | \(.coverage.lines.total) | \(.coverage.lines.covered) |"' coverage.json >> coverage_table.md - # Read the markdown table as an output - table=$(cat coverage_table.md) - echo "table=$table" >> $GITHUB_ENV + - name: Set markdown table as output + id: table_output + run: echo "table=$(< coverage_table.md)" >> $GITHUB_ENV - name: Post detailed coverage results as PR comment uses: actions/github-script@v6 @@ -47,5 +49,5 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `### Detailed Coverage Report\n\n${table}` + body: `### Detailed Coverage Report\n\n${table.replace(/\|/g, '\\|')}` }); \ No newline at end of file From fcd846e0e4bc3ea0dfddb593ef8f92e1261794e2 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 03:07:38 -0400 Subject: [PATCH 06/14] chore: update runner --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bdc5292129..1bca0209a1 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -10,7 +10,7 @@ jobs: coverage: runs-on: - runs-on=${{ github.run_id }} - - runner=16cpu-linux-arm64 + - runner=64cpu-linux-arm64 - tag=coverage steps: - name: Checkout code From f6c99700f7c3cbb36e1942b60da2acac7ee344c5 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 03:11:23 -0400 Subject: [PATCH 07/14] chore: set min stack --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1bca0209a1..aeb9674466 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: cargo llvm-cov --json --output-path=coverage + run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage - name: Parse detailed coverage report id: parse From a6384e1d344960efd928a1eeddbff3ac11d78034 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 13:40:40 -0400 Subject: [PATCH 08/14] fix: speed up coverage --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index aeb9674466..0eb0716d63 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage + run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --profile=fast --features parallel - name: Parse detailed coverage report id: parse From 2047d504de2cdb2f90dfeb66ac9804a8a3497c01 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 13:45:27 -0400 Subject: [PATCH 09/14] chore: add rust caching --- .github/workflows/coverage.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0eb0716d63..8b324fff6b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,13 +14,20 @@ jobs: - tag=coverage steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust toolchain (nightly) - run: rustup toolchain install nightly --component llvm-tools-preview + uses: dtolnay/rust-toolchain@nightly + + - name: Install llvm-tools-preview component + run: rustup component add llvm-tools-preview --toolchain nightly + + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - name: Install cargo-llvm-cov - run: cargo install cargo-llvm-cov + run: cargo install cargo-llvm-cov - name: Run coverage run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --profile=fast --features parallel From f820fcdfd9c817263eef97d9884c1e296a4f514f Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 13:49:22 -0400 Subject: [PATCH 10/14] fix: speed up coverage --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8b324fff6b..7437c83041 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,7 +30,7 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --profile=fast --features parallel + run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --profile=release --features parallel - name: Parse detailed coverage report id: parse From 9312c1098f8154397b77e603745c82dae0ee7548 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 13:56:36 -0400 Subject: [PATCH 11/14] fix: speed up coverage --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7437c83041..cdbb4f5444 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,7 +30,7 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --profile=release --features parallel + run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --jobs $(nproc)--profile=release --features parallel - name: Parse detailed coverage report id: parse From 21dfe113921d93efb7d902597542289f447387fb Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 14:01:47 -0400 Subject: [PATCH 12/14] fix: typo --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index cdbb4f5444..6de98a84ef 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,7 +30,7 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --jobs $(nproc)--profile=release --features parallel + run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --jobs $(nproc) --profile=release --features parallel - name: Parse detailed coverage report id: parse From 89d717e64d20c2f5fa0bda5f98bfd6bf9a526908 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 14:10:48 -0400 Subject: [PATCH 13/14] fix: speed up coverage --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6de98a84ef..7bf2210dc6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,7 +30,7 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: RUST_MIN_STACK=8388608 cargo llvm-cov --json --output-path=coverage --jobs $(nproc) --profile=release --features parallel + run: RUST_MIN_STACK=8388608 AXIOM_FAST_TEST=1 cargo llvm-cov --json --output-path=coverage --jobs $(nproc) --profile=fast --features parallel - name: Parse detailed coverage report id: parse From c61d07a01432452cb675d467d8ad6de6041f2a84 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 30 Oct 2024 14:20:17 -0400 Subject: [PATCH 14/14] fix: speed up coverage --- .github/workflows/coverage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7bf2210dc6..9bfdb6fba2 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,7 +30,10 @@ jobs: run: cargo install cargo-llvm-cov - name: Run coverage - run: RUST_MIN_STACK=8388608 AXIOM_FAST_TEST=1 cargo llvm-cov --json --output-path=coverage --jobs $(nproc) --profile=fast --features parallel + run: RUST_MIN_STACK=8388608 AXIOM_FAST_TEST=1 cargo llvm-cov --json --output-path=coverage --jobs $(nproc) --profile=fast --features parallel --ignore-filename-regex 'tests|examples' --no-report + + - name: Generate report + run: cargo llvm-cov --json --output-path coverage/ - name: Parse detailed coverage report id: parse