eefd2760975ef88fecc21a1929653ba5d83630f5
[ci-management.git] / .github / workflows / gerrit-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
45 concurrency:
46   group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
47   cancel-in-progress: true
48
49 jobs:
50   prepare:
51     runs-on: ubuntu-latest
52     steps:
53       - name: Clear votes
54         uses: lfit/gerrit-review-action@v0.3
55         with:
56           host: ${{ vars.GERRIT_SERVER }}
57           username: ${{ vars.GERRIT_SSH_USER }}
58           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
59           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
60           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
61           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
62           vote-type: clear
63       - name: Allow replication
64         run: sleep 10s
65
66   # run pre-commit tox env separately to get use of more parallel processing
67   pre-commit:
68     needs: prepare
69     runs-on: ubuntu-latest
70     steps:
71       - uses: lfit/checkout-gerrit-change-action@v0.2
72         with:
73           gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
74           delay: "0s"
75       - uses: actions/setup-python@v4
76         with:
77           python-version: "3.11"
78       - name: Run static analysis and format checkers
79         run: pipx run tox -e pre-commit
80
81   jjb-validation:
82     needs: prepare
83     runs-on: ubuntu-latest
84     steps:
85       - uses: lfit/checkout-gerrit-change-action@v0.2
86         with:
87           gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
88           delay: "0s"
89       - uses: actions/setup-python@v4
90         id: setup-python
91         with:
92           python-version: "3.11"
93       - name: Clone git submodules
94         run: git submodule update --init
95       - name: Run JJB Verify
96         run: |
97           python -m pip install --upgrade pip
98           pip install jenkins-job-builder
99           mkdir -p "${HOME}/.config/jenkins_jobs"
100           cat << EOF > "${HOME}/.config/jenkins_jobs/jenkins_jobs.ini"
101           [job_builder]
102           ignore_cache=True
103           keep_descriptions=False
104           include_path=.
105           recursive=True
106           query_plugins_info=False
107           config-xml=True
108           EOF
109           jenkins-jobs test -o archives/job-configs jjb/
110
111   vote:
112     if: ${{ always() }}
113     needs: [prepare, pre-commit, jjb-validation]
114     runs-on: ubuntu-latest
115     steps:
116       - uses: technote-space/workflow-conclusion-action@v3
117       - name: Set vote
118         uses: lfit/gerrit-review-action@v0.3
119         with:
120           host: ${{ vars.GERRIT_SERVER }}
121           username: ${{ vars.GERRIT_SSH_USER }}
122           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
123           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
124           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
125           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
126           vote-type: ${{ env.WORKFLOW_CONCLUSION }}