-
Notifications
You must be signed in to change notification settings - Fork 4
/
buildspec-mock-e2e.yml
69 lines (68 loc) · 3.3 KB
/
buildspec-mock-e2e.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
version: 0.2
env:
secrets-manager:
GITHUB_TOKEN: "fpjs-dev-cloudfront-secrets:GITHUB_TOKEN"
phases:
install:
runtime-versions:
nodejs: 20
commands:
- npm i -g pnpm
- export COMMIT_SHA=$(cat meta.json | jq -r '.sha')
- export VERSION=$(cat meta.json | jq -r '.version')
- echo $COMMIT_SHA
- echo $VERSION
- echo $CODEBUILD_BUILD_ID
- echo $CODEBUILD_PUBLIC_BUILD_URL
- |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
-d "{\"state\":\"pending\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-mock-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"Mock E2E Tests are running\",\"context\":\"mock-e2e\"}"
- ls -a
- curl -fsSL https://get.pulumi.com | sh
- export PATH=$PATH:$HOME/.pulumi/bin
- pulumi version
pre_build:
commands:
- pwd
- ls -lah
- pulumi version
- pnpm install
- npm i -g ts-node
- pnpm -C website install && pnpm -C website build
- cd tests && pnpm install && cd ..
- cd infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../
- cd infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../
- cd infra && pnpm install && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd ../
finally:
- |
if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
-d "{\"state\":\"error\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-mock-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"Mock E2E Tests failed during the pre-build step\",\"context\":\"mock-e2e\"}"
fi
build:
commands:
- ts-node ./scripts/mockTests.ts --project=tsconfig.json
finally:
- echo $CODEBUILD_BUILD_SUCCEEDING
- echo $COMMIT_SHA
- export STATUS=$(sh ./scripts/get-codebuild-status.sh)
- echo $STATUS
- |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
-d "{\"state\":\"$STATUS\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-mock-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"Mock E2E Tests finished\",\"context\":\"mock-e2e\"}"
- cd infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd ../