Skip to content

ci(test): grab Terraform versions dynamically #247

ci(test): grab Terraform versions dynamically

ci(test): grab Terraform versions dynamically #247

Workflow file for this run

name: Test
on:
pull_request:
paths-ignore:
- 'README.md'
push:
branches:
- main
paths-ignore:
- 'README.md'
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true
- run: go build -v .
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true
- uses: golangci/golangci-lint-action@v4
versions:
runs-on: ubuntu-latest
steps:
- name: Get Terraform versions
id: versions
run: |
echo "terraform=$(curl -sL https://releases.hashicorp.com/terraform/index.json | jq -c '[
.versions | keys | .[] |
{ version: ., semver: capture("(?<major>[0-9]+).(?<minor>[0-9]+).(?<patch>[0-9]+)(?<pre>.*)") } |
select(.semver.pre == "") |
{
version: .version,
group: (.semver.major + "." + .semver.minor),
major: .semver.major | tonumber,
minor: .semver.minor | tonumber,
patch: .semver.patch | tonumber
}
] | group_by(.group) | [ .[] | sort_by(.patch) | .[-1] | .version ] | sort | .[-2:]')" >> "$GITHUB_OUTPUT"
outputs:
terraform: ${{ steps.versions.outputs.terraform }}
test:
runs-on: ubuntu-latest
needs: versions
timeout-minutes: 15
strategy:
fail-fast: false
max-parallel: 1
matrix:
terraform: ${{ fromJSON(needs.versions.outputs.terraform) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true
- run: make testacc
env:
TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }}
OHDEAR_TOKEN: ${{ secrets.OHDEAR_TOKEN }}
OHDEAR_TEAM_ID: 6944