4 # yamllint disable-line rule:truthy
9 description: "Branch that change is against"
13 description: "The ID for the change"
17 description: "The Gerrit number"
21 description: "URL to the change"
25 description: "Type of Gerrit event"
28 GERRIT_PATCHSET_NUMBER:
29 description: "The patch number for the change"
32 GERRIT_PATCHSET_REVISION:
33 description: "The revision sha"
37 description: "Project in Gerrit"
41 description: "Gerrit refspec of change"
47 PACKER_VERSION: "1.9.1"
50 group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
51 cancel-in-progress: true
55 runs-on: ubuntu-latest
58 uses: lfit/gerrit-review-action@9627b9a144f2a2cad70707ddfae87c87dce60729 # v0.8
60 host: ${{ vars.GERRIT_SERVER }}
61 username: ${{ vars.GERRIT_SSH_USER }}
62 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
63 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
64 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
65 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
67 - name: Allow replication
72 runs-on: ubuntu-latest
74 - uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
76 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
77 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
78 gerrit-url: ${{ vars.GERRIT_URL }}
80 - name: Download actionlint
82 run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
84 - name: Check workflow files
85 run: ${{ steps.get_actionlint.outputs.executable }} -color
88 # run pre-commit tox env separately to get use of more parallel processing
91 runs-on: ubuntu-latest
93 - uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
95 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
96 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
97 gerrit-url: ${{ vars.GERRIT_URL }}
99 - uses: actions/setup-python@v5
101 python-version: "3.11"
102 - name: Run static analysis and format checkers
103 run: pipx run pre-commit run --all-files --show-diff-on-failure
107 runs-on: ubuntu-latest
109 - uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
111 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
112 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
113 gerrit-url: ${{ vars.GERRIT_URL }}
116 - uses: actions/setup-python@v5
119 python-version: "3.11"
120 - name: Clone git submodules
121 run: git submodule update --init
122 - name: Run JJB Verify
124 python -m pip install --upgrade pip
125 pip install jenkins-job-builder==6.3.0
126 mkdir -p "${HOME}/.config/jenkins_jobs"
127 cat << EOF > "${HOME}/.config/jenkins_jobs/jenkins_jobs.ini"
130 keep_descriptions=False
133 query_plugins_info=False
136 jenkins-jobs test -o archives/job-configs jjb/
140 runs-on: ubuntu-latest
142 - uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
144 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
145 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
146 gerrit-url: ${{ vars.GERRIT_URL }}
149 - uses: actions/setup-python@v5
152 python-version: "3.11"
159 runs-on: ubuntu-latest
161 - name: Gerrit Checkout
162 # yamllint disable-line rule:line-length
163 uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
165 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
166 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
167 gerrit-url: ${{ vars.GERRIT_URL }}
170 - name: Clone git submodules
172 run: git submodule update --init
173 - name: Check for changes
174 # yamllint disable-line rule:line-length
175 uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
178 base: ${{ inputs.GERRIT_BRANCH }}
179 ref: ${{ inputs.GERRIT_PATCHSET_REVISION }}
184 if: steps.changes.outputs.src == 'true'
185 uses: hashicorp/setup-packer@main
188 version: ${{ env.PACKER_VERSION }}
189 - name: Create cloud-env file required for packer
190 id: create-cloud-env-file
191 if: steps.changes.outputs.src == 'true'
194 echo "${{ secrets.CLOUDS_ENV_B64 }}" | base64 --decode \
195 > "${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl"
196 - name: Create cloud.yaml file for openstack client
197 id: create-cloud-yaml-file
198 if: steps.changes.outputs.src == 'true'
201 mkdir -p "$HOME/.config/openstack"
202 echo "${{ secrets.CLOUDS_YAML_B64 }}" | base64 --decode \
203 > "$HOME/.config/openstack/clouds.yaml"
205 if: steps.changes.outputs.src == 'true'
206 # yamllint disable-line rule:line-length
207 uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
209 python-version: "3.11"
210 - name: Install openstack deps
211 id: install-openstack-deps
212 if: steps.changes.outputs.src == 'true'
215 python -m pip install --upgrade pip
216 pip install python-openstackclient
218 - name: Verify packer files
219 if: steps.changes.outputs.src == 'true'
225 varfiles=(common-packer/vars/*.pkrvars.hcl)
226 templates=(templates/*.pkr.hcl)
228 mkdir -p "${GITHUB_WORKSPACE}/logs"
229 PACKER_LOGS_DIR="${GITHUB_WORKSPACE}/logs"
231 for varfile in "${varfiles[@]}"; do
232 if [[ "$varfile" == *"cloud-env.json"* ]] || \
233 [[ "$varfile" == "vars/*.json" ]] || \
234 [[ "$varfile" == *"cloud-env.pkrvars.hcl"* ]] || \
235 [[ "$varfile" == *"cloud-env-aws.pkrvars.hcl"* ]] || \
236 [[ "$varfile" == "vars/*.pkrvars.hcl" ]]; then
240 echo "::group::$varfile"
241 echo "-----> Test var: $varfile"
242 for template in "${templates[@]}"; do
243 if [[ "$template" == *"variables.pkr.hcl"* ]] || \
244 [[ "$template" == *"variables.auto.pkr.hcl"* ]]; then
248 if [[ "${template#*.}" == "pkr.hcl" ]]; then
249 echo "packer init $template ..."
250 packer init "$template"
253 LOG_FILE="packer-validate-${varfile##*/}-${template##*/}.log"
254 export PACKER_LOG="yes"
255 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/$LOG_FILE"
256 if output=$(OS_CLOUD=${{ env.OS_CLOUD }} packer validate \
257 -var-file="${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl" \
258 -var-file="$varfile" "$template"); then
259 echo "$template: $output"
261 echo "$template: $output"
279 runs-on: ubuntu-latest
281 - uses: technote-space/workflow-conclusion-action@v3
283 uses: lfit/gerrit-review-action@9627b9a144f2a2cad70707ddfae87c87dce60729 # v0.8
285 host: ${{ vars.GERRIT_SERVER }}
286 username: ${{ vars.GERRIT_SSH_USER }}
287 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
288 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
289 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
290 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
291 vote-type: ${{ env.WORKFLOW_CONCLUSION }}