Skip to content

Implement keyword-based dynamic text replacement #1541

Implement keyword-based dynamic text replacement

Implement keyword-based dynamic text replacement #1541

name: .NET Analysis
on:
push:
branches: [ main ]
paths-ignore:
- "test/k6/**"
- ".github/**"
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
build-test-analyze:
name: Build, test & analyze
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: platform_notifications_admin
POSTGRES_PASSWORD: Password
POSTGRES_DB: notificationsdb
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v4
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: Setup PostgreSQL
run: |
chmod +x dbsetup.sh
./dbsetup.sh
- name: Set up Kafka
uses: ybyzek/[email protected]
with:
service: broker
- name: Sleep for 30 seconds to allow Kafka to start
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '30s'
- name: Build & Test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"Altinn_altinn-notifications" /o:"altinn" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.exclusions="src/Altinn.Notifications.Persistence/Migration/**/*"
dotnet build Altinn.Notifications.sln -v q
dotnet test Altinn.Notifications.sln \
-v q \
--collect:"XPlat Code Coverage" \
--results-directory TestResults/ \
--logger "trx;" \
--configuration release \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Complete sonar analysis
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: TestResults
path: '**/TestResults/*.trx'
- name: Process unit test result
if: always()
uses: NasAmin/[email protected]
with:
TRX_PATH: ${{ github.workspace }}/TestResults
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}