E2E tests #203
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E tests | |
on: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
logs: | |
description: "Set 1 to activate full logs" | |
required: false | |
default: "0" | |
jobs: | |
plugin-build: | |
runs-on: [self-hosted, nxlab, packer] | |
outputs: | |
test-list: ${{ steps.test-list.outputs.list}} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup `golang` | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ">=1.19.0" | |
- name: Build packer plugin | |
run: | | |
cd $GITHUB_WORKSPACE | |
make build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: packer-plugin-nutanix | |
path: packer-plugin-nutanix | |
retention-days: 7 | |
- name: build test list | |
id: test-list | |
run: echo "list=$(ls test/e2e | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT | |
e2e: | |
name: E2E test | |
needs: plugin-build | |
strategy: | |
matrix: | |
test: ${{fromJSON(needs.plugin-build.outputs.test-list)}} | |
runs-on: [self-hosted, nxlab, packer] | |
defaults: | |
run: | |
working-directory: test/e2e/${{ matrix.test}} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup `packer` | |
uses: hashicorp/setup-packer@main | |
id: setup-packer | |
- name: Setup `xorriso` | |
run: | | |
sudo apt update -y | |
sudo apt install -y xorriso | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packer-plugin-nutanix | |
path: /tmp | |
- name: Fix plugin permissions | |
run: | | |
chmod +x /tmp/packer-plugin-nutanix | |
- name: Install plugin | |
run: | | |
packer plugins install --path /tmp/packer-plugin-nutanix "github.com/nutanix-cloud-native/nutanix" | |
- name: Run `packer init` | |
id: init | |
run: | | |
packer init . | |
- name: Run `packer validate` | |
id: validate | |
run: packer validate -var "test=${{ matrix.test}}" . | |
env: | |
PACKER_LOG: ${{ github.event.inputs.logs }} | |
- name: Run `packer build` | |
id: build | |
run: packer build -var "test=${{ matrix.test}}" . | |
env: | |
PACKER_LOG: ${{ github.event.inputs.logs }} | |
results: | |
if: ${{ always() }} | |
runs-on: [self-hosted, nxlab, packer] | |
name: Final E2E results | |
needs: [e2e] | |
steps: | |
- run: | | |
result="${{ needs.e2e.result }}" | |
if [[ $result == "success" || $result == "skipped" ]]; then | |
exit 0 | |
else | |
exit 1 | |
fi |