1
- name : run-e2e-tests
1
+ name : Run e2e Tests
2
+
2
3
on :
3
- workflow_dispatch : {}
4
+ workflow_dispatch :
5
+ inputs :
6
+ prNumber :
7
+ description : " (Optional) PR Number. If you specify a value the value of the branch field will be ignored."
8
+ required : false
9
+ default : " "
10
+
4
11
jobs :
5
- example-and-package-check :
6
- runs-on : ubuntu-latest
7
- permissions :
8
- contents : read
9
- steps :
10
- - name : " Checkout"
11
- uses : actions/checkout@v3
12
- - name : " Use NodeJS 16"
13
- uses : actions/setup-node@v3
14
- with :
15
- node-version : 16
16
- -
name :
" Install [email protected] "
17
- run : npm i -g npm@next-8
18
- - name : " Install monorepo packages"
19
- # This installs all the dependencies of ./packages/*
20
- # See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
21
- run : npm ci --foreground-scripts
22
- - name : Install CDK example packages
23
- # Since we are not managing the CDK examples with npm workspaces we install
24
- # the dependencies in a separate step
25
- working-directory : ./examples/cdk
26
- run : npm ci
27
- - name : " Setup SAM"
28
- # We use an ad-hoc action so we can specify the SAM CLI version
29
- uses : aws-actions/setup-sam@v2
30
- with :
31
- version : 1.49.0
32
- - name : Install SAM example packages
33
- # Since we are not managing the SAM examples with npm workspaces we install
34
- # the dependencies in a separate step
35
- working-directory : ./examples/sam
36
- run : npm ci
37
- - name : " Test packaging"
38
- run : |
39
- npm run lerna-package
40
- cd examples/cdk
41
- npm install ../../packages/**/dist/aws-lambda-powertools-*
42
- npm run test
43
- package-e2e-tests :
12
+ run-e2e-tests-on-utils :
44
13
runs-on : ubuntu-latest
14
+ env :
15
+ NODE_ENV : dev
16
+ PR_NUMBER : ${{ inputs.prNumber }}
45
17
permissions :
46
18
id-token : write # needed to interact with GitHub's OIDC Token endpoint.
47
19
contents : read
@@ -51,28 +23,47 @@ jobs:
51
23
version : [12, 14, 16]
52
24
fail-fast : false
53
25
steps :
54
- - name : " Checkout"
26
+ - name : Checkout Repo
55
27
uses : actions/checkout@v3
56
- - name : " Use NodeJS"
28
+ # If we pass a PR Number when triggering the workflow we will retrieve the PR info and get its headSHA
29
+ - name : Extract PR details
30
+ id : extract_PR_details
31
+ if : ${{ inputs.prNumber != '' }}
32
+ uses : actions/github-script@v6
33
+ with :
34
+ script : |
35
+ const script = require('.github/scripts/get_pr_info.js');
36
+ await script({github, context, core});
37
+ # Only if a PR Number was passed and the headSHA of the PR extracted,
38
+ # we checkout the PR at that point in time
39
+ - name : Checkout PR code
40
+ if : ${{ inputs.prNumber != '' }}
41
+ uses : actions/checkout@v3
42
+ with :
43
+ ref : ${{ steps.extract_PR_details.outputs.headSHA }}
44
+ - name : Setup NodeJS
57
45
uses : actions/setup-node@v3
58
46
with :
59
47
node-version : ${{ matrix.version }}
60
- - name : " Install npm@8.x "
48
+ - name : Setup npm
61
49
run : npm i -g npm@next-8
62
- - name : " Install monorepo packages "
50
+ - name : Install dependencies
63
51
# This installs all the dependencies of ./packages/*
64
52
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
65
53
run : npm ci --foreground-scripts
66
- - name : " Configure AWS credentials"
54
+ - name : Setup AWS credentials
67
55
uses :
aws-actions/[email protected]
68
56
with :
69
57
role-to-assume : ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
70
58
aws-region : eu-west-1
71
- - name : " Run packages integration tests"
59
+ - name : Run integration tests on utils
72
60
run : |
73
61
RUNTIME=nodejs${{ matrix.version }}x npm run test:e2e -w packages/${{ matrix.package }}
74
62
layer-e2e-tests :
75
63
runs-on : ubuntu-latest
64
+ env :
65
+ NODE_ENV : dev
66
+ PR_NUMBER : ${{ inputs.prNumber }}
76
67
permissions :
77
68
id-token : write # needed to interact with GitHub's OIDC Token endpoint.
78
69
contents : read
@@ -81,14 +72,30 @@ jobs:
81
72
matrix :
82
73
version : [12, 14, 16]
83
74
steps :
84
- - name : Checkout
75
+ - name : Checkout Repo
76
+ uses : actions/checkout@v3
77
+ # If we pass a PR Number when triggering the workflow we will retrieve the PR info and get its headSHA
78
+ - name : Extract PR details
79
+ id : extract_PR_details
80
+ if : ${{ inputs.prNumber != '' }}
81
+ uses : actions/github-script@v6
82
+ with :
83
+ script : |
84
+ const script = require('.github/scripts/get_pr_info.js');
85
+ await script({github, context, core});
86
+ # Only if a PR Number was passed and the headSHA of the PR extracted,
87
+ # we checkout the PR at that point in time
88
+ - name : Checkout PR code
89
+ if : ${{ inputs.prNumber != '' }}
85
90
uses : actions/checkout@v3
86
- - name : Use NodeJS
91
+ with :
92
+ ref : ${{ steps.extract_PR_details.outputs.headSHA }}
93
+ - name : Setup NodeJS
87
94
uses : actions/setup-node@v3
88
95
with :
89
96
# Always use version 16 as we use TypeScript target es2020
90
97
node-version : 16
91
- - name : Install npm@8.x
98
+ - name : Setup npm
92
99
run : npm i -g npm@next-8
93
100
- name : " Configure AWS credentials"
94
101
uses :
aws-actions/[email protected]
@@ -115,9 +122,8 @@ jobs:
115
122
if : steps.cache-node-modules.outputs.cache-hit == 'true'
116
123
run : |
117
124
npm run build -w packages/commons
118
- - name : " Run layer integration tests "
125
+ - name : Run integration test on layers
119
126
run : |
120
127
npm ci --foreground-scripts
121
128
RUNTIME=nodejs${{ matrix.version }}.x npm run test:e2e
122
129
working-directory : layer-publisher
123
-
0 commit comments