1- name : Analysis stage
2-
3- on :
4- workflow_call :
5- inputs :
6- unit_test_dir :
7- description : Directory containing the unit tests
8- required : true
9- type : string
10- build_datetime :
11- description : Build datetime
12- required : true
13- type : string
14- build_timestamp :
15- description : Build timestamp
16- required : true
17- type : string
18- build_epoch :
19- description : Build epoch
20- required : true
21- type : string
22- nodejs_version :
23- description : Node.js version
24- required : true
25- type : string
26- python_version :
27- description : Python version
28- required : true
29- type : string
30- terraform_version :
31- description : Terraform version
32- required : true
33- type : string
34- version :
35- description : Version of the software
36- required : true
37- type : string
38-
39- jobs :
40- download-test-coverage :
41- name : Download test coverage
42- runs-on : ubuntu-latest
43- timeout-minutes : 2
44- steps :
45- - name : Checkout code
46- uses : actions/checkout@v4
47- with :
48- submodules : true
49- - name : Download coverage report
50- uses : actions/download-artifact@v4
51- with :
52- name : test-coverage-report
53- path : coverage
1+ name : " Perform static analysis"
2+ description : " Perform static analysis with SonarCloud for .NET projects"
3+ inputs :
4+ sonar_organisation_key :
5+ description : " Sonar organisation key, used to identify the project"
6+ required : true
7+ sonar_project_key :
8+ description : " Sonar project key, used to identify the project"
9+ required : true
10+ sonar_token :
11+ description : " Sonar token, the API key"
12+ required : true
13+ coverage_path :
14+ description : " Path to coverage reports"
15+ required : false
16+ default : " coverage"
17+ runs :
18+ using : " composite"
19+ steps :
20+ - name : Set up JDK 17
21+ uses : actions/setup-java@v4
22+ with :
23+ java-version : 17
24+ distribution : " zulu"
25+
26+ - name : Install .NET SDKs
27+ uses : actions/setup-dotnet@v4
28+ with :
29+ dotnet-version : |
30+ 7.0.x
31+ 8.0.x
32+ 9.0.x
33+
34+ - name : Cache SonarQube packages
35+ uses : actions/cache@v4
36+ with :
37+ path : ~/.sonar/cache
38+ key : ${{ runner.os }}-sonar-${{ hashFiles('**/*.csproj') }}
39+ restore-keys : |
40+ ${{ runner.os }}-sonar-
5441
55- perform-static-analysis :
56- name : Perform static analysis
57- needs : [download-test-coverage]
58- runs-on : ubuntu-latest
59- permissions :
60- id-token : write
61- contents : read
62- pull-requests : read
63- timeout-minutes : 15
64- steps :
65- - name : Checkout code
66- uses : actions/checkout@v4
67- with :
68- submodules : true
69- fetch-depth : 0 # Full history for more accurate reporting
70- - name : Download coverage report
71- uses : actions/download-artifact@v4
72- with :
73- name : test-coverage-report
74- path : coverage
75- - name : Perform static analysis
76- uses : ./.github/actions/perform-static-analysis
77- with :
78- sonar_organisation_key : ${{ vars.SONAR_ORGANISATION_KEY }}
79- sonar_project_key : ${{ vars.SONAR_PROJECT_KEY }}
80- sonar_token : ${{ secrets.SONAR_TOKEN }}
81- coverage_path : " coverage"
42+ - name : Cache NuGet packages
43+ uses : actions/cache@v4
44+ with :
45+ path : ~/.nuget/packages
46+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }}
47+ restore-keys : |
48+ ${{ runner.os }}-nuget-
49+
50+ - name : Install SonarScanner
51+ shell : bash
52+ run : dotnet tool install --global dotnet-sonarscanner
53+
54+ - name : SonarCloud analysis
55+ shell : bash
56+ env :
57+ GITHUB_TOKEN : ${{ github.token }}
58+ SONAR_TOKEN : ${{ inputs.sonar_token }}
59+ run : |
60+ chmod +x ${{ github.workspace }}/scripts/reports/sonar-analysis.sh
61+ ${{ github.workspace }}/scripts/reports/sonar-analysis.sh \
62+ "${{ inputs.sonar_project_key }}" \
63+ "${{ inputs.sonar_organisation_key }}" \
64+ "${{ inputs.sonar_token }}" \
65+ "${{ inputs.coverage_path }}" \
66+ "${{ github.token }}" \
67+ "${{ github.event_name }}" \
68+ "${{ github.head_ref }}" \
69+ "${{ github.base_ref }}" \
70+ "${{ github.event.pull_request.number }}" \
71+ "${{ github.repository }}" \
72+ "${{ github.ref }}" \
73+ "${{ github.sha }}"
0 commit comments