Skip to content
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

Run sonar scan in separate job #322

Merged
merged 10 commits into from
Jul 13, 2022
Merged
34 changes: 21 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,32 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-node${{ runner.node-version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
cache: "npm"
- run: npm ci
- run: npm run build
- run: npm test
# Upload coverage for sonarcube (only matching OS and one node version required)
- uses: actions/upload-artifact@v3
NSeydoux marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == '16.x' }}
with:
name: code-coverage-${{matrix.os}}-${{matrix.node-version}}
path: coverage/

# Sonar analysis needs the full history for features like automatic assignment of bugs. If the following step
# is not included the project will show a warning about incomplete information.
- run: git fetch --unshallow
if: ${{ matrix.node-version == '16.x' && matrix.os == 'ubuntu-latest' }}
# Run Sonar analysis on just the latest ubuntu/node runner.
sonar-scan:
needs: [unit-tests]
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v3
with:
# Sonar analysis needs the full history for features like automatic assignment of bugs. If the following step
# is not included the project will show a warning about incomplete information.
Comment on lines +39 to +40
Copy link
Contributor

Choose a reason for hiding this comment

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

I was suggesting a minor change to this comment as it no longer refers to a separate step, just the parameter. Perhaps instead of my previous suggestion, the simplest change would be from following step to following option.

fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: code-coverage-ubuntu-latest-16.x
path: coverage/
- uses: SonarSource/sonarcloud-github-action@v1.6
if: ${{ matrix.node-version == '16.x' && matrix.os == 'ubuntu-latest' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down