Update Terraform github.com/DFE-Digital/terraform-azurerm-key-vault-t… #232
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
name: .NET Build and Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: [ main ] | |
types: [ opened, synchronize, reopened ] | |
env: | |
DOTNET_VERSION: '6.0.403' | |
EF_VERSION: '6.0.5' | |
JAVA_VERSION: '17' | |
CONNECTION_STRING: 'Server=localhost,1433;Database=sip;TrustServerCertificate=True;User Id=sa;Password=StrongPassword905' | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: read | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
fetch-depth: 0 # Shallow clones disabled for a better relevancy of SC analysis | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup services | |
run: | | |
cp .env.database.example .env.database | |
cp .env.example .env.development | |
docker compose -f "docker-compose.yml" up -d --build db | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Setup JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'microsoft' | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
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 EF for tests | |
run: dotnet tool install --global dotnet-ef --version ${{ env.EF_VERSION }} | |
- name: Install dotnet reportgenerator | |
run: dotnet tool install --global dotnet-reportgenerator-globaltool | |
- name: Add nuget package source | |
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DFE-Digital/index.json" | |
- name: Restore tools for tests | |
run: dotnet tool restore | |
- name: Restore dependencies | |
run: dotnet restore TramsDataApi.sln | |
- name: Build, Test and Analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
ConnectionStrings__DefaultConnection: ${{ env.CONNECTION_STRING }} | |
run: | | |
dotnet-sonarscanner begin /k:"DFE-Digital_academies-api" /o:"dfe-digital" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths=CoverageReport/SonarQube.xml | |
dotnet build --no-restore | |
dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" | |
reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:./CoverageReport -reporttypes:SonarQube | |
dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | |
- name: Stop containers | |
if: always() | |
run: docker-compose -f "docker-compose.yml" down |