|
1 |
| -name: Windows Tests |
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +# This workflow helps you trigger a SonarCloud analysis of your code and populates |
| 7 | +# GitHub Code Scanning alerts with the vulnerabilities found. |
| 8 | +# Free for open source project. |
| 9 | + |
| 10 | +# 1. Login to SonarCloud.io using your GitHub account |
| 11 | + |
| 12 | +# 2. Import your project on SonarCloud |
| 13 | +# * Add your GitHub organization first, then add your repository as a new project. |
| 14 | +# * Please note that many languages are eligible for automatic analysis, |
| 15 | +# which means that the analysis will start automatically without the need to set up GitHub Actions. |
| 16 | +# * This behavior can be changed in Administration > Analysis Method. |
| 17 | +# |
| 18 | +# 3. Follow the SonarCloud in-product tutorial |
| 19 | +# * a. Copy/paste the Project Key and the Organization Key into the args parameter below |
| 20 | +# (You'll find this information in SonarCloud. Click on "Information" at the bottom left) |
| 21 | +# |
| 22 | +# * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN |
| 23 | +# (On SonarCloud, click on your avatar on top-right > My account > Security |
| 24 | +# or go directly to https://sonarcloud.io/account/security/) |
| 25 | + |
| 26 | +# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/) |
| 27 | +# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9) |
| 28 | + |
| 29 | +name: SonarCloud analysis |
2 | 30 |
|
3 | 31 | on:
|
4 | 32 | push:
|
5 |
| - branches: |
6 |
| - - main |
| 33 | + branches: [ "main" ] |
7 | 34 | pull_request:
|
8 |
| - types: [opened, synchronize, reopened] |
| 35 | + branches: [ "main" ] |
| 36 | + workflow_dispatch: |
| 37 | + |
| 38 | +permissions: |
| 39 | + pull-requests: read # allows SonarCloud to decorate PRs with analysis results |
| 40 | + |
9 | 41 | jobs:
|
10 |
| - build: |
11 |
| - name: Build |
12 |
| - runs-on: windows-latest |
| 42 | + Analysis: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
13 | 45 | steps:
|
14 |
| - - name: Set up JDK 11 |
15 |
| - uses: actions/setup-java@v1 |
16 |
| - with: |
17 |
| - java-version: 1.11 |
18 |
| - - uses: actions/checkout@v2 |
19 |
| - with: |
20 |
| - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
21 |
| - - name: Cache SonarCloud packages |
22 |
| - uses: actions/cache@v1 |
23 |
| - with: |
24 |
| - path: ~\sonar\cache |
25 |
| - key: ${{ runner.os }}-sonar |
26 |
| - restore-keys: ${{ runner.os }}-sonar |
27 |
| - - name: Cache SonarCloud scanner |
28 |
| - id: cache-sonar-scanner |
29 |
| - uses: actions/cache@v1 |
30 |
| - with: |
31 |
| - path: .\.sonar\scanner |
32 |
| - key: ${{ runner.os }}-sonar-scanner |
33 |
| - restore-keys: ${{ runner.os }}-sonar-scanner |
34 |
| - - name: Install SonarCloud scanner |
35 |
| - if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
36 |
| - shell: powershell |
37 |
| - run: | |
38 |
| - New-Item -Path .\.sonar\scanner -ItemType Directory |
39 |
| - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner --version 9.0.0 |
40 |
| - - name: Build and analyze |
| 46 | + - name: Analyze with SonarCloud |
| 47 | + |
| 48 | + # You can pin the exact commit or the version. |
| 49 | + # uses: SonarSource/sonarcloud-github-action@v2.2.0 |
| 50 | + uses: SonarSource/sonarcloud-github-action@v2.2.0 |
41 | 51 | env:
|
42 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
43 |
| - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
44 |
| - shell: powershell |
45 |
| - run: | |
46 |
| - cd src |
47 |
| - ..\.sonar\scanner\dotnet-sonarscanner begin /k:"SpiceSharp_SpiceSharpParser" /o:"spicesharp" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.verbose=true |
48 |
| - dotnet build |
49 |
| - dotnet test --blame --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=opencover.xml |
50 |
| - ..\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" |
| 52 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) |
| 53 | + with: |
| 54 | + # Additional arguments for the SonarScanner CLI |
| 55 | + args: |
| 56 | + # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) |
| 57 | + # mandatory |
| 58 | + -Dsonar.projectKey="SpiceSharp_SpiceSharpParser" |
| 59 | + -Dsonar.organization="spicesharp" |
| 60 | + # Comma-separated paths to directories containing main source files. |
| 61 | + #-Dsonar.sources= # optional, default is project base directory |
| 62 | + # Comma-separated paths to directories containing test source files. |
| 63 | + #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ |
| 64 | + # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. |
| 65 | + #-Dsonar.verbose= # optional, default is false |
| 66 | + # When you need the analysis to take place in a directory other than the one from which it was launched, default is . |
| 67 | + projectBaseDir: . |
0 commit comments