fgrosse / go-coverage-report

A CLI tool and GitHub Action to post Go code coverage reports as comment to your pull requests.
BSD 3-Clause "New" or "Revised" License
59 stars 11 forks source link

Allow specifying TARGET Run ID #26

Open peter-crist opened 4 months ago

peter-crist commented 4 months ago

Current implementation will not behave as expected in a mono-repo with multiple Go projects. It would be beneficial to allow the user to optionally specify the LAST_SUCCESSFUL_RUN_ID or default to the existing behavior below:

start_group "Download code coverage results from target branch"
LAST_SUCCESSFUL_RUN_ID=$(gh run list --status=success --branch="$TARGET_BRANCH" --workflow="$GITHUB_WORKFLOW" --event=push --json=databaseId --limit=1 -q '.[] | .databaseId')
if [ -z "$LAST_SUCCESSFUL_RUN_ID" ]; then
  echo "::error::No successful run found on the target branch"
  exit 1
fi

For example, my use case would be something like:

gh run list --status=success --branch="main" --workflow="Go" --json=displayTitle,databaseId | jq -r '.[] | select(.displayTitle | contains("go/apps/app1")) | .databaseId' | head -n 1
peter-crist commented 4 months ago

I can create a PR from a fork for this if you'd like.

fgrosse commented 4 months ago

Yes that would be great. I currently only have very limited time to maintain projects on GitHub. :)