Skip to content

Commit

Permalink
updated workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
acn-sbuad committed Feb 28, 2024
1 parent 7f6b9cb commit e20d1e0
Showing 1 changed file with 19 additions and 42 deletions.
61 changes: 19 additions & 42 deletions .github/workflows/build-and-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ name: Code test and analysis
on:
push:
branches: [ main ]
paths-ignore:
- "test/k6/**"
- ".github/**"
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
build-and-test:
build-test-analyze:
name: Build and Test
if: ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) || github.event_name == 'push') && github.repository_owner == 'Altinn' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
Expand All @@ -18,60 +21,34 @@ jobs:
with:
dotnet-version: |
8.0.x
- name: Build & Test
run: |
dotnet build Altinn.Profile.sln -v m
dotnet test Altinn.Profile.sln -v m
analyze:
if: ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) || github.event_name == 'push') && github.repository_owner == 'Altinn' && github.actor != 'dependabot[bot]'
name: Analyze
runs-on: windows-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Set up JDK 17
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
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: 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'
shell: powershell
- name: Install SonarCloud scanners
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Analyze
dotnet tool install --global dotnet-sonarscanner
- name: Build & Test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Altinn_altinn-profile" /o:"altinn" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vstest.reportsPaths="**/*.trx" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.coverage.exclusions="src/**/Program.cs"
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"Altinn_altinn-profile" /o:"altinn" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vstest.reportsPaths="**/*.trx" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.coverage.exclusions="src/**/Program.cs"
dotnet build Altinn.Profile.sln -v q
dotnet build Altinn.Profile.sln
dotnet test Altinn.Profile.sln `
--no-build `
--results-directory TestResults/ `
--collect:"XPlat Code Coverage" `
dotnet test Altinn.Profile.sln \
-v q \
--results-directory TestResults/ \
--collect:"XPlat Code Coverage" \
--configuration release \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Complete sonar analysis
if: always()
Expand Down

0 comments on commit e20d1e0

Please sign in to comment.