Skip to content

Commit

Permalink
Skip SonarQube scan for PR from fork and allow compare_db workflow fr…
Browse files Browse the repository at this point in the history
…om fork (#327)

* check if PR is from a fork and skip SonarQube scan if so -- fail job so it is clear that the scan was not run

* specify repository of source branch in PR to allow PR from forked repository

* change condition to run coverage report generation to only run if the step to check for a fork PR is skipped, meaning the tests should run

* fixed syntax error
  • Loading branch information
georgemccabe committed Sep 9, 2024
1 parent 61842c0 commit e9b80b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/compare_db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
path: headnew
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: check out baseold code
uses: actions/checkout@v4
with:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/sonarqube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:

steps:

- name: Check if PR is from a fork
id: check_fork
if: ${{ github.event.pull_request.head.repo.full_name != 'dtcenter/METdataio' }}
run: echo "SonarQube scan cannot be run from a fork"; exit 1
- uses: actions/checkout@v4
with:
# Disable shallow clones for better analysis
Expand Down Expand Up @@ -76,11 +80,11 @@ jobs:
- name: Output coverage report
run: coverage report -m
if: always()
if: ${{ always() && steps.check_fork.conclusion == 'skipped' }}

- name: Generate XML coverage report
run: coverage xml
if: always()
if: ${{ always() && steps.check_fork.conclusion == 'skipped' }}

- name: Get branch name
id: get_branch_name
Expand Down

0 comments on commit e9b80b8

Please sign in to comment.