-
Notifications
You must be signed in to change notification settings - Fork 308
249 lines (217 loc) · 8.87 KB
/
Copy pathe2e-test-same-tenant.yml
File metadata and controls
249 lines (217 loc) · 8.87 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
name: E2E Test - Same Tenant
# This workflow runs e2e tests that require the Azure account and M365 account to be in the same tenant.
# Credentials are provided via TEST_E2E_ACCOUNT_NAME (var) and TEST_E2E_ACCOUNT_PASSWORD (secret).
#
# To add a new same-tenant test, extend the grep -E pattern in the setup job's case-listing steps:
# grep -E "FoundryProxyAgent|YourNewFeature"
on:
workflow_dispatch:
inputs:
cases:
description: 'Specific cases to execute. Example: ["./vs/FoundryProxyAgent.dotnet.tests.ts"]. Leave empty to run all same-tenant defaults.'
required: false
type: string
cli-version:
description: "cli version. Leave empty to use local or alpha build."
required: false
type: string
default: ""
target-testplan-id:
description: "target testplan id. If not set, will not archive ado testplan"
required: false
type: string
schedule:
- cron: "0 23 * * *"
pull_request:
branches: [dev, release/**]
permissions:
actions: read
pull-requests: write
issues: write
jobs:
setup:
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'OfficeDev/microsoft-365-agents-toolkit') }}
runs-on: ubuntu-latest
environment: engineering
permissions:
id-token: write
contents: read
pull-requests: write
outputs:
cases: ${{ steps.schedule-cases.outputs.cases || steps.ai-pr-cases.outputs.cases || steps.dispatch-cases.outputs.cases }}
env:
AZURE_ACCOUNT_NAME: ${{ vars.TEST_E2E_ACCOUNT_NAME }}
AZURE_ACCOUNT_PASSWORD: ${{ secrets.TEST_E2E_ACCOUNT_PASSWORD }}
AZURE_SUBSCRIPTION_ID: ${{ vars.TEST_E2E_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ vars.TEST_TENANT_CLEAN_TENANT_ID }}
M365_ACCOUNT_NAME: ${{ vars.TEST_E2E_ACCOUNT_NAME }}
M365_ACCOUNT_PASSWORD: ${{ secrets.TEST_E2E_ACCOUNT_PASSWORD }}
M365_TENANT_ID: ${{ vars.TEST_TENANT_CLEAN_TENANT_ID }}
AUTO_TEST_PLAN_ID: ${{ github.event.inputs.target-testplan-id }}
CI_ENABLED: "true"
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: azure/login@v1
with:
client-id: ${{ secrets.DEVOPS_CLIENT_ID }}
tenant-id: ${{ secrets.DEVOPS_TENANT_ID }}
subscription-id: ${{ secrets.DEVOPS_SUB_ID }}
- name: setup project
uses: ./.github/actions/setup-project
with:
range: "e2e"
# To add more same-tenant cases, extend the grep -E pattern, e.g.:
# grep -E "FoundryProxyAgent|YourNewFeature"
- name: List cases for schedule
id: schedule-cases
if: ${{ github.event_name == 'schedule' }}
working-directory: packages/tests/src/e2e
run: |
cases=`find . -wholename "*.tests.ts" | grep -E "FoundryProxyAgent" | jq -Rsc '[split("\n") | .[]| select(.!="")]'`
echo "cases=$cases" >> $GITHUB_OUTPUT
- name: AI-select cases for pull request
id: ai-pr-cases
if: ${{ github.event_name == 'pull_request' }}
uses: ./.github/actions/ai-select-e2e-cases
with:
test-dir: packages/tests/src/e2e
include-pattern: "FoundryProxyAgent"
pr-number: ${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
copilot-token: ${{ secrets.COPILOT_CLI_RUNNER_TOKEN }}
- name: List cases for dispatch
id: dispatch-cases
if: ${{ github.event_name == 'workflow_dispatch' }}
working-directory: packages/tests/src/e2e
run: |
inputCases='${{ github.event.inputs.cases }}'
if [ -z "$inputCases" ]; then
allCases=`find . -wholename "*.tests.ts" | grep -E "FoundryProxyAgent" | jq -Rsc '[split("\n") | .[]| select(.!="")]'`
echo "cases=$allCases" >> $GITHUB_OUTPUT
else
echo "cases=$inputCases" >> $GITHUB_OUTPUT
fi
- name: E2E Test clean (scheduled only)
if: ${{ github.event_name != 'pull_request' }}
working-directory: packages/tests
run: |
npm run test:e2e:clean
execute-case:
if: ${{ needs.setup.outputs.cases }}
env:
E2E_RUN_ID: ${{ github.event_name == 'pull_request' && github.run_id || '' }}
AZURE_ACCOUNT_NAME: ${{ vars.TEST_E2E_ACCOUNT_NAME }}
AZURE_ACCOUNT_PASSWORD: ${{ secrets.TEST_E2E_ACCOUNT_PASSWORD }}
AZURE_SUBSCRIPTION_ID: ${{ vars.TEST_E2E_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ vars.TEST_TENANT_CLEAN_TENANT_ID }}
M365_ACCOUNT_NAME: ${{ vars.TEST_E2E_ACCOUNT_NAME }}
M365_ACCOUNT_PASSWORD: ${{ secrets.TEST_E2E_ACCOUNT_PASSWORD }}
M365_TENANT_ID: ${{ vars.TEST_TENANT_CLEAN_TENANT_ID }}
AUTO_TEST_PLAN_ID: ${{ github.event.inputs.target-testplan-id }}
CI_ENABLED: "true"
TEAMSFX_DEBUG_TEMPLATE: "true"
NODE_ENV: "development"
TEAMSFX_AAD_DEPLOY_ONLY: "true"
SIDELOADING_SERVICE_ENDPOINT: ${{ secrets.SIDELOADING_SERVICE_ENDPOINT }}
SIDELOADING_SERVICE_SCOPE: ${{ secrets.SIDELOADING_SERVICE_SCOPE }}
needs: setup
runs-on: ubuntu-latest
environment: engineering
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
cases: ${{ fromJson(needs.setup.outputs.cases) }}
name: ${{ matrix.cases }}
outputs:
cases: ${{ matrix.cases }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: azure/login@v1
with:
client-id: ${{ secrets.DEVOPS_CLIENT_ID }}
tenant-id: ${{ secrets.DEVOPS_TENANT_ID }}
subscription-id: ${{ secrets.DEVOPS_SUB_ID }}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 22
- name: Setup .NET
if: contains(matrix.cases, '.dotnet.')
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
- uses: pnpm/action-setup@v4
- name: Setup project
run: |
npm run setup:e2e
- name: install cli with specific version
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.cli-version != '' }}
run: |
npm install -g @microsoft/m365agentstoolkit-cli@${{ github.event.inputs.cli-version }}
- name: install cli for schedule
if: ${{ github.event_name == 'schedule' || github.event_name == 'pull_request' || (github.event.ref == 'refs/heads/dev' && github.event_name == 'workflow_dispatch' && github.event.inputs.cli-version == '') }}
run: |
npm install -g @microsoft/m365agentstoolkit-cli@alpha
- name: link cli for workflow_dispatch
if: ${{ github.event_name == 'workflow_dispatch' && github.event.ref != 'refs/heads/dev' && github.event.inputs.cli-version == '' }}
run: |
pnpm link --global
- name: print system info
run: |
lscpu
- name: run test
working-directory: packages/tests/src/e2e
run: |
file=`find . -wholename "${{ matrix.cases }}"`
if [ -z "$file" ]; then
echo "can't find target case in $file"
exit 1
else
npx mocha --reporter mochawesome --timeout 1200000 $file
fi
- name: get report name
id: get-report-name
if: ${{ always() }}
run: |
name="${{ matrix.cases }}"
name="${name//'.tests.ts'/}"
name="${name//.\//}"
name="${name//\//_}"
echo "name=$name" >> $GITHUB_OUTPUT
- name: Upload test report
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: test-result-${{ steps.get-report-name.outputs.name }}
path: |
./packages/tests/src/e2e/mochawesome-report/mochawesome.json
tear-down:
needs: execute-case
if: ${{ always() && toJSON(needs.execute-case.outputs.cases) != 'null' }}
runs-on: ubuntu-latest
env:
E2E_RUN_ID: ${{ github.event_name == 'pull_request' && github.run_id || '' }}
E2E_CLEANUP_PREFIX: ${{ github.event_name == 'pull_request' && format('fxE2E{0}', github.run_id) || '' }}
AZURE_ACCOUNT_NAME: ${{ vars.TEST_E2E_ACCOUNT_NAME }}
AZURE_ACCOUNT_PASSWORD: ${{ secrets.TEST_E2E_ACCOUNT_PASSWORD }}
AZURE_SUBSCRIPTION_ID: ${{ vars.TEST_E2E_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ vars.TEST_TENANT_CLEAN_TENANT_ID }}
M365_ACCOUNT_NAME: ${{ vars.TEST_E2E_ACCOUNT_NAME }}
M365_ACCOUNT_PASSWORD: ${{ secrets.TEST_E2E_ACCOUNT_PASSWORD }}
M365_TENANT_ID: ${{ vars.TEST_TENANT_CLEAN_TENANT_ID }}
CI_ENABLED: "true"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: setup project
uses: ./.github/actions/setup-project
- name: E2E Test clean
working-directory: packages/tests
run: |
npm run test:e2e:clean