-
Notifications
You must be signed in to change notification settings - Fork 510
146 lines (139 loc) · 4.1 KB
/
test.yml
File metadata and controls
146 lines (139 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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@v4
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
# 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
- name: Install Terraform
if: matrix.tf-binary == 'terraform'
uses: hashicorp/setup-terraform@v3
with:
terraform_version: latest
- name: Install OpenTofu
if: matrix.tf-binary == 'opentofu'
uses: opentofu/setup-opentofu@v1
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