chore(deps): bump actions/upload-artifact from 4 to 7 (#1308) #535
This file contains hidden or 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: Build and Test | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - '*.md' | |
| - 'docs/*' | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '*.md' | |
| - 'docs/*' | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go-version: ["1.26.x"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Generate code | |
| run: make generate | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v7 | |
| with: | |
| version: v2.10.1 | |
| only-new-issues: true | |
| build: | |
| name: Build | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - {os: ubuntu-latest, go: 1.26} | |
| - {os: windows-latest, go: 1.26} | |
| - {os: macos-latest, go: 1.26} | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go }} | |
| id: go | |
| - name: Build | |
| run: | | |
| make build | |
| - name: Test | |
| run: | | |
| make test | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: terraform-provider-libvirt-${{ matrix.os }} | |
| path: ${{ github.workspace }}/terraform-provider-libvirt* | |
| acceptance: | |
| name: Acceptance Tests (${{ matrix.tf-binary }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| tf-binary: [terraform, opentofu] | |
| go-version: ["1.26.x"] | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Install libvirt and QEMU | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| qemu-system-x86 \ | |
| qemu-utils \ | |
| libvirt-daemon-system \ | |
| libvirt-clients \ | |
| libvirt-dev | |
| - name: Start libvirtd and configure permissions | |
| run: | | |
| sudo systemctl start libvirtd | |
| sudo systemctl status libvirtd | |
| # Normalize qemu runtime user on ephemeral runners to avoid storage DAC | |
| # mismatches (qemu uid cannot read newly created volume files). | |
| sudo sed -i 's/^#\?user = .*/user = "root"/' /etc/libvirt/qemu.conf | |
| sudo sed -i 's/^#\?group = .*/group = "root"/' /etc/libvirt/qemu.conf | |
| sudo sed -i 's/^#\?dynamic_ownership = .*/dynamic_ownership = 0/' /etc/libvirt/qemu.conf | |
| # Disable AppArmor confinement for QEMU so that VMs can access | |
| # volumes in non-default pool paths during acceptance tests. | |
| echo 'security_driver = "none"' | sudo tee -a /etc/libvirt/qemu.conf | |
| sudo systemctl restart libvirtd | |
| # Add runner to libvirt group | |
| sudo usermod -a -G libvirt runner | |
| # Change socket permissions to allow group access | |
| sudo chmod 666 /var/run/libvirt/libvirt-sock | |
| # Ensure default storage path is traversable by dynamically labeled qemu UIDs. | |
| sudo mkdir -p /var/lib/libvirt/images | |
| sudo chmod 1777 /var/lib/libvirt/images | |
| # Ensure default pool exists and is active in this ephemeral runner. | |
| if ! virsh -c qemu:///system pool-info default >/dev/null 2>&1; then | |
| virsh -c qemu:///system pool-define-as --name default --type dir --target /var/lib/libvirt/images | |
| fi | |
| virsh -c qemu:///system pool-start default || true | |
| virsh -c qemu:///system pool-autostart default || true | |
| - name: Install Terraform | |
| if: matrix.tf-binary == 'terraform' | |
| uses: hashicorp/setup-terraform@v4 | |
| with: | |
| terraform_version: latest | |
| - name: Install OpenTofu | |
| if: matrix.tf-binary == 'opentofu' | |
| uses: opentofu/setup-opentofu@v2 | |
| with: | |
| tofu_version: latest | |
| - name: Cache acceptance test images | |
| uses: actions/cache@v4 | |
| with: | |
| path: .cache/test-images | |
| key: ${{ runner.os }}-acc-images-alpine-3.23.3-r0 | |
| - name: Prepare Tiny Linux test image | |
| run: | | |
| make testdeps-acc-tinylinux | |
| - name: Run Acceptance Tests | |
| env: | |
| TF_ACC: "1" | |
| TF_PROVIDER_LIBVIRT_DOMAIN_TYPE: "qemu" | |
| TF_ACC_PROVIDER_NAMESPACE: "dmacvicar" | |
| TF_ACC_PROVIDER_HOST: "registry.terraform.io" | |
| run: | | |
| # Get absolute path to terraform/tofu binary | |
| if [ "${{ matrix.tf-binary }}" = "opentofu" ]; then | |
| export TF_ACC_TERRAFORM_PATH=$(which tofu) | |
| else | |
| export TF_ACC_TERRAFORM_PATH=$(which terraform) | |
| fi | |
| ACPI_IMAGE="$PWD/.cache/test-images/alpine-3.23.3-x86_64-bios-tiny-r0.qcow2" | |
| if [ -f "$ACPI_IMAGE" ]; then | |
| export LIBVIRT_TEST_ACPI_IMAGE="$ACPI_IMAGE" | |
| fi | |
| echo "Using Terraform CLI at: $TF_ACC_TERRAFORM_PATH" | |
| if [ -n "${LIBVIRT_TEST_ACPI_IMAGE:-}" ]; then | |
| echo "Using ACPI test image: $LIBVIRT_TEST_ACPI_IMAGE" | |
| else | |
| echo "LIBVIRT_TEST_ACPI_IMAGE not set; image-gated ACPI shutdown test will be skipped." | |
| fi | |
| make testacc | |
| - name: Debug Libvirt/QEMU Storage Access | |
| if: always() | |
| run: | | |
| echo "=== qemu.conf ===" | |
| sudo grep -E '^(user|group|dynamic_ownership)[[:space:]]*=' /etc/libvirt/qemu.conf || true | |
| echo | |
| echo "=== libvirt daemon status ===" | |
| sudo systemctl status libvirtd --no-pager || true | |
| echo | |
| echo "=== qemu processes ===" | |
| ps -ef | grep -E '[q]emu-system|[l]ibvirtd|[v]irtqemud' || true | |
| echo | |
| echo "=== default pool info ===" | |
| virsh -c qemu:///system pool-info default || true | |
| virsh -c qemu:///system pool-dumpxml default || true | |
| echo | |
| echo "=== images dir permissions ===" | |
| ls -ld /var/lib/libvirt/images || true | |
| stat -c '%a %U:%G %n' /var/lib/libvirt/images || true | |
| echo | |
| echo "=== test volume file permissions ===" | |
| ls -l /var/lib/libvirt/images/test-volume-shutdown-image.qcow2 || true | |
| stat -c '%a %U:%G %n' /var/lib/libvirt/images/test-volume-shutdown-image.qcow2 || true |