105d0104e4126ded72c58aea6a094da0358bdf01
[sim/a1-interface.git] / .github / workflows / gerrit-novote-verify.yaml
1 ---
2 name: Gerrit 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       TARGET_REPO:
45         # yamllint disable-line rule:line-length
46         description: "The target GitHub repository needing the required workflow"
47         required: false
48         default: ${{ github.repository }}
49         type: string
50       TOX_ENVS:
51         description: "Map of versions and envs to run"
52         required: true
53         type: string
54
55 concurrency:
56   # yamllint disable-line rule:line-length
57   group: gerrit-verify-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
58   cancel-in-progress: true
59
60 permissions: read-all
61
62 jobs:
63   prepare:
64     runs-on: ubuntu-latest
65     steps:
66       - name: Clear votes
67         uses: lfit/gerrit-review-action@v0.4
68         with:
69           host: ${{ vars.GERRIT_SERVER }}
70           username: ${{ vars.GERRIT_SSH_REQUIRED_USER }}
71           key: ${{ secrets.GERRIT_SSH_REQUIRED_PRIVKEY }}
72           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
73           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
74           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
75           vote-type: clear
76           comment-only: "true"
77       - name: Allow replication
78         run: sleep 10s
79
80   call-gerrit-tox-verify:
81     needs: prepare
82     # yamllint disable-line rule:line-length
83     uses: lfit/releng-reusable-workflows/.github/workflows/gerrit-compose-required-tox-verify.yaml@main
84     with:
85       GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
86       GERRIT_CHANGE_ID: ${{ inputs.GERRIT_CHANGE_ID }}
87       GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
88       GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
89       TARGET_REPO: ${{ inputs.TARGET_REPO }}
90       TOX_ENVS: "code"
91
92   vote:
93     if: ${{ always() }}
94     # yamllint enable rule:line-length
95     needs: [prepare, call-gerrit-tox-verify]
96     runs-on: ubuntu-latest
97     steps:
98       - uses: technote-space/workflow-conclusion-action@v3
99       - name: Set vote
100         uses: lfit/gerrit-review-action@v0.4
101         with:
102           host: ${{ vars.GERRIT_SERVER }}
103           username: ${{ vars.GERRIT_SSH_REQUIRED_USER }}
104           key: ${{ secrets.GERRIT_SSH_REQUIRED_PRIVKEY }}
105           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
106           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
107           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
108           vote-type: ${{ env.WORKFLOW_CONCLUSION }}
109           comment-only: "true"