generated from hashicorp/terraform-provider-scaffolding-framework
-
Notifications
You must be signed in to change notification settings - Fork 4
120 lines (115 loc) · 3.92 KB
/
testacc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Terraform Provider testing workflow.
name: Acceptance Tests
on:
issue_comment:
types:
- created
paths-ignore:
- 'README.md'
push:
branches:
- main
- tests
paths-ignore:
- 'README.md'
# Testing only needs permissions to read the repository contents.
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v .
comment-triggered-testacc:
# This job runs on issue_comment event with /testacc command.
# We will block merging to main unless this job passes
# The reason we don't want to run this on every push is because it's expensive/creates real resources
if: github.event.issue.pull_request && contains(github.event.comment.body, '/testacc')
name: PR Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.7.*'
- '1.6.*'
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
- name: Set latest commit status as pending
uses: myrotvorets/set-commit-status-action@master
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
- name: Checkout PR branch
uses: actions/checkout@v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
ASTRO_API_TOKEN: ${{ secrets.DEV_ASTRO_API_TOKEN }}
ASTRO_API_HOST: ${{ secrets.DEV_ASTRO_API_HOST }}
ASTRO_ORGANIZATION_ID: ${{ secrets.DEV_ASTRO_ORGANIZATION_ID }}
run: make testacc
timeout-minutes: 10
- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
main-testacc:
# This job runs on push to main branch.
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Main Terraform Provider Acceptance Tests
needs: build
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.7.*'
- '1.6.*'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
ASTRO_API_TOKEN: ${{ secrets.DEV_ASTRO_API_TOKEN }}
ASTRO_API_HOST: ${{ secrets.DEV_ASTRO_API_HOST }}
ASTRO_ORGANIZATION_ID: ${{ secrets.DEV_ASTRO_ORGANIZATION_ID }}
run: make testacc
timeout-minutes: 10