Skip to content

Commit

Permalink
Add OpenTofu to test matrix
Browse files Browse the repository at this point in the history
OpenTofu, a community fork of Terraform, has yet to be released as
stable, but an alpha version is available. Let's add it to the test
matrix.

You also need to set the environment variable TFMIGRATE_EXEC_PATH to
tofu.
  • Loading branch information
minamijoyo committed Oct 26, 2023
1 parent 087694f commit 8b44751
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ jobs:
go-version-file: '.go-version'
- name: test
run: make test
testacc:
testacc_terraform:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
terraform:
- 1.6.0
- 1.6.2
- 1.5.7
- 1.4.7
- 0.12.31
Expand All @@ -58,3 +58,27 @@ jobs:
run: docker-compose run --rm tfmigrate terraform --version
- name: testacc
run: docker-compose run --rm tfmigrate make testacc
testacc_opentofu:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
opentofu:
- 1.6.0-alpha3
env:
OPENTOFU_VERSION: ${{ matrix.opentofu }}
TFMIGRATE_EXEC_PATH: tofu
steps:
- uses: actions/checkout@v4
- name: docker build
run: docker-compose build
- name: start localstack
run: |
docker-compose up -d localstack
docker-compose run --rm dockerize -wait tcp://localstack:4566 -timeout 60s
docker-compose exec -T localstack /etc/localstack/init/wait_s3_bucket_exists.sh
- name: tofu --version
run: docker-compose run --rm tfmigrate tofu --version
- name: testacc
run: docker-compose run --rm tfmigrate make testacc
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
ARG TERRAFORM_VERSION=latest
ARG OPENTOFU_VERSION=latest

FROM hashicorp/terraform:$TERRAFORM_VERSION AS terraform
FROM ghcr.io/opentofu/opentofu:$OPENTOFU_VERSION AS opentofu

FROM golang:1.21-alpine3.18
RUN apk --no-cache add make git bash
COPY --from=terraform /bin/terraform /usr/local/bin/
COPY --from=opentofu /usr/local/bin/tofu /usr/local/bin/
WORKDIR /work

COPY go.mod go.sum ./
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
context: .
args:
TERRAFORM_VERSION: ${TERRAFORM_VERSION:-latest}
OPENTOFU_VERSION: ${OPENTOFU_VERSION:-latest}
volumes:
- ".:/work"
environment:
Expand All @@ -19,6 +20,8 @@ services:
# it appears that localstack sometimes misses API requests when run in parallel.
TF_CLI_ARGS_apply: "--parallelism=1"
TERRAFORM_VERSION: ${TERRAFORM_VERSION:-latest}
OPENTOFU_VERSION: ${OPENTOFU_VERSION:-latest}
TFMIGRATE_EXEC_PATH:
depends_on:
- localstack
- fake-gcs-server
Expand Down

0 comments on commit 8b44751

Please sign in to comment.