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@v0.3
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@57bf0435f739fbbc7ce4cc85c9c3b8a386c6f84b # v0.6
76 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
78 - name: Download actionlint
80 run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
82 - name: Check workflow files
83 run: ${{ steps.get_actionlint.outputs.executable }} -color
86 # run pre-commit tox env separately to get use of more parallel processing
89 runs-on: ubuntu-latest
91 - uses: lfit/checkout-gerrit-change-action@57bf0435f739fbbc7ce4cc85c9c3b8a386c6f84b # v0.6
93 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
95 - uses: actions/setup-python@v4
97 python-version: "3.11"
98 - name: Run static analysis and format checkers
99 run: pipx run pre-commit run --all-files --show-diff-on-failure
103 runs-on: ubuntu-latest
105 - uses: lfit/checkout-gerrit-change-action@57bf0435f739fbbc7ce4cc85c9c3b8a386c6f84b # v0.6
107 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
109 - uses: actions/setup-python@v4
112 python-version: "3.11"
113 - name: Clone git submodules
114 run: git submodule update --init
115 - name: Run JJB Verify
117 python -m pip install --upgrade pip
118 pip install jenkins-job-builder==5.1.0
119 mkdir -p "${HOME}/.config/jenkins_jobs"
120 cat << EOF > "${HOME}/.config/jenkins_jobs/jenkins_jobs.ini"
123 keep_descriptions=False
126 query_plugins_info=False
129 jenkins-jobs test -o archives/job-configs jjb/
133 runs-on: ubuntu-latest
135 - uses: lfit/checkout-gerrit-change-action@57bf0435f739fbbc7ce4cc85c9c3b8a386c6f84b # v0.6
137 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
139 - uses: actions/setup-python@v4
142 python-version: "3.11"
149 runs-on: ubuntu-latest
151 - name: Gerrit Checkout
152 # yamllint disable-line rule:line-length
153 uses: lfit/checkout-gerrit-change-action@57bf0435f739fbbc7ce4cc85c9c3b8a386c6f84b # v0.6
155 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
157 - name: Clone git submodules
159 run: git submodule update --init
160 - name: Check for changes
161 # yamllint disable-line rule:line-length
162 uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
165 base: ${{ inputs.GERRIT_BRANCH }}
166 ref: ${{ inputs.GERRIT_PATCHSET_REVISION }}
171 if: steps.changes.outputs.src == 'true'
172 uses: hashicorp/setup-packer@main
175 version: ${{ env.PACKER_VERSION }}
176 - name: Create cloud-env file required for packer
177 id: create-cloud-env-file
178 if: steps.changes.outputs.src == 'true'
181 echo "${{ secrets.CLOUDS_ENV_B64 }}" | base64 --decode \
182 > "${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl"
183 - name: Create cloud.yaml file for openstack client
184 id: create-cloud-yaml-file
185 if: steps.changes.outputs.src == 'true'
188 mkdir -p "$HOME/.config/openstack"
189 echo "${{ secrets.CLOUDS_YAML_B64 }}" | base64 --decode \
190 > "$HOME/.config/openstack/clouds.yaml"
192 if: steps.changes.outputs.src == 'true'
193 # yamllint disable-line rule:line-length
194 uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
196 python-version: "3.11"
197 - name: Install openstack deps
198 id: install-openstack-deps
199 if: steps.changes.outputs.src == 'true'
202 python -m pip install --upgrade pip
203 pip install python-openstackclient
205 - name: Verify packer files
206 if: steps.changes.outputs.src == 'true'
212 varfiles=(common-packer/vars/*.pkrvars.hcl)
213 templates=(templates/*.pkr.hcl)
215 mkdir -p "${GITHUB_WORKSPACE}/logs"
216 PACKER_LOGS_DIR="${GITHUB_WORKSPACE}/logs"
218 for varfile in "${varfiles[@]}"; do
219 if [[ "$varfile" == *"cloud-env.json"* ]] || \
220 [[ "$varfile" == "vars/*.json" ]] || \
221 [[ "$varfile" == *"cloud-env.pkrvars.hcl"* ]] || \
222 [[ "$varfile" == *"cloud-env-aws.pkrvars.hcl"* ]] || \
223 [[ "$varfile" == "vars/*.pkrvars.hcl" ]]; then
227 echo "::group::$varfile"
228 echo "-----> Test var: $varfile"
229 for template in "${templates[@]}"; do
230 if [[ "$template" == *"variables.pkr.hcl"* ]] || \
231 [[ "$template" == *"variables.auto.pkr.hcl"* ]]; then
235 if [[ "${template#*.}" == "pkr.hcl" ]]; then
236 echo "packer init $template ..."
237 packer init "$template"
240 LOG_FILE="packer-validate-${varfile##*/}-${template##*/}.log"
241 export PACKER_LOG="yes"
242 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/$LOG_FILE"
243 if output=$(OS_CLOUD=${{ env.OS_CLOUD }} packer validate \
244 -var-file="${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl" \
245 -var-file="$varfile" "$template"); then
246 echo "$template: $output"
248 echo "$template: $output"
266 runs-on: ubuntu-latest
268 - uses: technote-space/workflow-conclusion-action@v3
270 uses: lfit/gerrit-review-action@v0.3
272 host: ${{ vars.GERRIT_SERVER }}
273 username: ${{ vars.GERRIT_SSH_USER }}
274 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
275 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
276 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
277 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
278 vote-type: ${{ env.WORKFLOW_CONCLUSION }}