Skip to content

Improve performance of academies in trust ofsted page #87

Improve performance of academies in trust ofsted page

Improve performance of academies in trust ofsted page #87

name: Test .NET code and scan all code with SonarScanner
on:
push:
branches: [ main ]
paths:
- '**'
- '!.gitignore'
- '!**.DotSettings'
- '!**.md'
- '!.config/**'
- '!.github/**'
- '!terraform/**'
pull_request:
branches: [ main, '**-feature' ]
types: [ opened, synchronize, reopened]
paths:
- '**'
- '!.gitignore'
- '!**.DotSettings'
- '!**.md'
- '!.config/**'
- '!.github/**'
- '!terraform/**'
env:
DOTNET_VERSION: '8.x'
JAVA_VERSION: '17'
LAST_COMMIT_SHA: default
jobs:
build:
name: Build .NET
runs-on: ubuntu-latest
environment: development
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0 # Shallow clones disabled for a better relevancy of SC analysis
- name: Set SHA environment variable
run: |
echo "LAST_COMMIT_SHA=${GITHUB_SHA:(-7)}" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'microsoft'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-sonarscanner --version 8.0.1
- name: Install dotnet-coverage
run: dotnet tool install --global dotnet-coverage
- name: Install dotnet-stryker (mutation testing tool)
run: dotnet tool restore
- name: Build and Analyse solution
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"DFE-Digital_find-information-about-academies-and-trusts" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet restore DfE.FindInformationAcademiesTrusts
dotnet build DfE.FindInformationAcademiesTrusts -c Release
dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
dotnet stryker -r "cleartext" -r "html" --threshold-high 90 --threshold-low 81 --break-at 80