a274f16044ba8c19bbcf9b558c387a0b600e4f03
[ccsdk/cds.git] / .github / workflows / gerrit-verify.yaml
1 ---
2 name: Gerrit Composed Maven Verify
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       JDK_VERSION:
45         description: "OpenJDK version"
46         required: false
47         default: "17"
48         type: string
49       MVN_VERSION:
50         description: "Maven version"
51         required: false
52         default: "3.8.2"
53         type: string
54       TARGET_REPO:
55         # yamllint disable-line rule:line-length
56         description: "The target GitHub repository needing the required workflow"
57         required: false
58         default: ${{ github.repository }}
59         type: string
60
61 concurrency:
62   # yamllint disable-line rule:line-length
63   group: compose-maven-verify-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
64   cancel-in-progress: true
65
66 jobs:
67   prepare:
68     runs-on: ubuntu-latest
69     steps:
70       - name: Clear votes
71         # yamllint disable-line rule:line-length
72         uses: lfit/gerrit-review-action@6ac4c2322b68c0120a9b516eb0421491ee1b3fdf  # v0.4
73         with:
74           host: ${{ vars.GERRIT_SERVER }}
75           username: ${{ vars.GERRIT_SSH_USER }}
76           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
77           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
78           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
79           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
80           vote-type: clear
81           comment-only: true
82       - name: Allow replication
83         run: sleep 10s
84
85   maven-verify:
86     needs: prepare
87     # use compose-jjb-verify from the v0.4 series of releng-reusable-workflows
88     # yamllint disable-line rule:line-length
89     uses: lfit/releng-reusable-workflows/.github/workflows/gerrit-compose-required-maven-verify.yaml@main
90     with:
91       GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
92       GERRIT_CHANGE_ID: ${{ inputs.GERRIT_CHANGE_ID }}
93       GERRIT_CHANGE_NUMBER: ${{ inputs.GERRIT_CHANGE_NUMBER }}
94       GERRIT_CHANGE_URL: ${{ inputs.GERRIT_CHANGE_URL }}
95       GERRIT_EVENT_TYPE: ${{ inputs.GERRIT_EVENT_TYPE }}
96       GERRIT_PATCHSET_NUMBER: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
97       GERRIT_PATCHSET_REVISION: ${{ inputs.GERRIT_PATCHSET_REVISION }}
98       GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
99       GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
100       JDK_VERSION: ${{ inputs.JDK_VERSION }}
101       MVN_VERSION: ${{ inputs.MVN_VERSION }}
102       TARGET_REPO: ${{ inputs.TARGET_REPO }}
103
104   vote:
105     if: ${{ always() }}
106     # yamllint enable rule:line-length
107     needs: [prepare, maven-verify]
108     runs-on: ubuntu-latest
109     steps:
110       - name: Get conclusion
111         # yamllint disable-line rule:line-length
112         uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5  # v3.0.3
113       - name: Set vote
114         # yamllint disable-line rule:line-length
115         uses: lfit/gerrit-review-action@6ac4c2322b68c0120a9b516eb0421491ee1b3fdf  # v0.4
116         with:
117           host: ${{ vars.GERRIT_SERVER }}
118           username: ${{ vars.GERRIT_SSH_USER }}
119           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
120           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
121           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
122           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
123           vote-type: ${{ env.WORKFLOW_CONCLUSION }}
124           comment-only: true