Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #407 from DFE-Digital/add-sonarcloud-scanning
Browse files Browse the repository at this point in the history
Add sonarcloud scanning to build and test github action
  • Loading branch information
cshnimble authored Nov 9, 2022
2 parents 66e6f92 + 097c69e commit 32dde0f
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
name: .NET

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
types: [ opened, synchronize, reopened]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones disabled for a better relevancy of SC analysis
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Install SonarCloud scanners
run: dotnet tool install --global dotnet-sonarscanner
- name: Install dotnet-coverage
run: dotnet tool install --global dotnet-coverage
- name: Restore dependencies
run: dotnet restore
- name: Setup node.js
Expand All @@ -23,7 +43,12 @@ jobs:
# This could be cached in the future to allow for quicker build times
- name: Build Frontend
run: make build-frontend
- name: Build
run: dotnet build -c Release --no-restore
- name: Test
run: dotnet test -c Release --no-build --verbosity normal
- name: Build, Test and Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"DFE-Digital_academy-transfers-api" /o:"dfe-digital" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build -c Release --no-restore
dotnet test -c Release --no-build --verbosity normal
dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

0 comments on commit 32dde0f

Please sign in to comment.