@@ -3,55 +3,135 @@ name: SonarQube scan for internal repositories
33# configuration @ https://github.com/marketplace/actions/official-sonarqube-scan
44# TODO: replace existing sonarqube.yml in PPS repos (like https://github.com/progress-platform-services/chef-node-enrollment-api/blob/main/.github/workflows/sonarqube.yml)
55# TODO: remove from PPS code gen, just use the stub
6+ # TODO: add version to each pipeline stage
67
78on :
89 workflow_call :
9-
10+ # all secrets are inherited from the calling workflow, typically SONAR_TOKEN, SONAR_HOST_URL, GH_TOKEN
11+ inputs :
12+ perform-build :
13+ required : false
14+ type : boolean
15+ build-profile : # TODO: implmenet this flag - chef360 container build flags, etc
16+ required : false
17+ type : string
18+ language :
19+ required : false
20+ type : string
21+ report-unit-test-coverage :
22+ required : false
23+ type : boolean
24+ report-to-atlassian-dashboard :
25+ required : false
26+ type : boolean
27+ quality-product-name :
28+ required : false
29+ type : string
30+ quality-sonar-app-name :
31+ required : false
32+ type : string
33+ quality-testing-type :
34+ required : false
35+ type : string
36+ quality-service-name :
37+ required : false
38+ type : string
39+ quality-junit-report :
40+ required : false
41+ type : string
42+ visibility : # TODO: simplify the sonar step by bringing in the other variants (private, public, internal) from the calling workflow
43+ required : false
44+ type : string
45+ go-private-modules :
46+ required : false
47+ type : string
48+ udf1 :
49+ required : false
50+ type : string
51+ udf2 :
52+ required : false
53+ type : string
54+ udf3 :
55+ required : false
56+ type : string
57+
1058jobs :
11- # echo-inputs:
12- # name: 'Echo inputs'
13- # runs-on: ubuntu-latest
14- # steps:
15- # - name: Echo inputs
16- # run: |
17- # echo "Sonarqube scan for INTERNAL repositories, running on ubuntu-latest-4-cores runner"
18- # echo "Sonar host URL ${{ secrets.SONAR_HOST_URL}}"
19- # # echo "Skip unit tests set to ${{ inputs.skip-unit-tests }}"
20-
59+ echo-inputs :
60+ name : ' Echo inputs'
61+ runs-on : ubuntu-latest
62+ steps :
63+ - name : Echo inputs
64+ run : |
65+ echo "Sonarqube scan for INTERNAL repositories, running on ubuntu-latest-4-cores runner"
66+ echo "Perform build set to ${{ inputs.perform-build }}"
67+ echo "Build profile set to ${{ inputs.build-profile }}"
68+ echo "Language set to ${{ inputs.language }} "
69+ echo "Visibility set to ${{ inputs.visibility }} [ ${{ github.event.repository.visibility }} ]"
70+ echo "Perform unit test coverage set to ${{ inputs.report-unit-test-coverage }}"
71+ echo "Report to Atlassian dashboard set to ${{ inputs.report-to-atlassian-dashboard }}"
72+ echo "Quality product name set to ${{ inputs.quality-product-name }}"
73+ echo "Quality sonar application name set to ${{ inputs.quality-sonar-app-name }}"
74+ echo "Quality testing type set to ${{ inputs.quality-testing-type }}"
75+ echo "Quality service name set to ${{ inputs.quality-service-name }}"
76+ echo "Quality JUnit report set to ${{ inputs.quality-junit-report }}"
77+ echo "Go private modules set to ${{ inputs.go-private-modules }}"
78+
2179 SonarQube :
2280 runs-on : ubuntu-latest-4-cores
2381 steps :
24- # unit-tests:
25- # runs-on: ubuntu-latest
26- # if: ${{ inputs.skip-unit-tests == false }}
27- # steps:
28- # - name: Run unit tests
29- # run: |
30- # echo "Running unit tests..."
31- - uses : actions/checkout@v4
82+ - name : checkout
83+ if : ${{ inputs.perform-build == true && inputs.visibility == 'internal' }}
84+ uses : actions/checkout@v4
3285 with :
3386 fetch-depth : 0
3487
3588 - name : Set up Go
36- uses : actions/setup-go@v4
89+ if : ${{ inputs.perform-build == true && inputs.language == 'Go' && inputs.visibility == 'internal' }}
90+ uses : actions/setup-go@v5
3791 with :
38- go-version : 1.24.2
39- check-latest : true
40-
92+ go-version : ' stable'
93+ # go-version: 1.24.2
94+ # check-latest: true
95+
4196 - name : Configure git for private modules
97+ if : ${{ inputs.perform-build == true && inputs.visibility == 'internal' }}
4298 env :
43- GOPRIVATE : github.com/progress-platform-services/*
99+ GOPRIVATE : ${{ inputs.go-private-modules }} # github.com/progress-platform-services/*
44100 run : git config --global url."https://${{ secrets.GH_TOKEN }}@github.com/".insteadOf "https://github.com/"
45101
46- - name : Generate coverage files
47- run : go test -v -coverprofile="coverage.out" ./...
48- - name : Copy file
49- run : mkdir -p test/coverage; cp coverage.out test/coverage/coverage.out
102+ - name : Generate unit test coverage files
103+ if : ${{ inputs.perform-build == true && inputs.report-unit-test-coverage == true && inputs.language == 'Go' && inputs.visibility == 'internal'}}
104+ run : |
105+ go test -v -coverprofile="coverage.out" ./...
106+ mkdir -p test/coverage
107+ cp coverage.out test/coverage/coverage.out
50108
51109 - name : SonarQube Scan
110+ if : ${{ inputs.perform-build == true && inputs.report-unit-test-coverage == true && inputs.visibility == 'internal' }}
52111 uses : sonarsource/sonarqube-scan-action@v5.1.0
53112 # was uses: sonarsource/sonarqube-scan-action@master
54113 continue-on-error : true
55114 env :
56115 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
57- SONAR_HOST_URL : ${{ secrets.SONAR_HOST_URL }}
116+ SONAR_HOST_URL : ${{ secrets.SONAR_HOST_URL }}
117+
118+ # TODO: Test adding Irfan's quality reporting stage inline here after sonar run (https://github.com/Progress-I360/github-action-reporting)
119+ # PRODUCT_NAME = [Chef360 | Courier | Inspec]
120+ - name : Run SonarQube report generation
121+ if : ${{ inputs.report-to-atlassian-dashboard == true && inputs.visibility == 'internal' }}
122+ uses : Progress-I360/github-action-reporting/sonarqube@main
123+ with :
124+ PRODUCT_NAME : ${{ inputs.quality-product-name }}
125+ SONAR_APP_NAME : ${{ inputs.quality-sonar-app-name }}
126+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
127+
128+ # TESTING_TYPE = [Unit | Integration | e2e | api | Performance | Security]
129+ # ENVIRONMENT = [DEV | STAGE | PROD] (optional)
130+ - name : Run report generation
131+ if : ${{ inputs.report-to-atlassian-dashboard == true && inputs.report-unit-test-coverage == true && inputs.visibility == 'internal' }}
132+ uses : Progress-I360/github-action-reporting/automation@main
133+ with :
134+ PRODUCT_NAME : ${{ inputs.quality-product-name }}
135+ TESTING_TYPE : ${{ inputs.quality-testing-type }}
136+ SERVICE_NAME : ${{ inputs.quality-service-name }}
137+ JUNIT_REPORT : ${{ inputs.quality-junit-report }}
0 commit comments