Skip to content

Fix refs used for code scanning results #1346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
- name: "Generate SARIF report from code scanning alerts"
uses: mongodb-labs/drivers-github-tools/code-scanning-export@v2
with:
ref: ${{ inputs.version }}
ref: refs/tags/${{ inputs.version }}
output-file: ${{ env.S3_ASSETS }}/code-scanning-alerts.json

- name: "Generate compliance report"
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ jobs:
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}

- name: "Get SHA hash of checked out ref"
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo CHECKED_OUT_SHA=$(git rev-parse HEAD) >> $GITHUB_ENV

- name: "Setup"
uses: "./.github/actions/setup"
with:
Expand All @@ -44,6 +49,15 @@ jobs:
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc) --report=psalm.sarif"

- name: "Upload SARIF report"
if: ${{ github.event_name != 'workflow_dispatch' }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to split this, as the upload-sarif action contains logic to fix the refs/pulls/<number>/merge ref, but doesn't do so when it was provided explicitly. Thus the only way to retain current logic for pull requests is to invoke the action without ref and sha arguments, and then explicitly pass them when the workflow was dispatched manually.

uses: "github/codeql-action/upload-sarif@v3"
with:
sarif_file: psalm.sarif

- name: "Upload SARIF report"
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: "github/codeql-action/upload-sarif@v3"
with:
sarif_file: psalm.sarif
ref: ${{ inputs.ref }}
sha: ${{ env.CHECKED_OUT_SHA }}