-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (85 loc) · 2.73 KB
/
npm-publish-github-packages.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
name: Test AppSync utils
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
TEST_IMAGE_NAME: public.ecr.aws/lambda/nodejs:16
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
- run: npm ci
- run: npm test
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Pull test docker image
run: docker pull $TEST_IMAGE_NAME
- name: Install dependencies
run: npm ci
- name: Integration test with LocalStack invoke method
run: bash ./test_in_docker.sh
localstack-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start LocalStack
uses: LocalStack/[email protected]
with:
image-tag: 'latest'
use-pro: 'true'
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
APPSYNC_JS_LIBS_VERSION: ${{ github.sha }}
DEBUG: "1"
DISABLE_EVENTS: "1"
- name: Ensure pro image is used
run: curl -s http://localhost:4566/_localstack/health | grep appsync
- uses: actions/setup-node@v4
- name: Install cdk project
working-directory: cdk
run: npm install
- name: CDK bootstrap
working-directory: cdk
run: npm run cdklocal -- bootstrap
- name: CDK deploy
working-directory: cdk
run: npm run cdklocal -- deploy --require-approval never --outputs-file outputs.json
- name: Fetch output variables for test step
working-directory: cdk
run: |
jq -r '"TEST_URL=\(.CdkStack.GraphQLURL)"' outputs.json >> $GITHUB_ENV
jq -r '"TEST_API_KEY=\(.CdkStack.ApiKey)"' outputs.json >> $GITHUB_ENV
- name: Invoke the URL
run: |
set -x
curl --connect-timeout 30 --retry 10 --retry-delay 6 -X POST -H "x-api-key:$TEST_API_KEY" -H "Accept:application/json" -H "Content-Type:application/json" $TEST_URL -d '{"query": "query { foo }"}'
- name: Get the LocalStack logs
if: success() || failure()
run: |
localstack logs | gzip > logs.txt.gz
- name: Upload the logs as an artifact
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: ls-logs-${{ github.run_number }}
path: |
logs.txt.gz
retention-days: 7
- name: Print the LocalStack logs
if: success() || failure()
run: |
gunzip -c logs.txt.gz