forked from DavidKrau/terraform-provider-simplemdm
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (116 loc) · 4.37 KB
/
test.yml
File metadata and controls
121 lines (116 loc) · 4.37 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
# Terraform Provider testing workflow.
name: Tests
# This GitHub action runs tests for each pull request and push.
on:
pull_request:
paths-ignore:
- 'README.md'
push:
paths-ignore:
- 'README.md'
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@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v ./...
- name: Run linters
uses: golangci/golangci-lint-action@v6
with:
version: latest
generate:
name: Generate Docs
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- run: go generate ./...
- name: Check for changes
id: git-check
run: |
git diff --compact-summary --exit-code || echo "has_changes=true" >> $GITHUB_OUTPUT
- name: Commit and push changes (push events)
if: steps.git-check.outputs.has_changes == 'true' && github.event_name == 'push'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -A
git commit -m "docs: Auto-generate documentation from schema changes"
git push
- name: Fail on uncommitted changes (pull requests)
if: steps.git-check.outputs.has_changes == 'true' && github.event_name == 'pull_request'
run: |
echo "Unexpected difference in directories after code generation."
echo "Run 'go generate ./...' command and commit the changes."
git diff --compact-summary
exit 1
# Run acceptance tests in a matrix with Terraform CLI versions.
# Tests require TF_ACC=1 and SIMPLEMDM_APIKEY to run; without them,
# acceptance tests are automatically skipped while unit/coverage tests run.
test:
name: Terraform Provider Tests (${{ matrix.terraform }})
needs: build
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
terraform:
- '1.8.*'
- '1.9.*'
- '1.10.*'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- name: Run tests
env:
TF_ACC: "1"
SIMPLEMDM_APIKEY: ${{ secrets.SIMPLEMDM_APIKEY }}
# Fixture IDs for data source tests
SIMPLEMDM_APP_ID: ${{ secrets.SIMPLEMDM_APP_ID }}
SIMPLEMDM_ASSIGNMENT_GROUP_ID: ${{ secrets.SIMPLEMDM_ASSIGNMENT_GROUP_ID }}
SIMPLEMDM_ATTRIBUTE_NAME: ${{ secrets.SIMPLEMDM_ATTRIBUTE_NAME }}
SIMPLEMDM_CUSTOM_PROFILE_ID: ${{ secrets.SIMPLEMDM_CUSTOM_PROFILE_ID }}
SIMPLEMDM_CUSTOM_DECLARATION_ID: ${{ secrets.SIMPLEMDM_CUSTOM_DECLARATION_ID }}
SIMPLEMDM_DEVICE_GROUP_ID: ${{ secrets.SIMPLEMDM_DEVICE_GROUP_ID }}
SIMPLEMDM_DEVICE_ID: ${{ secrets.SIMPLEMDM_DEVICE_ID }}
SIMPLEMDM_ENROLLMENT_ID: ${{ secrets.SIMPLEMDM_ENROLLMENT_ID }}
SIMPLEMDM_PROFILE_ID: ${{ secrets.SIMPLEMDM_PROFILE_ID }}
SIMPLEMDM_SCRIPT_ID: ${{ secrets.SIMPLEMDM_SCRIPT_ID }}
SIMPLEMDM_SCRIPT_JOB_ID: ${{ secrets.SIMPLEMDM_SCRIPT_JOB_ID }}
SIMPLEMDM_MANAGED_APP_ID: ${{ secrets.SIMPLEMDM_MANAGED_APP_ID }}
# Fixture IDs for resource tests
SIMPLEMDM_DEVICE_GROUP_CLONE_SOURCE_ID: ${{ secrets.SIMPLEMDM_DEVICE_GROUP_CLONE_SOURCE_ID }}
SIMPLEMDM_ENROLLMENT_CONTACT: ${{ secrets.SIMPLEMDM_ENROLLMENT_CONTACT }}
SIMPLEMDM_CUSTOM_DECLARATION_DEVICE_ID: ${{ secrets.SIMPLEMDM_CUSTOM_DECLARATION_DEVICE_ID }}
SIMPLEMDM_DEP_SERVER_ID: ${{ secrets.SIMPLEMDM_DEP_SERVER_ID }}
run: go test -v -cover ./provider/... ./internal/...
timeout-minutes: 20