-
Notifications
You must be signed in to change notification settings - Fork 6
175 lines (153 loc) · 5.87 KB
/
main.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
on:
schedule:
- cron: '0 19 * * 6'
workflow_dispatch:
inputs:
services:
type: string
required: false
default: 'ls-all'
description: name of the service to execute tests for (e.g. "ls-community", "ls-pro", "ls-all", "s3,iam,ec2")
enable-pro:
type: string
required: false
default: 'true'
description: determine if pro capabilities should be enabled
tinybird-reporting:
type: string
required: false
default: 'false'
description: determine whether results should be reported to tinybird
name: Terraform Tests
jobs:
prepare_list:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- id: set-matrix
run: echo "matrix=$(python -m terraform_pytest.get_services ${{ github.event.inputs.services || 'ls-all' }})" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
test_service:
needs: prepare_list
strategy:
max-parallel: 10
fail-fast: false
matrix:
service_partition: ${{ fromJson(needs.prepare_list.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-go@v3
with:
go-version: '1.20.x'
cache: true
cache-dependency-path: terraform-provider-aws/go.sum
- uses: actions/checkout@v3
if: ${{ (github.event.inputs.tinybird-reporting || 'true') == 'true' }}
with:
repository: tinybirdco/pytest-tinybird
path: pytest-tinybird
- name: Set up Python 3.10.5
uses: actions/setup-python@v4
with:
python-version: '3.10.5'
cache: 'pip'
- name: Install system dependencies
run: |
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
- name: Apply Terraform Plugin Sdk Patch
run: |
cd terraform-provider-aws
sdk_version=$(go list -m github.com/hashicorp/terraform-plugin-sdk/v2 | sed -n -e 's/^.* //p')
go mod edit --replace github.com/hashicorp/terraform-plugin-sdk/v2=github.com/localstack/terraform-plugin-sdk/v2@${sdk_version}
go mod tidy
- name: Patch Terraform Provider
run: |
source .venv/bin/activate
cd terraform-provider-aws && go mod vendor
cd ../
python -m terraform_pytest.main patch
- name: Build ${{ matrix.service_partition.service }} Binary
run: |
source .venv/bin/activate
python -m terraform_pytest.main build -s ${{ matrix.service_partition.service }}
ls -la ./test-bin
- name: Setup tinybird plugin
if: ${{ (github.event.inputs.tinybird-reporting || 'true') == 'true' }}
run: |
source .venv/bin/activate
cd pytest-tinybird
python setup.py install
- name: Setup LocalStack
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
TMP_USER: ${{ secrets.TMP_USER }}
TMP_PW: ${{ secrets.TMP_PW }}
run: |
source .venv/bin/activate
pip install --pre localstack
enable_pro=${{ inputs.enable-pro || 'true' }}
if [[ $enable_pro != 'true' ]]
then
docker pull localstack/localstack
else
docker pull localstack/localstack-pro
localstack auth login -u $TMP_USER -p $TMP_PW # login is currently required
localstack extensions init
localstack extensions install "git+https://github.com/localstack/localstack-moto-test-coverage/#egg=collect-raw-metric-data-extension&subdirectory=collect-raw-metric-data-extension"
fi
- name: Run ${{ matrix.service_partition.service }} - ${{ matrix.service_partition.partition }} Tests
env:
SERVICE: ${{ matrix.service_partition.service }}
PARTITION: ${{ matrix.service_partition.partition }}
TINYBIRD_URL: https://api.tinybird.co
TINYBIRD_DATASOURCE: localstack_terraform_test_results
TINYBIRD_TOKEN: ${{ secrets.TINYBIRD_TOKEN }}
CI_COMMIT_SHA: ${{ github.sha }}
CI_JOB_ID: ${{ github.job }}
CI_JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
CI_JOB_NAME: ${{ github.job }}-${{ matrix.service_partition.service }}-${{ matrix.service_partition.partition }}
run: |
source .venv/bin/activate
enable_pro=${{ inputs.enable-pro || 'true' }}
enable_tinybird=${{ inputs.tinybird-reporting || 'true' }}
if [[ $enable_pro == 'true' ]]
then
export LOCALSTACK_API_KEY=${{ secrets.LOCALSTACK_API_KEY }}
fi
if [[ $enable_tinybird == 'true' ]]
then
options="-s -v --ls-start --gather-metrics --report-to-tinybird"
else
options="-s -v --ls-start --gather-metrics"
fi
if [[ ${{ matrix.service_partition.service }} == "lambda" ]]
then
make prepare-lambda
fi
if [[ ${{ matrix.service_partition.partition }} == "All" ]]
then
python -m pytest --junitxml=target/reports/pytest.xml terraform-provider-aws/internal/service/${{ matrix.service_partition.service }} $options
else
python -m pytest --junitxml=target/reports/pytest.xml $(python terraform_pytest/get_tf_partitions.py ${{ matrix.service_partition.service }} ${{ matrix.service_partition.partition }} ) $options
fi
- name: Archive Test Result
uses: actions/upload-artifact@v3
if: always()
with:
name: test-metrics
path: target/reports
- name: Publish ${{ matrix.service }} Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
junit_files: target/reports/*.xml
check_name: ${{ matrix.service }} Terraform Test Results