-
Notifications
You must be signed in to change notification settings - Fork 393
150 lines (141 loc) · 5.44 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Run Tests
on:
pull_request:
branches:
- master
schedule:
- cron: "0 1 * * *"
push:
branches:
- mq-working-branch-master-**
concurrency:
group: ${{ github.head_ref || github.run_id }}-test
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
if: (github.event.action != 'closed' && github.event.pull_request.merged != true) || github.event_name == 'schedule'
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236
with:
python-version: '3.11'
- name: Install pre-commit
run: python -m pip install pre-commit
- name: set PY
run: echo "PY=$(python -c 'import platform;print(platform.python_version())')" >> $GITHUB_ENV
- uses: actions/cache@f4b3439a656ba812b8cb417d2d49f9c810103092
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always
linter-checks:
runs-on: ubuntu-latest
steps:
# if we don't do this, `gofmt` will want to rewrite all Go files due to bad line endings,
# because Git will convert all line endings to CRLF when cloning on windows
- name: Set Git to use Linux-style line endings
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
with:
go-version: "1.23"
cache: true
- name: Vet
run: make vet
- name: License Check
run: make license-check
- name: Check Docs Are Up To Date
run: make check-docs
test:
strategy:
matrix:
terraform_version:
- "0.14.11"
- "0.15.5"
- "1.1.2"
- "1.5.3"
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
with:
go-version: "1.23"
cache: true
- name: Setup terraform CLI
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1
with:
terraform_version: ${{ matrix.terraform_version }}
terraform_wrapper: false
- name: Set TF_ACC_TERRAFORM_PATH env var
run: echo "TF_ACC_TERRAFORM_PATH=$(which terraform)" >> $GITHUB_ENV
- name: Set regex for tests to run
shell: bash
run: |
test_re=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- datadog/*.go datadog/*/*.go datadog/internal/* go.mod go.sum | \
sed 's/.*_datadog_\(.*\).*.go/\1/' | sed 's/.*\/.*\/\(.*\).*.go/\1/' | \
sed -E 's+test|_++g' | \
sed -e "s/\(.*\)/\\(?i\\)\1/" | \
xargs | sed -e 's/ /|/g')
if [[ "$test_re" =~ go.mod|go.sum|provider ]] || [[ "${{ github.head_ref }}" = release/* ]] || [[ "${{ github.event_name }}" == "schedule" ]]; then
echo TESTARGS="-run \".*\"" >> $GITHUB_ENV
elif [[ ! -z "$test_re" ]]; then
echo TESTARGS="-run \"${test_re}\"" >> $GITHUB_ENV
fi
- name: Test
shell: bash
run: |
[[ -z "${TESTARGS}" ]] && echo "Skipping tests" || make testall
env:
RECORD: false
test-tofu:
runs-on: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
with:
go-version: "1.23"
cache: true
- uses: opentofu/setup-opentofu@592200bd4b9bbf4772ace78f887668b1aee8f716 # v1.0.5
with:
tofu_version: 1.6.3
tofu_wrapper: false
- name: Set Terraform env vars
run: |
echo "TF_ACC_TERRAFORM_PATH=$(which tofu)" >> $GITHUB_ENV
echo "TF_ACC_PROVIDER_HOST=registry.opentofu.org" >> $GITHUB_ENV
- name: Set regex for tests to run
shell: bash
run: |
test_re=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- datadog/*.go datadog/*/*.go datadog/internal/* go.mod go.sum | \
sed 's/.*_datadog_\(.*\).*.go/\1/' | sed 's/.*\/.*\/\(.*\).*.go/\1/' | \
sed -E 's+test|_++g' | \
sed -e "s/\(.*\)/\\(?i\\)\1/" | \
xargs | sed -e 's/ /|/g')
if [[ "$test_re" =~ go.mod|go.sum|provider ]] || [[ "${{ github.head_ref }}" = release/* ]] || [[ "${{ github.event_name }}" == "schedule" ]]; then
echo TESTARGS="-run \".*\"" >> $GITHUB_ENV
elif [[ ! -z "$test_re" ]]; then
echo TESTARGS="-run \"${test_re}\"" >> $GITHUB_ENV
fi
- name: Test
shell: bash
run: |
[[ -z "${TESTARGS}" ]] && echo "Skipping tests" || make testacc
env:
RECORD: false