run: >-
TOX_SKIP_ENV=pre-commit pipx run tox
+ packer-validation:
+ needs: prepare
+ runs-on: ubuntu-latest
+ steps:
+ - uses: lfit/checkout-gerrit-change-action@v0.3
+ with:
+ gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
+ delay: "0s"
+ - name: Setup packer
+ uses: hashicorp/setup-packer@main
+ id: setup
+ env:
+ AUTH_URL: ${{ secrets.cloud_auth_url }}
+ CLOUD_ENV: "packer/cloud-env.json"
+ with:
+ cloud_auth_url: "https://auth.vexxhost.net/v3/"
+ cloud_tenant: ${{ secrets.cloud_tenant }}
+ cloud_user: ${{ secrets.cloud_user }}
+ cloud_network: ${{ secrets.cloud_network }}
+ version: ${{ env.PACKER_VERSION }}
+ cloud_pass: ${{ secrets.cloud_pass }}
+ dicrectory: packer
+ file_name: cloud-env.json
+ fail_on_empty: true
+ - name: Clone git submodules
+ run: git submodule update --init
+ - uses: dorny/paths-filter@v2
+ id: changes
+ with:
+ filters: |
+ src:
+ - '**'
+ - if: steps.changes.outputs.src == 'true'
+ run: |
+ cd packer
+ varfiles=(vars/*.json common-packer/vars/*.json)
+ templates=(templates/*.json)
+
+ for varfile in "${varfiles[@]}"; do
+ # cloud-env.json is a file containing credentials which is pulled in via
+ # CLOUDENV variable so skip it here. Also handle the case where a project
+ # has not vars/*.json file.
+ if [[ "$varfile" == *"cloud-env.json"* ]] || [[ "$varfile" == 'vars/*.json' ]]; then
+ continue
+ fi
+
+ echo "-----> Testing varfile: $varfile"
+ for template in "${templates[@]}"; do
+ export PACKER_LOG="yes"
+ export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log"
+ if output=$(packer validate -var-file="$CLOUDENV" -var-file="$varfile" "$template"); then
+ echo "$template: $output"
+ else
+ echo "$template: $output"
+ exit 1
+ fi
+ done
+ done
+
vote:
if: ${{ always() }}
- needs: [prepare, pre-commit, tox]
+ needs: [prepare, pre-commit, tox, packer-validation]
runs-on: ubuntu-latest
steps:
- name: Get workflow conclusion