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
29 changes: 20 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,35 @@ 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') }}
- run: npm ci
- run: npm run build
- run: npm test
# Upload coverage for sonarcube
- uses: actions/upload-artifact@v3
NSeydoux marked this conversation as resolved.
Show resolved Hide resolved
with:
name: code-coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps:

Suggested change
name: code-coverage
name: code-coverage-${matrix.os}-${matrix.node-version}

path: coverage/

sonar-scan:
needs: [unit-tests]
runs-on: ${{ matrix.os }}
if: ${{ github.actor != 'dependabot[bot]' }}
strategy:
matrix:
# Available OS's: https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
os: [ubuntu-latest]
node-version: [16.x]
NSeydoux marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: code-coverage
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
NSeydoux marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ matrix.node-version == '16.x' && matrix.os == 'ubuntu-latest' }}
# Run Sonar analysis on just the latest ubuntu/node runner.
- 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