diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 973111e..3e29c94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,42 @@ jobs: - name: Check code coverage if: matrix.os == 'ubuntu-latest' - run: npm run test:coverage + id: coverage + run: | + output=$(npm run test:coverage 2>&1) + echo "$output" + pct=$(echo "$output" | grep 'all files' | head -1 | awk -F'|' '{gsub(/[[:space:]]/, "", $2); print $2}') + echo "percentage=$pct" >> "$GITHUB_OUTPUT" + + - name: Determine badge color + if: matrix.os == 'ubuntu-latest' + id: color + run: | + pct="${{ steps.coverage.outputs.percentage }}" + int_pct=${pct%.*} + if [ "$int_pct" -ge 90 ]; then + echo "color=brightgreen" >> "$GITHUB_OUTPUT" + elif [ "$int_pct" -ge 80 ]; then + echo "color=green" >> "$GITHUB_OUTPUT" + elif [ "$int_pct" -ge 70 ]; then + echo "color=yellowgreen" >> "$GITHUB_OUTPUT" + elif [ "$int_pct" -ge 60 ]; then + echo "color=yellow" >> "$GITHUB_OUTPUT" + else + echo "color=red" >> "$GITHUB_OUTPUT" + fi + + - name: Update coverage badge + if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main' + continue-on-error: true + uses: schneegans/dynamic-badges-action@0e50b8bad39e7e1afd3e4e9c2b7dd145fad07501 # v1.8.0 + with: + auth: ${{ secrets.GIST_TOKEN }} + gistID: d01e4551b744b77e2927555e43a4b935 + filename: coverage.json + label: coverage + message: ${{ steps.coverage.outputs.percentage }}% + color: ${{ steps.color.outputs.color }} build: runs-on: ubuntu-latest diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index cceb196..df4be07 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -19,6 +19,7 @@ jobs: if: github.event.pull_request.merged == true permissions: actions: write + contents: write steps: - name: Harden runner uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 @@ -32,3 +33,13 @@ jobs: gh workflow run ci.yml --ref main --repo "${{ github.repository }}" gh workflow run security.yml --ref main --repo "${{ github.repository }}" gh workflow run scorecard.yml --ref main --repo "${{ github.repository }}" + + - name: Auto-update open PR branches + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr list --base main --state open --json number --jq '.[].number' \ + --repo "${{ github.repository }}" | while read -r pr; do + echo "Updating PR #$pr" + gh pr update-branch "$pr" --repo "${{ github.repository }}" || true + done diff --git a/README.md b/README.md index 2c068a9..bafaad6 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![CI](https://github.com/patchloom/patchloom-vscode/actions/workflows/ci.yml/badge.svg)](https://github.com/patchloom/patchloom-vscode/actions/workflows/ci.yml) [![Security](https://github.com/patchloom/patchloom-vscode/actions/workflows/security.yml/badge.svg)](https://github.com/patchloom/patchloom-vscode/actions/workflows/security.yml) +[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/SebTardif/d01e4551b744b77e2927555e43a4b935/raw/coverage.json)](https://github.com/patchloom/patchloom-vscode/actions/workflows/ci.yml) [![VS Code Marketplace](https://vsmarketplacebadges.dev/version/patchloom.patchloom.svg)](https://marketplace.visualstudio.com/items?itemName=patchloom.patchloom) [![Open VSX](https://img.shields.io/open-vsx/v/patchloom/patchloom)](https://open-vsx.org/extension/patchloom/patchloom) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/patchloom/patchloom-vscode/badge)](https://securityscorecards.dev/viewer/?uri=github.com/patchloom/patchloom-vscode) diff --git a/lychee.toml b/lychee.toml index fc2026c..3b3e3fd 100644 --- a/lychee.toml +++ b/lychee.toml @@ -16,4 +16,6 @@ exclude = [ "https://marketplace.visualstudio.com/items\\?itemName=patchloom\\.patchloom", "https://open-vsx.org/extension/patchloom/patchloom", "https://github.com/patchloom/patchloom-vscode/compare/patchloom-v", + # Badge SVG endpoints are unreliable for link checking (transient 500s) + "https://vsmarketplacebadges\\.dev/", ]