bump(deps-dev): bump the dev-dependencies group across 1 directory with 5 updates #534
Workflow file for this run
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: Tests & Coverage | |
| on: | |
| pull_request: | |
| branches: [main] | |
| # Restrict the default GITHUB_TOKEN to read-only; jobs escalate only what they need | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| if: github.actor != 'dotenv-diff-release-bot' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| # Required to post the sticky coverage comment on the PR | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 | |
| with: | |
| version: 11.24.0 | |
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v 7.0.0 | |
| with: | |
| node-version: 24 | |
| cache: 'pnpm' | |
| - run: pnpm install --frozen-lockfile | |
| - name: Setup Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| cache-dependency-path: .github/diff-cover-requirements.txt | |
| - name: Install diff-cover | |
| # Hash-pinned install so Scorecard's Pinned-Dependencies check passes. | |
| run: pip install --require-hashes -r .github/diff-cover-requirements.txt | |
| - name: Run coverage | |
| run: pnpm --filter dotenv-diff run coverage | |
| - name: Locate and normalize coverage files | |
| id: coverage_files | |
| run: | | |
| LCOV_FILE="coverage/lcov.info" | |
| SUMMARY_FILE="coverage/coverage-summary.json" | |
| if [ -f "packages/cli/coverage/lcov.info" ]; then | |
| LCOV_FILE="packages/cli/coverage/lcov.info" | |
| fi | |
| if [ -f "packages/cli/coverage/coverage-summary.json" ]; then | |
| SUMMARY_FILE="packages/cli/coverage/coverage-summary.json" | |
| fi | |
| if [ ! -f "$LCOV_FILE" ]; then | |
| echo "Missing lcov file at $LCOV_FILE" | |
| exit 1 | |
| fi | |
| if [ ! -f "$SUMMARY_FILE" ]; then | |
| echo "Missing coverage summary at $SUMMARY_FILE" | |
| exit 1 | |
| fi | |
| # Normalize source-file paths for monolith layout so diff-cover can | |
| # map coverage entries to changed files under packages/cli. | |
| sed -i -E 's|^SF:src/|SF:packages/cli/src/|; s|^SF:src\\|SF:packages/cli/src/|; s|^SF:packages\\cli\\src\\|SF:packages/cli/src/|' "$LCOV_FILE" | |
| echo "lcov_file=$LCOV_FILE" >> $GITHUB_OUTPUT | |
| echo "summary_file=$SUMMARY_FILE" >> $GITHUB_OUTPUT | |
| - name: Run diff-cover analysis | |
| id: diff_cover | |
| run: | | |
| echo "## π Unit Test Coverage" > comment.md | |
| echo "" >> comment.md | |
| COVERAGE_THRESHOLD=80 | |
| all_passed=true | |
| overall_coverage="N/A" | |
| if [ -f "${{ steps.coverage_files.outputs.summary_file }}" ]; then | |
| overall_coverage=$(jq -r '.total.lines.pct' "${{ steps.coverage_files.outputs.summary_file }}") | |
| fi | |
| diff-cover "${{ steps.coverage_files.outputs.lcov_file }}" \ | |
| --compare-branch=origin/${{ github.event.pull_request.base.ref }} \ | |
| --diff-range-notation=... \ | |
| --json-report diff-coverage.json \ | |
| --fail-under=0 || true | |
| echo "**Overall coverage**: ${overall_coverage}%" >> comment.md | |
| echo "" >> comment.md | |
| if [ -f "diff-coverage.json" ]; then | |
| total_lines=$(jq -r '.total_num_lines' diff-coverage.json) | |
| if [ "$total_lines" != "0" ] && [ "$total_lines" != "null" ]; then | |
| percent=$(jq -r '.total_percent_covered' diff-coverage.json) | |
| violations=$(jq -r '.total_num_violations' diff-coverage.json) | |
| covered=$((total_lines - violations)) | |
| if [ "$percent" -lt "$COVERAGE_THRESHOLD" ]; then | |
| all_passed=false | |
| fi | |
| if [ "$percent" = "100" ]; then | |
| emoji="β " | |
| status="PASS" | |
| elif [ "$percent" -ge "$COVERAGE_THRESHOLD" ]; then | |
| emoji="β οΈ" | |
| status="PASS" | |
| else | |
| emoji="β" | |
| status="FAIL" | |
| fi | |
| echo "**Diff coverage**: $emoji ${percent}% (${covered}/${total_lines} lines) - $status" >> comment.md | |
| echo "" >> comment.md | |
| if [ "$violations" != "0" ]; then | |
| echo "<details>" >> comment.md | |
| echo "<summary>π Uncovered lines in diff</summary>" >> comment.md | |
| echo "" >> comment.md | |
| echo '```' >> comment.md | |
| jq -r '.src_stats | to_entries[] | .key as $file | .value.violation_lines[] | "\($file):\(.)"' diff-coverage.json >> comment.md | |
| echo '```' >> comment.md | |
| echo "" >> comment.md | |
| echo "</details>" >> comment.md | |
| fi | |
| else | |
| echo "β¨ No new testable lines in this PR" >> comment.md | |
| fi | |
| fi | |
| echo "---" >> comment.md | |
| echo "" >> comment.md | |
| if [ "$all_passed" = true ]; then | |
| echo "β **Coverage threshold met** (β₯${COVERAGE_THRESHOLD}%)" >> comment.md | |
| else | |
| echo "β **Coverage threshold not met** (required: β₯${COVERAGE_THRESHOLD}%)" >> comment.md | |
| fi | |
| echo "all_passed=$all_passed" >> $GITHUB_OUTPUT | |
| - name: Comment PR with coverage | |
| if: github.event.pull_request.head.repo.fork == false | |
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | |
| with: | |
| path: comment.md | |
| - name: Fail if coverage is below threshold | |
| if: steps.diff_cover.outputs.all_passed == 'false' | |
| run: | | |
| echo "β Coverage check failed: Coverage below 80%" | |
| exit 1 |