mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-07-26 07:58:14 +00:00
f21c7f84b7
- Replace tests/infrastructure/Dockerfile with tests/Dockerfile.test (single multi-stage Dockerfile for both CI and local dev) - CI container-image job now builds from Dockerfile.test target dev-infra - Add ARM support: PowerShell installed via dotnet tool on arm64, APT package on amd64 - Replace tests/dev.sh (bash) with tests/dev.ps1 (PowerShell) for cross-platform support (Windows, macOS, Linux) - Add -DockerHost parameter for running x86 containers on a remote Docker host from ARM Macs (rsyncs repo, uses SSH Docker transport) - Add -NoCleanup switch to keep nested PVE VMs after integration tests - integration command now provisions nested PVE VMs instead of testing against a pre-existing PVE directly - Share /opt/pve-isos host path between CI and local dev (was separate Docker named volume) - Delete tools/Invoke-Tests.ps1 (unused, overlapped with run-integration.sh) - Add .gitignore entries for Terraform state/artifacts - Update all documentation references Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
217 lines
7.5 KiB
YAML
217 lines
7.5 KiB
YAML
name: Integration Tests
|
|
|
|
# Real integration tests against a live Proxmox VE instance.
|
|
#
|
|
# Architecture:
|
|
# build → GitHub-hosted, dotnet publish → upload artifact
|
|
# container-image → GitHub-hosted, build+push Docker image to GHCR
|
|
# provision → self-hosted, provisions ALL nested PVE VMs via run-integration.sh
|
|
# test → self-hosted, runs Pester tests via run-integration.sh
|
|
# cleanup → self-hosted, tears down all VMs via run-integration.sh (always runs)
|
|
# cleanup-images → GitHub-hosted, prunes old GHCR container images
|
|
#
|
|
# The provision/test/cleanup logic lives in tests/infrastructure/scripts/run-integration.sh
|
|
# which is the single source of truth shared between CI and local dev containers.
|
|
#
|
|
# Required repository secrets (for provisioning):
|
|
# PVE_ENDPOINT - Parent PVE API URL (e.g. https://pve.example.com:8006)
|
|
# PVE_API_TOKEN - Parent PVE API token (for Terraform + uploads)
|
|
# PVE_TEST_PASSWORD - Root password for nested PVE instances
|
|
#
|
|
# Required repository variables:
|
|
# PVE_TARGET_NODE - Parent PVE node name (variable, not secret, to avoid log masking)
|
|
#
|
|
# Optional secrets (for skip_provision mode):
|
|
# PVETEST_HOST - Hostname or IP of a pre-existing nested PVE
|
|
# PVETEST_APITOKEN - API token for the pre-existing nested PVE
|
|
#
|
|
# WARNING: Integration tests create and destroy real resources on the target
|
|
# node. Never run against production.
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
# NOTE: pull_request trigger intentionally removed. Integration tests
|
|
# run on a self-hosted runner with access to secrets and a live PVE
|
|
# node. Fork PRs must not execute code on that runner. Integration
|
|
# tests run automatically on push to main after merge.
|
|
workflow_dispatch:
|
|
inputs:
|
|
skip_provision:
|
|
description: 'Skip provisioning (use existing PVE from PVETEST_HOST secret)'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
env:
|
|
SCRIPTS_DIR: tests/infrastructure/scripts
|
|
TEST_IMAGE: ghcr.io/goodolclint/psproxmoxve-integration
|
|
CACHE_DIR: /opt/pve-isos
|
|
|
|
jobs:
|
|
# ── Build module artifact (GitHub-hosted) ────────────────────────────
|
|
build:
|
|
if: github.actor != 'dependabot[bot]'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v5
|
|
with:
|
|
dotnet-version: '10.0.x'
|
|
|
|
- name: Build module
|
|
run: dotnet publish src/PSProxmoxVE/PSProxmoxVE.csproj --configuration Release --framework netstandard2.0 --output ./publish/netstandard2.0
|
|
|
|
- name: Clean publish output
|
|
run: rm -f ./publish/netstandard2.0/*.deps.json
|
|
|
|
- name: Upload module artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: module-integration
|
|
path: ./publish/netstandard2.0/
|
|
|
|
# ── Build test container image (GitHub-hosted) ───────────────────────
|
|
container-image:
|
|
if: github.actor != 'dependabot[bot]'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
file: tests/Dockerfile.test
|
|
target: dev-infra
|
|
push: true
|
|
tags: ${{ env.TEST_IMAGE }}:${{ github.sha }},${{ env.TEST_IMAGE }}:latest
|
|
|
|
# ── Provision all nested PVE VMs (self-hosted) ──────────────────────
|
|
provision:
|
|
if: inputs.skip_provision != true
|
|
needs: [build, container-image]
|
|
runs-on: [self-hosted, proxmox, integration]
|
|
timeout-minutes: 30
|
|
container:
|
|
image: ghcr.io/goodolclint/psproxmoxve-integration:${{ github.sha }}
|
|
credentials:
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
volumes:
|
|
- /opt/pve-isos:/opt/pve-isos
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Provision PVE instances
|
|
shell: bash
|
|
env:
|
|
PVE_ENDPOINT: ${{ secrets.PVE_ENDPOINT }}
|
|
PVE_API_TOKEN: ${{ secrets.PVE_API_TOKEN }}
|
|
PVE_TARGET_NODE: ${{ vars.PVE_TARGET_NODE }}
|
|
PVE_PASSWORD: ${{ secrets.PVE_TEST_PASSWORD }}
|
|
run: bash ${SCRIPTS_DIR}/run-integration.sh provision
|
|
|
|
# ── Integration tests (self-hosted, per PVE version) ────────────────
|
|
test:
|
|
needs: [build, provision]
|
|
runs-on: [self-hosted, proxmox, integration]
|
|
timeout-minutes: 20
|
|
container:
|
|
image: ghcr.io/goodolclint/psproxmoxve-integration:${{ github.sha }}
|
|
credentials:
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
volumes:
|
|
- /opt/pve-isos:/opt/pve-isos
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 2
|
|
matrix:
|
|
pve_version: ['9', '8']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Download module artifact
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: module-integration
|
|
path: ./publish/netstandard2.0/
|
|
|
|
- name: Run integration tests (PVE ${{ matrix.pve_version }})
|
|
shell: bash
|
|
env:
|
|
PVE_PASSWORD: ${{ secrets.PVE_TEST_PASSWORD }}
|
|
MODULE_ARTIFACT: ./publish/netstandard2.0
|
|
SKIP_PROVISION: ${{ inputs.skip_provision || 'false' }}
|
|
PVETEST_HOST: ${{ secrets.PVETEST_HOST }}
|
|
PVETEST_APITOKEN: ${{ secrets.PVETEST_APITOKEN }}
|
|
run: bash ${SCRIPTS_DIR}/run-integration.sh test ${{ matrix.pve_version }}
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: integration-test-results-pve${{ matrix.pve_version }}
|
|
path: TestResults/
|
|
|
|
# ── Cleanup: destroy all VMs (always runs) ──────────────────────────
|
|
cleanup:
|
|
needs: [provision, test]
|
|
if: always() && needs.provision.result != 'skipped' && github.actor != 'dependabot[bot]'
|
|
runs-on: [self-hosted, proxmox, integration]
|
|
timeout-minutes: 15
|
|
container:
|
|
image: ghcr.io/goodolclint/psproxmoxve-integration:${{ github.sha }}
|
|
credentials:
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
volumes:
|
|
- /opt/pve-isos:/opt/pve-isos
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Cleanup PVE instances
|
|
shell: bash
|
|
env:
|
|
PVE_ENDPOINT: ${{ secrets.PVE_ENDPOINT }}
|
|
PVE_API_TOKEN: ${{ secrets.PVE_API_TOKEN }}
|
|
PVE_TARGET_NODE: ${{ vars.PVE_TARGET_NODE }}
|
|
run: bash ${SCRIPTS_DIR}/run-integration.sh cleanup
|
|
|
|
# ── Clean up old container images from GHCR ──────────────────────────
|
|
cleanup-images:
|
|
needs: test
|
|
if: always() && github.actor != 'dependabot[bot]'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
steps:
|
|
- name: Delete old container image versions
|
|
uses: actions/delete-package-versions@v5
|
|
with:
|
|
package-name: psproxmoxve-integration
|
|
package-type: container
|
|
min-versions-to-keep: 3
|
|
delete-only-untagged-versions: false
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|