CI: Add silent prescan SonarCloud job
[nonrtric/rapp/ransliceassurance.git] / .github / workflows / gerrit-novote-merge.yaml
1 ---
2 name: Gerrit Merge
3
4 # yamllint disable-line rule:truthy
5 on:
6   workflow_dispatch:
7     inputs:
8       GERRIT_BRANCH:
9         description: "Branch that change is against"
10         required: true
11         type: string
12       GERRIT_CHANGE_ID:
13         description: "The ID for the change"
14         required: true
15         type: string
16       GERRIT_CHANGE_NUMBER:
17         description: "The Gerrit number"
18         required: true
19         type: string
20       GERRIT_CHANGE_URL:
21         description: "URL to the change"
22         required: true
23         type: string
24       GERRIT_EVENT_TYPE:
25         description: "Type of Gerrit event"
26         required: true
27         type: string
28       GERRIT_PATCHSET_NUMBER:
29         description: "The patch number for the change"
30         required: true
31         type: string
32       GERRIT_PATCHSET_REVISION:
33         description: "The revision sha"
34         required: true
35         type: string
36       GERRIT_PROJECT:
37         description: "Project in Gerrit"
38         required: true
39         type: string
40       GERRIT_REFSPEC:
41         description: "Gerrit refspec of change"
42         required: true
43         type: string
44     secrets:
45       SONAR_TOKEN:
46         description: "Sonar Cloud access token"
47         required: true
48
49 concurrency:
50   # yamllint disable-line rule:line-length
51   group: gerrit-merge-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
52   cancel-in-progress: true
53
54 jobs:
55   notify:
56     runs-on: ubuntu-latest
57     steps:
58       - name: Notify job start
59         # yamllint disable-line rule:line-length
60         uses: lfit/gerrit-review-action@7c30179c3c9389545fccb0d458df59879372ae6a  # v0.6
61         with:
62           host: ${{ vars.GERRIT_SERVER }}
63           username: ${{ vars.GERRIT_SSH_USER }}
64           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
65           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
66           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
67           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
68           vote-type: clear
69           comment-only: true
70       - name: Allow replication
71         run: sleep 10s
72
73   call-prescan-sonarcloud:
74     needs: notify
75     # yamllint disable-line rule:line-length
76     uses: lfit/releng-reusable-workflows/.github/workflows/composed-prescan-sonar-cloud.yaml@main
77     with:
78       GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
79       GERRIT_CHANGE_ID: ${{ inputs.GERRIT_CHANGE_ID }}
80       GERRIT_CHANGE_NUMBER: ${{ inputs.GERRIT_CHANGE_NUMBER }}
81       GERRIT_CHANGE_URL: ${{ inputs.GERRIT_CHANGE_URL }}
82       GERRIT_EVENT_TYPE: ${{ inputs.GERRIT_EVENT_TYPE }}
83       GERRIT_PATCHSET_NUMBER: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
84       GERRIT_PATCHSET_REVISION: ${{ inputs.GERRIT_PATCHSET_REVISION }}
85       GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
86       GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
87       JDK_VERSION: "17"
88       # yamllint disable-line rule:line-length
89       PRE_BUILD_SCRIPT_URL: "https://raw.githubusercontent.com/o-ran-sc/ci-management/master/jjb/nonrtric-rapp-ransliceassurance/prescan-ransliceassurance-ubuntu.sh"
90       SONAR_ARGS: >
91         -Dsonar.organization=o-ran-sc
92         -Dsonar.projectKey=o-ran-sc_nonrtric-rapp-ransliceassurance
93         -Dsonar.projectName=nonrtric-rapp-ransliceassurance
94         -Dsonar.build.sourceEncoding=UTF-8
95         -Dsonar.language=go
96         -Dsonar.sources=.
97         -Dsonar.go.coverage.reportPaths=smoversion/coverage.txt, icsversion/coverage.txt
98         -Dsonar.inclusions=smoversion/internal/**/**.go, icsversion/internal/**/**.go
99         -Dsonar.exclusions=smoversion/main.go,smoversion/stub/**.go,smoversion/internal/**/**_test.go, smoversion/main.go, icsversion/stub/**.go, icsversion/internal/**/**_test.go
100         -Dsonar.verbose=true
101     secrets:
102       SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
103
104   report-status:
105     if: ${{ always() }}
106     needs: [notify, call-prescan-sonarcloud]
107     runs-on: ubuntu-latest
108     steps:
109       - name: Get workflow conclusion
110         uses: technote-space/workflow-conclusion-action@v3
111       - name: Report workflow conclusion
112         # yamllint disable-line rule:line-length
113         uses: lfit/gerrit-review-action@7c30179c3c9389545fccb0d458df59879372ae6a  # v0.6
114         with:
115           host: ${{ vars.GERRIT_SERVER }}
116           username: ${{ vars.GERRIT_SSH_USER }}
117           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
118           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
119           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
120           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
121           vote-type: ${{ env.WORKFLOW_CONCLUSION }}
122           comment-only: true