-
Notifications
You must be signed in to change notification settings - Fork 29
166 lines (159 loc) · 5.9 KB
/
test.yml
File metadata and controls
166 lines (159 loc) · 5.9 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Terraform Provider testing workflow.
name: Test
on:
pull_request: # this is for external contributions/forks. we have a check in place to ensure an LD user explicitly allows the tests to run for forks.
push:
branches: [main]
schedule: # runs tests once a day on the main branch
- cron: "0 0 * * *"
# Testing only needs permissions to read the repository contents.
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha || github.sha}}
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
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: v1.64.8
install-mode: goinstall
generate:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: aws-actions/configure-aws-credentials@f24d7193d98baebaeacc7e2227925dd47cc267f5 # v4.2.0
with:
audience: https://github.com/launchdarkly
aws-region: us-east-1
role-to-assume: arn:aws:iam::061661829416:role/github-actions-terraform-provider-launchdarkly
role-session-name: GitHubActionsGenerate_run-${{ github.run_id }}
- id: get-launchdarkly-access-token
uses: dkershner6/aws-ssm-getparameters-action@4fcb4872421f387a6c43058473acc1b22443fe13 # v2.0.3
with:
parameterPairs: |
/global/services/github/terraform-provider/launchdarkly-access-token = LAUNCHDARKLY_ACCESS_TOKEN
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: "go.mod"
cache: true
# We need the latest version of Terraform for our documentation generation to use
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_wrapper: false
- run: make generate
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'make generate' command and commit."; exit 1)
# Run acceptance tests in a matrix with Terraform CLI versions
test:
name: Acceptance Tests
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
id-token: write
contents: read
env:
TF_ACC: "1"
strategy:
matrix:
test_case:
- TestAccAIConfig_
- TestAccAIConfigVariation
- TestAccAITool
- TestAccDataSource
- TestAccAccessToken
- TestAccAuditLogSubscription
- TestAccCustomRole
- TestAccDestination
- TestAccEnvironment
- TestAccFeatureFlag_
- TestAccFeatureFlagEnvironment
- TestAccFlagTemplates
- TestAccFlagTrigger
- TestAccMetric
- TestAccModelConfig
- TestAccProject
- TestAccRelayProxy
- TestAccSegment
- TestAccTeamMember_CreateGeneric
- TestAccTeamMember_UpdateGeneric
- TestAccTeamMember_CreateWithCustomRole
- TestAccTeamMember_UpdateWithCustomRole
- TestAccTeam_
- TestAccTeamRoleMapping_
- TestAccView
- TestAccWebhook
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: aws-actions/configure-aws-credentials@f24d7193d98baebaeacc7e2227925dd47cc267f5 # v4.2.0
with:
audience: https://github.com/launchdarkly
aws-region: us-east-1
role-to-assume: arn:aws:iam::061661829416:role/github-actions-terraform-provider-launchdarkly
role-session-name: GitHubActionsTest_run-${{ github.run_id }}
- id: get-launchdarkly-access-token
uses: dkershner6/aws-ssm-getparameters-action@4fcb4872421f387a6c43058473acc1b22443fe13 # v2.0.3
with:
parameterPairs: |
/global/services/github/terraform-provider/launchdarkly-access-token = LAUNCHDARKLY_ACCESS_TOKEN
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: "go.mod"
- run: go mod download
- name: Run Test
run: |
echo "Running test case: ${{ matrix.test_case }}"
TESTARGS="-run ${{ matrix.test_case }}" make testacc-with-retry
check-success:
name: Check Success
needs:
- build
- generate
- test
if: always()
runs-on: ubuntu-latest
steps:
- name: Evaluate results
run: |
if printf '${{ toJSON(needs) }}' | grep --quiet --extended-regexp --ignore-case '"result": "(failure|cancelled)"'; then
printf "Tests failed or workflow cancelled:\n\n${{ toJSON(needs) }}"
exit 1
fi
notify-slack-on-failure:
name: Notify Slack on Failures
if: failure() && github.ref == 'refs/heads/main'
needs:
- build
- generate
- test
runs-on: ubuntu-latest
steps:
- name: Send GitHub trigger payload to Slack Workflow Builder
id: slack
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
with:
payload-delimiter: "_"
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger