Skip to content

Commit 7454994

Browse files
committed
ci: add support to test OpenTofu
1 parent 791929a commit 7454994

File tree

1 file changed

+136
-1
lines changed

1 file changed

+136
-1
lines changed

.github/workflows/acceptance-tests.yaml

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
merge_group:
99

1010
jobs:
11-
tests:
11+
terraform:
1212
strategy:
1313
fail-fast: false
1414
matrix:
@@ -164,3 +164,138 @@ jobs:
164164
TF_TEST_DOMAIN_ZONE: tf
165165
SCW_DEBUG: 0
166166
SCW_ENABLE_BETA: true
167+
opentofu:
168+
strategy:
169+
fail-fast: false
170+
matrix:
171+
products:
172+
- account
173+
- applesilicon
174+
- az
175+
- baremetal
176+
- billing
177+
- block
178+
- cockpit
179+
- container
180+
- domain
181+
- file
182+
- flexibleip
183+
- function
184+
- iam
185+
- instance
186+
- inference
187+
- iot
188+
- ipam
189+
- jobs
190+
- k8s
191+
- lb
192+
- marketplace
193+
- mnq
194+
- mongodb
195+
- object
196+
- rdb
197+
- redis
198+
- registry
199+
- sdb
200+
- secret
201+
- tem
202+
- vpc
203+
- vpcgw
204+
- webhosting
205+
runs-on: ubuntu-latest
206+
steps:
207+
# Checkout should always be before setup-go to ensure caching is working
208+
- name: Checkout
209+
uses: actions/checkout@v5
210+
- name: Install OpenTofu
211+
uses: opentofu/setup-opentofu@v1
212+
- name: Install Go
213+
uses: actions/setup-go@v6
214+
with:
215+
go-version: stable
216+
# This CI supports skipping flaky or broken tests via GitHub repository variables.
217+
# This allows quick fixes without code changes when tests break due to external factors.
218+
#
219+
# HOW TO SKIP TESTS:
220+
# 1. Go to: Settings → Secrets and variables → Actions → Variables
221+
# 2. Create or edit Repository variables:
222+
# - SKIP_TESTS_<PRODUCT>: Skip patterns for any product (uppercase)
223+
# - SKIP_TESTS_ALL: Skip patterns applied to ALL products
224+
#
225+
# PATTERN SYNTAX:
226+
# - Single test: TestAccServer_Basic
227+
# - Multiple tests: TestAccServer_Basic|TestAccServer_Other
228+
# - Wildcard: TestAccServer.*
229+
# - Contains: .*IPAM.*
230+
#
231+
# EXAMPLE:
232+
# Variable: SKIP_TESTS_BAREMETAL
233+
# Value: TestAccServer_Basic|TestAccServer_WithIPAMPrivateNetwork
234+
- name: Determine Skip Pattern
235+
id: skip-config
236+
run: |
237+
PRODUCT="${{ matrix.products }}"
238+
SKIP_PATTERN=""
239+
240+
case "$PRODUCT" in
241+
baremetal)
242+
SKIP_PATTERN="$SKIP_TESTS_BAREMETAL"
243+
;;
244+
esac
245+
246+
if [ -n "$SKIP_TESTS_ALL" ]; then
247+
if [ -n "$SKIP_PATTERN" ]; then
248+
SKIP_PATTERN="${SKIP_PATTERN}|${SKIP_TESTS_ALL}"
249+
else
250+
SKIP_PATTERN="$SKIP_TESTS_ALL"
251+
fi
252+
fi
253+
254+
echo "skip_pattern=$SKIP_PATTERN" >> $GITHUB_OUTPUT
255+
env:
256+
SKIP_TESTS_BAREMETAL: ${{ vars.SKIP_TESTS_BAREMETAL }}
257+
SKIP_TESTS_ALL: ${{ vars.SKIP_TESTS_ALL }}
258+
- name: Run Acceptance Tests
259+
run: |
260+
SKIP_PATTERN="${{ steps.skip-config.outputs.skip_pattern }}"
261+
262+
if [ -n "$SKIP_PATTERN" ]; then
263+
echo ""
264+
echo "SKIPPING TESTS"
265+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
266+
echo "Pattern: $SKIP_PATTERN"
267+
echo ""
268+
echo "Tests that will be skipped:"
269+
go tool gotestsum --format github-actions -- -list=. ./internal/services/${{ matrix.products }} | grep -E "$SKIP_PATTERN" || true
270+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
271+
echo ""
272+
273+
go tool gotestsum --format github-actions -- -v ./internal/services/${{ matrix.products }} -timeout=2h -skip="$SKIP_PATTERN"
274+
TEST_RESULT=$?
275+
else
276+
go tool gotestsum --format github-actions -- -v ./internal/services/${{ matrix.products }} -timeout=2h
277+
TEST_RESULT=$?
278+
fi
279+
280+
if [ -n "$SKIP_PATTERN" ]; then
281+
echo ""
282+
echo "CI Skip Configuration:"
283+
echo "Pattern: $SKIP_PATTERN"
284+
echo "To modify: Update SKIP_TESTS_$(echo ${{ matrix.products }} | tr '[:lower:]' '[:upper:]') in GitHub repository variables"
285+
fi
286+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
287+
288+
exit $TEST_RESULT
289+
env:
290+
TF_ACC_TERRAFORM_PATH: tofu
291+
TF_ACC_PROVIDER_NAMESPACE: hashicorp
292+
TF_ACC_PROVIDER_HOST: registry.opentofu.org
293+
TF_LOG: DEBUG
294+
TF_ACC: 1
295+
TF_UPDATE_CASSETTES: false
296+
TF_TEST_DOMAIN: scaleway-terraform.com
297+
TF_TEST_DOMAIN_ZONE: tf
298+
SCW_DEBUG: 0
299+
SCW_ACCESS_KEY: "SCWXXXXXXXXXXXXXFAKE"
300+
SCW_SECRET_KEY: "11111111-1111-1111-1111-111111111111"
301+
SCW_ENABLE_BETA: true

0 commit comments

Comments
 (0)