Skip to content

Commit

Permalink
Add a SonarQube configuration file to implement static code analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
chopin-fan committed Jun 27, 2024
1 parent baa5178 commit 612468d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/sonarqube.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
pull_request:
types: [opened, synchronize, reopened]

name: PR Static Code Analysis
jobs:
static-code-analysis:
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0'
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: ./.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarScanner for .NET
run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Add .NET global tools to PATH
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: Begin SonarQube analysis
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
dotnet build
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

0 comments on commit 612468d

Please sign in to comment.