build(deps): bump actions/stale from 10.2.0 to 10.3.0 #116
This file contains hidden or 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: Coverage | |
| on: | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: coverage-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| coverage: | |
| name: Coverage | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 | |
| with: | |
| components: llvm-tools-preview | |
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 | |
| - uses: taiki-e/install-action@2d15d02e710b40b6332201aba6af30d595b5cd96 # cargo-llvm-cov | |
| - name: Setup Node.js | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| with: | |
| node-version: 22 | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Install JS dependencies | |
| run: corepack pnpm install --ignore-scripts --no-frozen-lockfile | |
| - name: Install wasm-pack | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| install_script='https://rustwasm.github.io/wasm-pack/installer/init.sh' | |
| for attempt in 1 2 3; do | |
| if curl "$install_script" -sSf | sh; then | |
| exit 0 | |
| fi | |
| echo "wasm-pack installer attempt $attempt failed; retrying..." >&2 | |
| sleep 5 | |
| done | |
| cargo install wasm-pack --locked --version 0.13.1 | |
| # Rust coverage (lcov) | |
| - name: Rust coverage | |
| run: | | |
| mkdir -p coverage | |
| cargo llvm-cov --workspace --lcov --output-path coverage/rust.lcov | |
| # Build NAPI packages for JS tests | |
| - name: Build NAPI packages | |
| run: | | |
| corepack pnpm --filter @srcmap/codec build | |
| corepack pnpm --filter @srcmap/sourcemap build | |
| # Build WASM packages for JS tests | |
| - name: Build WASM packages | |
| run: | | |
| corepack pnpm --filter @srcmap/sourcemap-wasm build | |
| corepack pnpm --filter @srcmap/generator-wasm build | |
| corepack pnpm --filter @srcmap/remapping-wasm build | |
| # JS coverage (lcov) | |
| - name: JS coverage | |
| run: corepack pnpm run coverage:js | |
| # Compute merged coverage percentage from all lcov files | |
| - name: Compute coverage | |
| run: | | |
| COVERAGE=$(awk -F: ' | |
| /^LF:/ { total += $2 } | |
| /^LH:/ { hit += $2 } | |
| END { if (total > 0) printf "%.1f", (hit/total)*100; else print "0" } | |
| ' coverage/rust.lcov coverage/js-lcov.info) | |
| echo "COVERAGE=$COVERAGE" >> "$GITHUB_ENV" | |
| echo "Total coverage: $COVERAGE%" | |
| RUST_COV=$(awk -F: ' | |
| /^LF:/ { total += $2 } | |
| /^LH:/ { hit += $2 } | |
| END { if (total > 0) printf "%.1f", (hit/total)*100; else print "0" } | |
| ' coverage/rust.lcov) | |
| echo "RUST_COVERAGE=$RUST_COV" >> "$GITHUB_ENV" | |
| echo "Rust coverage: $RUST_COV%" | |
| # Choose badge color based on coverage percentage | |
| - name: Compute badge color | |
| run: | | |
| color_for() { | |
| local cov=$1 | |
| local int=${cov%.*} | |
| if [ "$int" -ge 90 ]; then echo "brightgreen" | |
| elif [ "$int" -ge 80 ]; then echo "green" | |
| elif [ "$int" -ge 70 ]; then echo "yellowgreen" | |
| elif [ "$int" -ge 60 ]; then echo "yellow" | |
| elif [ "$int" -ge 50 ]; then echo "orange" | |
| else echo "red" | |
| fi | |
| } | |
| echo "BADGE_COLOR=$(color_for "$COVERAGE")" >> "$GITHUB_ENV" | |
| echo "RUST_BADGE_COLOR=$(color_for "$RUST_COVERAGE")" >> "$GITHUB_ENV" | |
| # Update badges branch | |
| - name: Update coverage badges | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| if ! git ls-remote --heads origin badges | grep -q badges; then | |
| git checkout --orphan badges | |
| git rm -rf . 2>/dev/null || true | |
| echo "{}" > coverage.json | |
| echo "{}" > rust-coverage.json | |
| git add coverage.json rust-coverage.json | |
| git commit -m "chore: init badges branch" | |
| git push origin badges | |
| git checkout main | |
| fi | |
| git fetch origin badges | |
| git worktree add /tmp/srcmap-badges --detach origin/badges | |
| cd /tmp/srcmap-badges | |
| git checkout -B badges origin/badges | |
| echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${COVERAGE}%\",\"color\":\"${BADGE_COLOR}\"}" > coverage.json | |
| echo "{\"schemaVersion\":1,\"label\":\"rust coverage\",\"message\":\"${RUST_COVERAGE}%\",\"color\":\"${RUST_BADGE_COLOR}\"}" > rust-coverage.json | |
| git add coverage.json rust-coverage.json | |
| git diff --cached --quiet || git commit -m "chore: update coverage badges to ${COVERAGE}%" | |
| git push origin badges | |
| cd "$GITHUB_WORKSPACE" | |
| git worktree remove /tmp/srcmap-badges |