Skip to content

Tests

Tests #9

Workflow file for this run

# Terraform Provider testing workflow.
name: Tests
on:
pull_request:
paths-ignore:
- 'README.md'
push:
paths-ignore:
- 'README.md'
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v -o terraform-provider-ona .
- name: Run linters
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: latest
test:
name: Unit Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go test -v -cover ./...
integration:
name: Integration Test
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GITPOD_API_KEY: ${{ secrets.GITPOD_API_KEY }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
with:
terraform_version: '1.14.*'
terraform_wrapper: false
- name: Build provider
run: go build -o terraform-provider-ona .
- name: Setup dev overrides
run: |
cat > ~/.terraformrc << EOF
provider_installation {
dev_overrides {
"combor/ona" = "${{ github.workspace }}"
}
direct {}
}
EOF
- name: Terraform Apply
working-directory: examples
run: |
terraform apply -auto-approve \
-var="runner_name=tf-ci-${{ github.run_id }}" \
-var="runner_provider_type=RUNNER_PROVIDER_MANAGED" \
-var="runner_manager_id=01984227-2946-7e40-a982-2f427741f5da" \
-var="runner_region=eu-central-1"
- name: Terraform Destroy
if: always()
working-directory: examples
run: |
terraform destroy -auto-approve \
-var="runner_name=tf-ci-${{ github.run_id }}" \
-var="runner_provider_type=RUNNER_PROVIDER_MANAGED" \
-var="runner_manager_id=01984227-2946-7e40-a982-2f427741f5da" \
-var="runner_region=eu-central-1"