blob: 6310b4971d004a645361c9ba99aa8e3002b7cfe6 [file] [log] [blame]
Jessica Wagantall675c1a72023-05-01 14:03:18 -07001---
2name: Gerrit Verify
3
4# yamllint disable-line rule:truthy
5on:
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
45concurrency:
46 group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
47 cancel-in-progress: true
48
49jobs:
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
Andrew Grimbergc06ba612023-05-02 14:10:49 -070066 actionlint:
67 runs-on: ubuntu-latest
68 steps:
69 - uses: lfit/checkout-gerrit-change-action@v0.3
70 with:
71 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
72 delay: "0s"
73 - name: Download actionlint
74 id: get_actionlint
75 run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
76 shell: bash
77 - name: Check workflow files
78 run: ${{ steps.get_actionlint.outputs.executable }} -color
79 shell: bash
80
Jessica Wagantall675c1a72023-05-01 14:03:18 -070081 # run pre-commit tox env separately to get use of more parallel processing
82 pre-commit:
83 needs: prepare
84 runs-on: ubuntu-latest
85 steps:
Andrew Grimbergc06ba612023-05-02 14:10:49 -070086 - uses: lfit/checkout-gerrit-change-action@v0.3
Jessica Wagantall675c1a72023-05-01 14:03:18 -070087 with:
88 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
89 delay: "0s"
90 - uses: actions/setup-python@v4
91 with:
92 python-version: "3.11"
93 - name: Run static analysis and format checkers
94 run: pipx run tox -e pre-commit
95
Jessica Wagantall675c1a72023-05-01 14:03:18 -070096 jjb-validation:
97 needs: prepare
98 runs-on: ubuntu-latest
99 steps:
Andrew Grimbergc06ba612023-05-02 14:10:49 -0700100 - uses: lfit/checkout-gerrit-change-action@v0.3
Jessica Wagantall675c1a72023-05-01 14:03:18 -0700101 with:
102 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
103 delay: "0s"
104 - uses: actions/setup-python@v4
105 id: setup-python
106 with:
107 python-version: "3.11"
Jessica Wagantall378a76f2023-05-02 11:22:39 -0700108 - name: Clone git submodules
109 run: git submodule update --init
Jessica Wagantall675c1a72023-05-01 14:03:18 -0700110 - name: Run JJB Verify
111 run: |
112 python -m pip install --upgrade pip
113 pip install jenkins-job-builder
114 mkdir -p "${HOME}/.config/jenkins_jobs"
115 cat << EOF > "${HOME}/.config/jenkins_jobs/jenkins_jobs.ini"
116 [job_builder]
117 ignore_cache=True
118 keep_descriptions=False
119 include_path=.
120 recursive=True
121 query_plugins_info=False
122 config-xml=True
123 EOF
124 jenkins-jobs test -o archives/job-configs jjb/
125
126 vote:
127 if: ${{ always() }}
Andrew Grimbergc06ba612023-05-02 14:10:49 -0700128 needs: [prepare, actionlint, pre-commit, jjb-validation]
Jessica Wagantall675c1a72023-05-01 14:03:18 -0700129 runs-on: ubuntu-latest
130 steps:
131 - uses: technote-space/workflow-conclusion-action@v3
132 - name: Set vote
133 uses: lfit/gerrit-review-action@v0.3
134 with:
135 host: ${{ vars.GERRIT_SERVER }}
136 username: ${{ vars.GERRIT_SSH_USER }}
137 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
138 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
139 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
140 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
141 vote-type: ${{ env.WORKFLOW_CONCLUSION }}