-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Expand file tree
/
Copy pathrun-e2e-test-project-reset.mjs
More file actions
72 lines (67 loc) · 1.89 KB
/
Copy pathrun-e2e-test-project-reset.mjs
File metadata and controls
72 lines (67 loc) · 1.89 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
import {
resetProject,
TEST_PROJECT_NAME,
TEST_TEAM_NAME,
ADAPTER_TEST_TEAM_NAME,
ADAPTER_TEST_TOKEN,
TURBOPACK_TEST_TEAM_NAME,
TURBOPACK_TEST_TOKEN,
TEST_TOKEN,
} from './reset-project.mjs'
/**
* Every team hosting a `TEST_PROJECT_NAME` project that deploy tests deploy
* into. Each entry records the environment variables it was read from, so that
* a failure can point at the variables to check rather than just reporting that
* some team could not be reset.
*/
const TEST_TEAMS = [
{
teamEnvVar: 'VERCEL_TEST_TEAM',
teamId: TEST_TEAM_NAME,
tokenEnvVar: 'VERCEL_TEST_TOKEN',
token: TEST_TOKEN,
},
{
teamEnvVar: 'VERCEL_ADAPTER_TEST_TEAM',
teamId: ADAPTER_TEST_TEAM_NAME,
tokenEnvVar: 'VERCEL_ADAPTER_TEST_TOKEN',
token: ADAPTER_TEST_TOKEN,
},
{
teamEnvVar: 'VERCEL_TURBOPACK_TEST_TEAM',
teamId: TURBOPACK_TEST_TEAM_NAME,
tokenEnvVar: 'VERCEL_TURBOPACK_TEST_TOKEN',
token: TURBOPACK_TEST_TOKEN,
},
]
async function main() {
let hadFailure = false
// Keep going after a failure so that one misconfigured or unreachable team
// does not stop the others from being reset. `resetProject` rejects an absent
// teamId or token itself, so this only has to say which variables to check.
for (const { teamEnvVar, teamId, tokenEnvVar, token } of TEST_TEAMS) {
try {
await resetProject({
projectName: TEST_PROJECT_NAME,
teamId,
token,
disableDeploymentProtection: true,
})
} catch (err) {
console.error(
new Error(
`Failed to reset the ${TEST_PROJECT_NAME} project for ${teamEnvVar}. Verify that ${teamEnvVar} and ${tokenEnvVar} are set correctly.`,
{ cause: err }
)
)
hadFailure = true
}
}
if (hadFailure) {
throw new Error(`resetting a project failed`)
}
}
main().catch((err) => {
console.error(err)
process.exit(1)
})