-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from DEFRA/sonar-config
Run Sonar via GitHub Actions
- Loading branch information
Showing
2 changed files
with
59 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,8 @@ concurrency: | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
jobs: | ||
install: | ||
name: Install | ||
build: | ||
name: Build | ||
runs-on: ${{ matrix.runner }} | ||
|
||
strategy: | ||
|
@@ -37,40 +37,6 @@ jobs: | |
key: npm-install-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | ||
path: node_modules | ||
|
||
- name: Setup Node.js | ||
if: steps.npm-install-cache.outputs.cache-hit != 'true' | ||
uses: actions/setup-node@v4 | ||
with: | ||
cache: 'npm' | ||
node-version-file: .nvmrc | ||
|
||
- name: Install dependencies | ||
if: steps.npm-install-cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
build: | ||
name: Build | ||
runs-on: ${{ matrix.runner }} | ||
needs: [install] | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
runner: | ||
- ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Restore dependencies | ||
uses: actions/cache/restore@v4 | ||
with: | ||
enableCrossOsArchive: true | ||
key: npm-install-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | ||
path: node_modules | ||
|
||
- name: Cache build | ||
uses: actions/cache@v4 | ||
with: | ||
|
@@ -83,13 +49,17 @@ jobs: | |
with: | ||
node-version-file: .nvmrc | ||
|
||
- name: Install dependencies | ||
if: steps.npm-install-cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: Run build | ||
run: npm run build | ||
|
||
lint: | ||
name: ${{ matrix.task.description }} (${{ matrix.runner }}) | ||
runs-on: ${{ matrix.runner }} | ||
needs: [install] | ||
needs: [build] | ||
|
||
env: | ||
# Authorise GitHub API requests for EditorConfig checker binary | ||
|
@@ -138,7 +108,7 @@ jobs: | |
tasks: | ||
name: ${{ matrix.task.description }} (${{ matrix.runner }}) | ||
runs-on: ${{ matrix.runner }} | ||
needs: [install, build] | ||
needs: [build] | ||
|
||
strategy: | ||
fail-fast: false | ||
|
@@ -149,7 +119,9 @@ jobs: | |
|
||
task: | ||
- description: Unit tests | ||
name: test-unit | ||
run: npm run test | ||
cache: coverage | ||
|
||
steps: | ||
- name: Checkout | ||
|
@@ -174,5 +146,37 @@ jobs: | |
with: | ||
node-version-file: .nvmrc | ||
|
||
- name: Cache task | ||
if: ${{ matrix.task.cache }} | ||
uses: actions/cache@v4 | ||
with: | ||
enableCrossOsArchive: true | ||
key: ${{ matrix.task.name }}-${{ runner.os }} | ||
path: ${{ matrix.task.cache }} | ||
|
||
- name: Run task | ||
run: ${{ matrix.task.run }} | ||
|
||
analysis: | ||
name: Analysis | ||
runs-on: ubuntu-latest | ||
needs: [build, tasks] | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Restore unit test coverage | ||
uses: actions/cache/restore@v4 | ||
with: | ||
enableCrossOsArchive: true | ||
key: test-unit-${{ runner.os }} | ||
path: coverage | ||
|
||
- name: SonarCloud Scan | ||
uses: SonarSource/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
sonar.projectKey=DEFRA_forms-manager | ||
sonar.projectName=forms-manager | ||
sonar.organization=defra | ||
|
||
sonar.links.homepage=https://github.com/DEFRA/forms-manager/blob/main/README.md | ||
sonar.links.ci=https://github.com/DEFRA/forms-manager/actions | ||
sonar.links.scm=https://github.com/DEFRA/forms-manager | ||
sonar.links.issue=https://github.com/DEFRA/forms-manager/issues | ||
|
||
sonar.javascript.lcov.reportPaths=coverage/lcov.info | ||
sonar.sourceEncoding=UTF-8 | ||
|
||
sonar.sources=src | ||
sonar.exclusions=**/*.test.* | ||
sonar.tests=src,test | ||
sonar.test.inclusions=**/*.test.* | ||
sonar.cpd.exclusions=**/*.test.* |