forked from microsoft/dbt-fabric
-
-
Notifications
You must be signed in to change notification settings - Fork 2
263 lines (230 loc) · 8.93 KB
/
integration-tests-de.yml
File metadata and controls
263 lines (230 loc) · 8.93 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
---
name: "DE integration tests"
on:
schedule:
- cron: '0 1 * * 0'
issue_comment:
types: [created]
workflow_dispatch:
inputs:
pytest_filter:
description: "Pytest -k filter expression (leave empty to run all DE tests)"
required: false
type: string
default: ""
pr_number:
description: "PR number to test (leave empty for current branch)"
required: false
type: string
default: ""
permissions:
contents: read
pull-requests: write
id-token: write
concurrency:
group: de-${{ github.event.issue.number || github.event.inputs.pr_number || 'main' }}
cancel-in-progress: true
jobs:
scheduled-de-tests:
name: DE tests (scheduled)
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
environment: azure
steps:
- name: Install mssql-python system dependencies
run: sudo apt-get update && sudo apt-get install -y libltdl7
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
- name: Install dependencies
run: uv sync --all-extras --all-groups
- name: Run DE integration tests
env:
FABRIC_TEST_AUTH: workload_identity
FABRIC_TEST_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
FABRIC_TEST_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
FABRIC_TEST_WORKSPACE_NAME: adapter-ci
FABRIC_TEST_LAKEHOUSE_NAME: cilh
FABRIC_TEST_LIVY_SESSION_NAME: ${{ github.run_id }}
FABRIC_TEST_THREADS: "4"
run: |
export FABRIC_TEST_FEDERATED_TOKEN_URL="${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=api://AzureADTokenExchange"
export FABRIC_TEST_FEDERATED_TOKEN_HEADER="bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}"
uv run pytest -ra -v --de
- name: Upload test logs
if: always()
uses: actions/upload-artifact@v7
with:
name: logs-de-scheduled
path: logs/
on-demand-de-tests:
name: DE tests (on-demand)
if: >-
(github.event_name == 'workflow_dispatch' && github.event.inputs.pr_number != '') ||
(github.event_name == 'issue_comment'
&& github.event.issue.pull_request
&& (github.event.comment.body == '/test-de' || startsWith(github.event.comment.body, '/test-de '))
&& contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association))
runs-on: ubuntu-latest
environment: azure
steps:
- name: Resolve PR metadata
id: pr
uses: actions/github-script@v9
env:
INPUT_PR_NUMBER: ${{ github.event.inputs.pr_number }}
with:
script: |
const prNumber = context.eventName === 'issue_comment'
? context.issue.number
: parseInt(process.env.INPUT_PR_NUMBER);
if (!prNumber) {
core.setFailed('No PR number provided');
return;
}
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
if (pr.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`) {
core.setFailed('Cannot run tests on PRs from forks');
return;
}
core.setOutput('number', prNumber);
core.setOutput('head_ref', pr.head.ref);
core.setOutput('head_sha', pr.head.sha);
- name: Parse pytest filter
id: filter
uses: actions/github-script@v9
env:
INPUT_PYTEST_FILTER: ${{ github.event.inputs.pytest_filter }}
with:
script: |
let rawFilter = '';
if (context.eventName === 'issue_comment') {
const body = context.payload.comment.body;
const match = body.match(/^\/test-de\s+(.*)/);
rawFilter = match ? match[1].split('\n')[0].trim() : '';
} else {
rawFilter = process.env.INPUT_PYTEST_FILTER || '';
}
const sanitized = rawFilter.replace(/[^a-zA-Z0-9 _()]/g, '');
core.setOutput('expression', sanitized);
core.setOutput('has_filter', sanitized.length > 0 ? 'true' : 'false');
core.info(`Pytest filter: ${sanitized || '(none — running all DE tests)'}`);
- name: Acknowledge comment
if: github.event_name == 'issue_comment'
uses: actions/github-script@v9
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket',
});
- name: Install mssql-python system dependencies
run: sudo apt-get update && sudo apt-get install -y libltdl7
- uses: actions/checkout@v6
with:
ref: ${{ steps.pr.outputs.head_sha }}
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
- name: Install dependencies
run: uv sync --all-extras --all-groups
- name: Run DE integration tests
id: tests
env:
FABRIC_TEST_AUTH: workload_identity
FABRIC_TEST_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
FABRIC_TEST_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
FABRIC_TEST_WORKSPACE_NAME: adapter-ci
FABRIC_TEST_LAKEHOUSE_NAME: cilh
FABRIC_TEST_LIVY_SESSION_NAME: ${{ github.run_id }}
FABRIC_TEST_THREADS: "4"
PYTEST_FILTER: ${{ steps.filter.outputs.expression }}
run: |
export FABRIC_TEST_FEDERATED_TOKEN_URL="${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=api://AzureADTokenExchange"
export FABRIC_TEST_FEDERATED_TOKEN_HEADER="bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}"
if [ -n "$PYTEST_FILTER" ]; then
uv run pytest -ra -v --de -k "$PYTEST_FILTER"
else
uv run pytest -ra -v --de
fi
- name: Upload test logs
if: always()
uses: actions/upload-artifact@v7
with:
name: logs-de-on-demand-${{ steps.pr.outputs.number }}
path: logs/
- name: Report results
if: always()
uses: actions/github-script@v9
env:
FILTER_EXPR: ${{ steps.filter.outputs.expression }}
TEST_OUTCOME: ${{ steps.tests.outcome }}
with:
script: |
const prNumber = ${{ steps.pr.outputs.number }};
const success = process.env.TEST_OUTCOME === 'success';
const filter = process.env.FILTER_EXPR || '(all DE tests)';
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const emoji = success ? ':white_check_mark:' : ':x:';
const status = success ? 'passed' : 'failed';
const body = [
`${emoji} **DE integration tests ${status}**`,
``,
`**Filter:** \`${filter}\``,
`**Run:** ${runUrl}`,
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
dispatch-de-tests:
name: DE tests (dispatch, no PR)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.pr_number == ''
runs-on: ubuntu-latest
environment: azure
steps:
- name: Install mssql-python system dependencies
run: sudo apt-get update && sudo apt-get install -y libltdl7
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
- name: Install dependencies
run: uv sync --all-extras --all-groups
- name: Run DE integration tests
env:
FABRIC_TEST_AUTH: workload_identity
FABRIC_TEST_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
FABRIC_TEST_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
FABRIC_TEST_WORKSPACE_NAME: adapter-ci
FABRIC_TEST_LAKEHOUSE_NAME: cilh
FABRIC_TEST_LIVY_SESSION_NAME: ${{ github.run_id }}
FABRIC_TEST_THREADS: "4"
PYTEST_FILTER: ${{ github.event.inputs.pytest_filter }}
run: |
export FABRIC_TEST_FEDERATED_TOKEN_URL="${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=api://AzureADTokenExchange"
export FABRIC_TEST_FEDERATED_TOKEN_HEADER="bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}"
if [ -n "$PYTEST_FILTER" ]; then
uv run pytest -ra -v --de -k "$PYTEST_FILTER"
else
uv run pytest -ra -v --de
fi
- name: Upload test logs
if: always()
uses: actions/upload-artifact@v7
with:
name: logs-de-dispatch
path: logs/