Fix: Run both sonar and clm scans in parallel
[ccsdk/cds.git] / .github / workflows / gerrit-merge.yaml
1 ---
2 name: Gerrit Composed Maven 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
45 concurrency:
46   # yamllint disable-line rule:line-length
47   group: compose-maven-merge-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
48   cancel-in-progress: true
49
50 jobs:
51   notify:
52     runs-on: ubuntu-latest
53     steps:
54       - name: Notify job start
55         # yamllint disable-line rule:line-length
56         uses: lfit/gerrit-review-action@7c30179c3c9389545fccb0d458df59879372ae6a  # v0.6
57         with:
58           host: ${{ vars.GERRIT_SERVER }}
59           username: ${{ vars.GERRIT_SSH_USER }}
60           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
61           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
62           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
63           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
64           vote-type: clear
65           comment-only: true
66       - name: Allow replication
67         run: sleep 10s
68
69   run-maven-clm:
70     needs: notify
71     # yamllint disable-line rule:line-length
72     uses: lfit/releng-reusable-workflows/.github/workflows/composed-maven-nexus-iq.yaml@main
73     with:
74       GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
75       GERRIT_CHANGE_ID: ${{ inputs.GERRIT_CHANGE_ID }}
76       GERRIT_CHANGE_NUMBER: ${{ inputs.GERRIT_CHANGE_NUMBER }}
77       GERRIT_CHANGE_URL: ${{ inputs.GERRIT_CHANGE_URL }}
78       GERRIT_EVENT_TYPE: ${{ inputs.GERRIT_EVENT_TYPE }}
79       GERRIT_PATCHSET_NUMBER: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
80       GERRIT_PATCHSET_REVISION: ${{ inputs.GERRIT_PATCHSET_REVISION }}
81       GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
82       GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
83       # yamllint disable rule:line-length
84       ENV_VARS: '{"MAVEN_OPTS": "--add-opens=java.base/java.util=ALL-UNNAMED"}'
85       ENV_SECRETS: "{}"
86       JDK_VERSION: "17"
87       MVN_PHASES: "clean install dependency:tree com.sonatype.clm:clm-maven-plugin:2.41.0-02:index"
88       MVN_OPTS: >-
89         -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
90         -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
91         -DaltDeploymentRepository=staging::default::file:"${GITHUB_WORKSPACE}"/m2repo
92     secrets:
93       NEXUS_IQ_PASSWORD: ${{ secrets.NEXUS_IQ_PASSWORD }}
94
95   run-maven-sonar:
96     needs: notify
97     # yamllint disable-line rule:line-length
98     uses: lfit/releng-reusable-workflows/.github/workflows/composed-maven-sonar-cloud.yaml@main
99     with:
100       GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
101       GERRIT_CHANGE_ID: ${{ inputs.GERRIT_CHANGE_ID }}
102       GERRIT_CHANGE_NUMBER: ${{ inputs.GERRIT_CHANGE_NUMBER }}
103       GERRIT_CHANGE_URL: ${{ inputs.GERRIT_CHANGE_URL }}
104       GERRIT_EVENT_TYPE: ${{ inputs.GERRIT_EVENT_TYPE }}
105       GERRIT_PATCHSET_NUMBER: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
106       GERRIT_PATCHSET_REVISION: ${{ inputs.GERRIT_PATCHSET_REVISION }}
107       GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
108       GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
109       # yamllint disable rule:line-length
110       ENV_VARS: '{"MAVEN_OPTS": "--add-opens=java.base/java.util=ALL-UNNAMED"}'
111       ENV_SECRETS: "{}"
112       JDK_VERSION: "17"
113       SONAR_PROJECT_KEY: "onap_ccsdk-cds"
114       SONAR_ORG: "onap"
115       SONAR_ARGS: >
116         -Dsonar.sources=src/main
117         -Dsonar.test.inclusions=**/*.java,**/*.kt
118         -Dsonar.tests=src/test
119         -Dsonar.verbose=true
120     secrets:
121       SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
122
123   report-status:
124     if: ${{ always() }}
125     needs: [notify, run-maven-clm, run-maven-sonar]
126     runs-on: ubuntu-latest
127     steps:
128       - name: Get workflow conclusion
129         uses: technote-space/workflow-conclusion-action@v3
130       - name: Report workflow conclusion
131         # yamllint disable-line rule:line-length
132         uses: lfit/gerrit-review-action@7c30179c3c9389545fccb0d458df59879372ae6a  # v0.6
133         with:
134           host: ${{ vars.GERRIT_SERVER }}
135           username: ${{ vars.GERRIT_SSH_USER }}
136           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
137           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
138           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
139           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
140           vote-type: ${{ env.WORKFLOW_CONCLUSION }}
141           comment-only: true