-
Notifications
You must be signed in to change notification settings - Fork 24
126 lines (119 loc) · 3.98 KB
/
test.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
121
122
123
124
125
126
# Terraform Provider testing workflow.
name: Test
on:
pull_request:
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
- 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
generate:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
LAUNCHDARKLY_ACCESS_TOKEN: ${{ secrets.LAUNCHDARKLY_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- 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
env:
TF_ACC: "1"
LAUNCHDARKLY_ACCESS_TOKEN: ${{ secrets.LAUNCHDARKLY_ACCESS_TOKEN }}
strategy:
matrix:
test_case:
- TestAccDataSource
- TestAccAccessToken
- TestAccAuditLogSubscription
- TestAccCustomRole
- TestAccDestination
- TestAccEnvironment
- TestAccFeatureFlag_
- TestAccFeatureFlagEnvironment
- TestAccFlagTrigger
- TestAccMetric
- TestAccProject
- TestAccRelayProxy
- TestAccSegment
- TestAccTeamMember_CreateGeneric
- TestAccTeamMember_UpdateGeneric
- TestAccTeamMember_CreateWithCustomRole
- TestAccTeamMember_UpdateWithCustomRole
- TestAccTeam_
- TestAccTeamRoleMapping_
- TestAccWebhook
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: "1.21.3"
- 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