-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
735ec7e
commit c67603a
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Validate PR | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'src/**' | ||
- 'tests/**' | ||
- '*.sln' | ||
- 'Dockerfile' | ||
|
||
env: | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
PR_SOURCE_BRANCH: ${{ github.head_ref }} | ||
PR_TARGET_BRANCH: ${{ github.base_ref }} | ||
GITHUB_PR_NUMBER: ${{github.event.pull_request.number}} | ||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8' | ||
- name: Install dotnet-sonarscanner | ||
run: | | ||
dotnet tool install --global dotnet-sonarscanner | ||
- name: Check if the project is well formatted | ||
run: | | ||
./scripts/start-check-formatting.sh | ||
- name: Build the project, run all tests, and publish the test results | ||
run: | | ||
./scripts/start-sonarcloud.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
# You should start the scanner prior building your project and running your tests | ||
if [ -n "${PR_SOURCE_BRANCH:-}" ]; then | ||
dotnet sonarscanner begin \ | ||
/d:sonar.login="$SONAR_TOKEN" \ | ||
/k:"juntossomosmais_AspNetCore.RestFramework" \ | ||
/o:"juntossomosmais" \ | ||
/d:sonar.host.url="https://sonarcloud.io" \ | ||
/d:sonar.cs.opencover.reportsPaths="**/*/coverage.opencover.xml" \ | ||
/d:sonar.cs.vstest.reportsPaths="**/*/*.trx" \ | ||
/d:sonar.pullrequest.base="$PR_TARGET_BRANCH" \ | ||
/d:sonar.pullrequest.branch="$PR_SOURCE_BRANCH" \ | ||
/d:sonar.pullrequest.key="$GITHUB_PR_NUMBER" | ||
else | ||
dotnet sonarscanner begin \ | ||
/d:sonar.login="$SONAR_TOKEN" \ | ||
/v:"$PROJECT_VERSION" \ | ||
/k:"juntossomosmais_AspNetCore.RestFramework" \ | ||
/o:"juntossomosmais" \ | ||
/d:sonar.host.url="https://sonarcloud.io" \ | ||
/d:sonar.cs.opencover.reportsPaths="**/*/coverage.opencover.xml" \ | ||
/d:sonar.cs.vstest.reportsPaths="**/*/*.trx" \ | ||
/d:sonar.branch.name="$SOURCE_BRANCH_NAME" | ||
fi | ||
|
||
# Now we can run our tests as usual | ||
./scripts/start-tests.sh | ||
|
||
# Now we can collect the results 👍 | ||
dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
|