From 15a163079ae0180df17e3d13cde6fb612e215721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 19:39:26 +0200 Subject: [PATCH 01/10] Add basic validate YAML --- .github/workflows/validate.yaml | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/validate.yaml diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 00000000..60ed83e8 --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,53 @@ +on: + push: + branches: + - topic/workflows + +permissions: + contents: read + actions: read + checks: write + +jobs: + validate: + name: 'Validate' + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v2 + - name: 'Setup .NET SDK 9.x' + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '9.x' + - name: 'Setup Node.js 22.x' + uses: actions/setup-node@v3 + with: + node-version: '22.x' + - name: 'Setup Chrome' + uses: browser-actions/setup-chrome@v1 + id: 'setup-chrome' + - name: 'Set CHROME_BIN environment variable' + run: 'echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV' + - name: 'Restore .NET solution' + run: 'dotnet restore' + working-directory: './src' + - name: 'Build .NET solution' + run: 'dotnet build --no-restore -c Release' + working-directory: './src' + - name: 'Test .NET solution' + run: 'dotnet test --no-build --logger trx -c Release' + working-directory: './src' + - name: 'Install npm packages' + run: 'npm ci' + working-directory: './src/Turnierplan.Web/ClientApp/' + - name: 'Lint client application' + run: 'npm run lint:ci' + working-directory: './src/Turnierplan.Web/ClientApp/' + - name: 'Test client application' + run: 'npm run test:ci' + working-directory: './src/Turnierplan.Web/ClientApp/' + - name: 'Build client application' + run: 'npm run build:prod' + working-directory: './src/Turnierplan.Web/ClientApp/' + - name: 'Publish .NET solution' + run: 'dotnet publish --no-build -c Release /p:UseAppHost=false' + working-directory: './src' From 91190c31c307c36623bb0058be2df67c0709dd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 19:41:49 +0200 Subject: [PATCH 02/10] Fix project path --- .github/workflows/validate.yaml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 60ed83e8..dc828189 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -3,11 +3,6 @@ on: branches: - topic/workflows -permissions: - contents: read - actions: read - checks: write - jobs: validate: name: 'Validate' @@ -38,16 +33,16 @@ jobs: working-directory: './src' - name: 'Install npm packages' run: 'npm ci' - working-directory: './src/Turnierplan.Web/ClientApp/' + working-directory: './src/Turnierplan.App/Client/' - name: 'Lint client application' run: 'npm run lint:ci' - working-directory: './src/Turnierplan.Web/ClientApp/' + working-directory: './src/Turnierplan.App/Client/' - name: 'Test client application' run: 'npm run test:ci' - working-directory: './src/Turnierplan.Web/ClientApp/' + working-directory: './src/Turnierplan.App/Client/' - name: 'Build client application' run: 'npm run build:prod' - working-directory: './src/Turnierplan.Web/ClientApp/' + working-directory: './src/Turnierplan.App/Client/' - name: 'Publish .NET solution' run: 'dotnet publish --no-build -c Release /p:UseAppHost=false' working-directory: './src' From 703eb335d7ec380b29d4673e9fd23e767b0884c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 19:44:26 +0200 Subject: [PATCH 03/10] Fix steps order --- .github/workflows/validate.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index dc828189..dbd0b034 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -34,15 +34,15 @@ jobs: - name: 'Install npm packages' run: 'npm ci' working-directory: './src/Turnierplan.App/Client/' + - name: 'Build client application' + run: 'npm run build:prod' + working-directory: './src/Turnierplan.App/Client/' - name: 'Lint client application' run: 'npm run lint:ci' working-directory: './src/Turnierplan.App/Client/' - name: 'Test client application' run: 'npm run test:ci' working-directory: './src/Turnierplan.App/Client/' - - name: 'Build client application' - run: 'npm run build:prod' - working-directory: './src/Turnierplan.App/Client/' - name: 'Publish .NET solution' run: 'dotnet publish --no-build -c Release /p:UseAppHost=false' working-directory: './src' From 9135b12cd76c20fc6380eb8794dc4c5d918cf5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 19:54:10 +0200 Subject: [PATCH 04/10] SonarQube cloud --- .github/workflows/validate.yaml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index dbd0b034..1121864d 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -1,7 +1,9 @@ on: push: branches: - - topic/workflows + - topic/workflows # TODO: SWITCH TO MAIN!!! + pull_request: + types: [opened, synchronize, reopened] jobs: validate: @@ -9,6 +11,8 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: 'Setup .NET SDK 9.x' uses: actions/setup-dotnet@v3 with: @@ -22,14 +26,36 @@ jobs: id: 'setup-chrome' - name: 'Set CHROME_BIN environment variable' run: 'echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV' + - name: Install SonarQube Cloud scanner + shell: powershell + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + working-directory: './src' + - name: Start SonarQube Cloud analysis + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + working-directory: './src' - name: 'Restore .NET solution' run: 'dotnet restore' working-directory: './src' - name: 'Build .NET solution' run: 'dotnet build --no-restore -c Release' working-directory: './src' + - name: 'Install dotnet-coverage' + run: 'dotnet tool install --global dotnet-coverage' - name: 'Test .NET solution' - run: 'dotnet test --no-build --logger trx -c Release' + run: 'dotnet-coverage collect "dotnet test --no-build -c Release" -f xml -o "coverage.xml"' + working-directory: './src' + - name: End SonarQube Cloud analysis + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" working-directory: './src' - name: 'Install npm packages' run: 'npm ci' From c7409fc07ac5f814f005139b09c6b31862e87357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 19:56:11 +0200 Subject: [PATCH 05/10] Simplify --- .github/workflows/validate.yaml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 1121864d..e587243c 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -27,17 +27,11 @@ jobs: - name: 'Set CHROME_BIN environment variable' run: 'echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV' - name: Install SonarQube Cloud scanner - shell: powershell - run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - working-directory: './src' + run: 'dotnet tool install --global dotnet-sonarscanner' - name: Start SonarQube Cloud analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: powershell - run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"' working-directory: './src' - name: 'Restore .NET solution' run: 'dotnet restore' @@ -53,9 +47,7 @@ jobs: - name: End SonarQube Cloud analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: powershell - run: | - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + run: 'dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"' working-directory: './src' - name: 'Install npm packages' run: 'npm ci' From 25b42be108da01de0b98a8c669a48b9b3d10befa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 19:57:19 +0200 Subject: [PATCH 06/10] sonar coverage.xml --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index e587243c..5536019b 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -31,7 +31,7 @@ jobs: - name: Start SonarQube Cloud analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"' + run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml' working-directory: './src' - name: 'Restore .NET solution' run: 'dotnet restore' From 0243da8e7ffdc197ef4de52419dee1255062390f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 19:59:13 +0200 Subject: [PATCH 07/10] ADd exlucion and switch order --- .github/workflows/validate.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 5536019b..98d4c869 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -31,7 +31,7 @@ jobs: - name: Start SonarQube Cloud analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml' + run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" /d:sonar.exclusions="src/Turnierplan.Dal/Migrations/**/*"' working-directory: './src' - name: 'Restore .NET solution' run: 'dotnet restore' @@ -44,11 +44,6 @@ jobs: - name: 'Test .NET solution' run: 'dotnet-coverage collect "dotnet test --no-build -c Release" -f xml -o "coverage.xml"' working-directory: './src' - - name: End SonarQube Cloud analysis - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: 'dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"' - working-directory: './src' - name: 'Install npm packages' run: 'npm ci' working-directory: './src/Turnierplan.App/Client/' @@ -61,6 +56,11 @@ jobs: - name: 'Test client application' run: 'npm run test:ci' working-directory: './src/Turnierplan.App/Client/' + - name: End SonarQube Cloud analysis + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: 'dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"' + working-directory: './src' - name: 'Publish .NET solution' run: 'dotnet publish --no-build -c Release /p:UseAppHost=false' working-directory: './src' From cc8b20efcfa926fa7afe89b38ad880f21715fa9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 20:11:21 +0200 Subject: [PATCH 08/10] Fix path --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 98d4c869..3222186e 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -31,7 +31,7 @@ jobs: - name: Start SonarQube Cloud analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" /d:sonar.exclusions="src/Turnierplan.Dal/Migrations/**/*"' + run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" /d:sonar.exclusions="Turnierplan.Dal/Migrations/**/*"' working-directory: './src' - name: 'Restore .NET solution' run: 'dotnet restore' From 305eaedea1cd7cb93e7b943784af2125886b682a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 20:15:00 +0200 Subject: [PATCH 09/10] maybe like this? --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 3222186e..5bb8f217 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -31,7 +31,7 @@ jobs: - name: Start SonarQube Cloud analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" /d:sonar.exclusions="Turnierplan.Dal/Migrations/**/*"' + run: 'dotnet-sonarscanner begin /k:"turnierplan-NET_turnierplan.NET" /o:"turnierplan-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" /d:sonar.exclusions="Turnierplan.Dal/Migrations/*"' working-directory: './src' - name: 'Restore .NET solution' run: 'dotnet restore' From 80c39c148c4c397354dc25eb4ff58dc876960067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Thu, 22 May 2025 20:20:09 +0200 Subject: [PATCH 10/10] Main branch --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 5bb8f217..5d74a5d0 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -1,7 +1,7 @@ on: push: branches: - - topic/workflows # TODO: SWITCH TO MAIN!!! + - main pull_request: types: [opened, synchronize, reopened]