Skip to content

Commit

Permalink
Added basic sonar check (#135)
Browse files Browse the repository at this point in the history
* Added basic sonar check

* Build and test enabled

* Removed manual trigger on deploy

* Removed push builds

* Fixed branch name

---------

Co-authored-by: Tom Whittington <[email protected]>
  • Loading branch information
ThomasWhittington and Tom Whittington authored Aug 16, 2024
1 parent 6ac4075 commit 3d7f934
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 20 deletions.
72 changes: 56 additions & 16 deletions .github/workflows/code-pr-check.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Code PR Check

on:
push:
branches: ["main", "Development"]
paths:
- "src/**"
- "tests/**"
pull_request:
branches: ["main", "Development"]
paths:
Expand All @@ -30,16 +25,61 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

dotnet-version: ${{ env.DOTNET_VERSION }}
cache: false

- name: Install dotnet coverage
run: dotnet tool install --global dotnet-coverage --version 17.9.3

- 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: Install latest JDK
uses: actions/setup-java@v4
with:
distribution: "microsoft"
java-version: "17"

# - name: Start SonarCloud scanner
# run: |
# dotnet-sonarscanner begin \
# /k:"DFE-Digital_sts-content-support" \
# /o:"dfe-digital" \
# /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
# /d:sonar.host.url="https://sonarcloud.io" \
# /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml \
# /d:sonar.coverage.exclusions=**/Program.cs,**/wwwroot/** \
# /d:sonar.issue.ignore.multicriteria=e1 \
# /d:sonar.issue.ignore.multicriteria.e1.ruleKey=csharpsquid:S6602 \
# /d:sonar.issue.ignore.multicriteria.e1.resourceKey=src/**/*.cs

- name: Build web app
uses: ./.github/actions/build-dotnet-app
with:
dotnet_version: ${{ env.DOTNET_VERSION }}
solution_filename: sts-contentsupport.sln

- name: Run unit tests
uses: ./.github/actions/run-unit-tests
with:
solution_filename: sts-contentsupport.sln

# - name: Merge test results
# run: dotnet-coverage merge -f xml -o "coverage.xml" -s "coverage.settings.xml" -r coverage.cobertura.xml
#
# - name: End SonarCloud Scanner
# run: dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
#
# - name: Archive code coverage results
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-report
# path: coverage.xml
#
8 changes: 4 additions & 4 deletions .github/workflows/matrix-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Multi stage build & deploy
on:
workflow_dispatch:
push:
branches: ["main", "development"]
branches: [ "main", "Development" ]
paths:
- "src/**"
- ".github/workflows/matrix-deploy.yml"
Expand Down Expand Up @@ -37,20 +37,20 @@ jobs:
checked-out-sha: ${{ needs.set-env.outputs.checked-out-sha }}

create-and-tag-release:
needs: [set-env, create-and-publish-image]
needs: [ set-env, create-and-publish-image ]
name: Create & Tag Release
uses: ./.github/workflows/create-tag-release.yml
secrets: inherit


deploy-to-dev:
needs: [set-env, create-and-publish-image]
needs: [ set-env, create-and-publish-image ]
name: Deployment to Dev & Test
strategy:
max-parallel: 1
fail-fast: true
matrix:
target: [Dev]
target: [ Dev ]
uses: ./.github/workflows/deploy-image.yml
with:
environment: ${{ matrix.target }}
Expand Down

0 comments on commit 3d7f934

Please sign in to comment.