From 1909efe772a286dc384440377ec2b8d017faa473 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 3 Aug 2026 12:38:01 +0000 Subject: [PATCH 1/2] fix(pana-score): never fall back to the shared "pana" status context Package-name resolution ran partway through the score step, guarded by set -e, so a crash before that point (or the whole step being skipped after an earlier failure) left package-name unset. The status step then fell back to the bare "pana" context, which every such failure collided on again. Resolve the name first thing in the score step, shielded from set -e, with an "unknown" last resort. The status step now also resolves it independently as a fallback, in case the score step never ran at all. --- .github/actions/pana-score/README.md | 5 ++-- .github/actions/pana-score/action.yaml | 32 ++++++++++++++++++++------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/actions/pana-score/README.md b/.github/actions/pana-score/README.md index 624797a..b6ca4af 100644 --- a/.github/actions/pana-score/README.md +++ b/.github/actions/pana-score/README.md @@ -34,8 +34,9 @@ publishing its status and summary. - `score`: e.g. `98/100`. - `state`: one of `success`, `failure`, `error`. -- `package-name`: resolved from the package's `pubspec.yaml` (or its directory - name), used to namespace the commit status context. +- `package-name`: resolved from the package's `pubspec.yaml` (falling back to + its directory name, then `unknown`), used to namespace the commit status + context. Always set, even if the score step itself fails. ## Required workflow permissions diff --git a/.github/actions/pana-score/action.yaml b/.github/actions/pana-score/action.yaml index 323e524..b978ecd 100644 --- a/.github/actions/pana-score/action.yaml +++ b/.github/actions/pana-score/action.yaml @@ -44,12 +44,20 @@ runs: PACKAGE_PATH: ${{ inputs.path }} run: | set -euo pipefail # so tee doesn't mask a pana that fell over - pana --json "$PACKAGE_PATH" | tee "$RUNNER_TEMP/pana.json" || true - package_name="$(awk -F': *' '/^name:/{print $2; exit}' "$PACKAGE_PATH/pubspec.yaml" 2>/dev/null | tr -d "\"'")" + # Resolved and reported first, and shielded from failing the step, so + # a later crash still leaves this package identifiable and out of the + # shared/generic status context that collides across packages. + package_name="$(awk -F': *' '/^name:/{print $2; exit}' "$PACKAGE_PATH/pubspec.yaml" 2>/dev/null | tr -d "\"'")" || true + if [ -z "$package_name" ]; then + package_name="$(basename "$(cd "$PACKAGE_PATH" && pwd)" 2>/dev/null)" || true + fi if [ -z "$package_name" ]; then - package_name="$(basename "$(cd "$PACKAGE_PATH" && pwd)")" + package_name="unknown" fi + echo "package-name=$package_name" >> "$GITHUB_OUTPUT" + + pana --json "$PACKAGE_PATH" | tee "$RUNNER_TEMP/pana.json" || true granted="$(jq -r '.scores.grantedPoints // empty' "$RUNNER_TEMP/pana.json" 2>/dev/null || true)" max="$(jq -r '.scores.maxPoints // empty' "$RUNNER_TEMP/pana.json" 2>/dev/null || true)" @@ -74,7 +82,6 @@ runs: echo "score=$score" >> "$GITHUB_OUTPUT" echo "state=$state" >> "$GITHUB_OUTPUT" echo "valid_score=$valid_score" >> "$GITHUB_OUTPUT" - echo "package-name=$package_name" >> "$GITHUB_OUTPUT" { echo "## pana score for $package_name: $score" @@ -108,12 +115,23 @@ runs: STATE: ${{ steps.score.outputs.state || 'error' }} SCORE: ${{ steps.score.outputs.score || 'pana produced no score' }} PACKAGE_NAME: ${{ steps.score.outputs.package-name }} + PACKAGE_PATH: ${{ inputs.path }} TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | - context="pana" - if [ -n "$PACKAGE_NAME" ]; then - context="pana ($PACKAGE_NAME)" + # Falls back to resolving the name itself (score step may have been + # skipped entirely, e.g. if an earlier step failed), so this never + # degenerates into the shared "pana" context that collides across packages. + package_name="$PACKAGE_NAME" + if [ -z "$package_name" ]; then + package_name="$(awk -F': *' '/^name:/{print $2; exit}' "$PACKAGE_PATH/pubspec.yaml" 2>/dev/null | tr -d "\"'")" || true + fi + if [ -z "$package_name" ]; then + package_name="$(basename "$(cd "$PACKAGE_PATH" && pwd)" 2>/dev/null)" || true + fi + if [ -z "$package_name" ]; then + package_name="unknown" fi + context="pana ($package_name)" gh api "repos/$GITHUB_REPOSITORY/statuses/$SHA" \ --silent \ From e2ade55be094c79cd32885159e63ac2c4a834adc Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 3 Aug 2026 13:23:00 +0000 Subject: [PATCH 2/2] style(pana-score): trim comments down to one-liners --- .github/actions/pana-score/action.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/actions/pana-score/action.yaml b/.github/actions/pana-score/action.yaml index b978ecd..8138be5 100644 --- a/.github/actions/pana-score/action.yaml +++ b/.github/actions/pana-score/action.yaml @@ -45,9 +45,7 @@ runs: run: | set -euo pipefail # so tee doesn't mask a pana that fell over - # Resolved and reported first, and shielded from failing the step, so - # a later crash still leaves this package identifiable and out of the - # shared/generic status context that collides across packages. + # resolved first and shielded from set -e so a later crash still reports a name package_name="$(awk -F': *' '/^name:/{print $2; exit}' "$PACKAGE_PATH/pubspec.yaml" 2>/dev/null | tr -d "\"'")" || true if [ -z "$package_name" ]; then package_name="$(basename "$(cd "$PACKAGE_PATH" && pwd)" 2>/dev/null)" || true @@ -118,9 +116,7 @@ runs: PACKAGE_PATH: ${{ inputs.path }} TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | - # Falls back to resolving the name itself (score step may have been - # skipped entirely, e.g. if an earlier step failed), so this never - # degenerates into the shared "pana" context that collides across packages. + # re-resolved in case the score step was skipped entirely package_name="$PACKAGE_NAME" if [ -z "$package_name" ]; then package_name="$(awk -F': *' '/^name:/{print $2; exit}' "$PACKAGE_PATH/pubspec.yaml" 2>/dev/null | tr -d "\"'")" || true