Skip to content

ci: disable fail-fast, run tests on testdata changes (#33) #80

ci: disable fail-fast, run tests on testdata changes (#33)

ci: disable fail-fast, run tests on testdata changes (#33) #80

Workflow file for this run

name: Test
on:
pull_request:
branches:
- main
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'internal/provider/testdata/*.tf'
- '.github/workflows/test.yml'
push:
branches:
- main
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'internal/provider/testdata/*.tf'
- '.github/workflows/test.yml'
permissions:
contents: read
jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: latest
test:
name: Acceptance Tests
strategy:
matrix:
target:
- UpCloud
- Minio
- moto
cli:
- terraform
- tofu
fail-fast: false
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_wrapper: false
if: matrix.cli == 'terraform'
- uses: opentofu/setup-opentofu@592200bd4b9bbf4772ace78f887668b1aee8f716 # v1.0.5
with:
tofu_wrapper: false
if: matrix.cli == 'tofu'
- name: Set TF_ACC_* environment for OpenTofu
run: |
echo "TF_ACC_TERRAFORM_PATH=$(which tofu)" >> "$GITHUB_ENV"
echo "TF_ACC_PROVIDER_NAMESPACE=hashicorp" >> "$GITHUB_ENV"
echo "TF_ACC_PROVIDER_HOST=registry.opentofu.org" >> "$GITHUB_ENV"
if: matrix.cli == 'tofu'
- run: go mod download
- name: Test against UpCloud Managed Object Storage
env:
TF_ACC: "1"
TEST_TARGET: UpCloud
OBJSTO_ACCESS_KEY: ${{ secrets.UPCLOUD_ACCESS_KEY }}
OBJSTO_SECRET_KEY: ${{ secrets.UPCLOUD_SECRET_KEY }}
OBJSTO_ENDPOINT: ${{ secrets.UPCLOUD_ENDPOINT }}
OBJSTO_REGION: ${{ secrets.UPCLOUD_REGION }}
run: go test -v -cover ./internal/provider/
timeout-minutes: 10
if: matrix.target == 'UpCloud'
- name: Test against Minio
env:
TF_ACC: "1"
TEST_TARGET: Minio
OBJSTO_ACCESS_KEY: access_key
OBJSTO_SECRET_KEY: secret_key
OBJSTO_ENDPOINT: http://localhost:9000
OBJSTO_REGION: local-1
run: |
docker run -d -e MINIO_ROOT_USER=access_key -e MINIO_ROOT_PASSWORD=secret_key -e MINIO_BROWSER=off -p 9000:9000 minio/minio:RELEASE.2024-11-07T00-52-20Z server /data
go test -v -cover ./internal/provider/
timeout-minutes: 10
if: matrix.target == 'Minio'
- name: Test against moto
env:
TF_ACC: "1"
TEST_TARGET: moto
OBJSTO_ACCESS_KEY: access_key
OBJSTO_SECRET_KEY: secret_key
OBJSTO_ENDPOINT: http://localhost:5000
OBJSTO_REGION: us-east-1
run: |
docker run -d -e MOTO_DISABLE_GLOBAL_CORS=yes -e MOTO_S3_ALLOW_CROSSACCOUNT_ACCESS=false -e MOTO_IAM_LOAD_MANAGED_POLICIES=false -e MOTO_EC2_LOAD_DEFAULT_AMIS=false -p 5000:5000 motoserver/moto:5.0.28
go test -v -cover ./internal/provider/
timeout-minutes: 10
if: matrix.target == 'moto'