NEXT-38121 - Update readme #51
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and test | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
permissions: | |
pull-requests: write | |
jobs: | |
build_and_test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
env: | |
RUST_BACKTRACE: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install latest stable Rust version | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- uses: Swatinem/rust-cache@v2 | |
- name: Cargo build | |
run: cargo build --verbose | |
- name: Generate coverage data JSON report | |
run: cargo llvm-cov --all-features --no-fail-fast --json --output-path ./coverage.json | |
- name: Generate coverage data HTML report | |
if: github.event_name == 'pull_request' | |
run: cargo llvm-cov --all-features --no-fail-fast --html | |
- name: Upload JSON coverage data | |
id: coverage_upload_json | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-json-report | |
path: ./coverage.json | |
- name: Upload HTML coverage data | |
if: github.event_name == 'pull_request' | |
id: coverage_upload_html | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-html-report | |
path: target/llvm-cov/html | |
- name: Delete old coverage comments | |
if: github.event_name == 'pull_request' | |
uses: izhangzhihao/delete-comment@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
delete_user_name: github-actions[bot] | |
issue_number: ${{ github.event.number }} | |
- name: Download JSON coverage data from main branch | |
if: github.event_name == 'pull_request' | |
id: download-artifact | |
continue-on-error: true | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
workflow: build.yml | |
branch: main | |
path: main-coverage | |
name: coverage-json-report | |
if_no_artifact_found: fail | |
- name: Get main branch coverage data | |
if: ${{ github.event_name == 'pull_request' && steps.download-artifact.outcome == 'success' }} | |
id: get-main-coverage | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const script = require('./.github/scripts/main-coverage.js'); | |
script({core}); | |
- name: Comment coverage data | |
uses: actions/github-script@v7 | |
env: | |
MAIN_COVERAGE: ${{ steps.get-main-coverage.outputs.total_coverage }} | |
ARTIFACT_URL: "${{steps.coverage_upload_html.outputs.artifact-url}}" | |
with: | |
script: | | |
const script = require('./.github/scripts/comment-coverage.js'); | |
await script({github, context, core}); |