Skip to content
Merged
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
12 changes: 10 additions & 2 deletions .github/workflows/pr-sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ jobs:
timeout-minutes: 30
if: github.event.workflow_run.conclusion == 'success'
steps:
# Checkout the code from the PR
- name: Checkout PR code
uses: actions/checkout@v3
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0

# Download the artifacts from the PR build
- name: Download artifacts 📥
uses: actions/github-script@v6
with:
Expand All @@ -37,9 +39,10 @@ jobs:
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/rsc-pr-build-artifacts.zip`, Buffer.from(download.data));

- name: Unzip code coverage 📁
- name: Unzip artifacts 📁
run: unzip rsc-pr-build-artifacts.zip

# Save the PR number, branch, and base branch to the environment
- name: Setup workflow variables 📝
run: |
# Load the PR number from the file
Expand All @@ -54,6 +57,8 @@ jobs:
echo "PR_BRANCH=${pr_branch}" >> $GITHUB_ENV
echo "PR_BASE=${pr_base}" >> $GITHUB_ENV

# Checkout the base branch
# SonarCloud requires the base branch to be checked out to properly compare the PR for code coverage details
- name: Checkout base branch 🌳
run: |
git remote add upstream ${{ github.event.repository.clone_url }}
Expand All @@ -62,6 +67,9 @@ jobs:
git checkout ${{ github.event.workflow_run.head_branch }}
git clean -ffdx && git reset --hard HEAD

# Download the artifacts from the PR build
# Have to do this again since checking out the base branch will remove the artifacts
# Need the coverage report for the sonar scan step
- name: Re-download artifacts 📥
uses: actions/github-script@v6
with:
Expand All @@ -83,7 +91,7 @@ jobs:
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/rsc-pr-build-artifacts.zip`, Buffer.from(download.data));

- name: Re-unzip code coverage 📁
- name: Re-unzip artifacts 📁
run: unzip rsc-pr-build-artifacts.zip

- name: SonarCloud Scan 🔍
Expand Down