1- name : run-e2e-tests
1+ name : Run e2e Tests
2+
23on :
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+
411jobs :
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 npm@8.x"
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 :
4413 runs-on : ubuntu-latest
14+ env :
15+ NODE_ENV : dev
16+ PR_NUMBER : ${{ inputs.prNumber }}
4517 permissions :
4618 id-token : write # needed to interact with GitHub's OIDC Token endpoint.
4719 contents : read
@@ -51,28 +23,47 @@ jobs:
5123 version : [12, 14, 16]
5224 fail-fast : false
5325 steps :
54- - name : " Checkout"
26+ - name : Checkout Repo
5527 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
5745 uses : actions/setup-node@v3
5846 with :
5947 node-version : ${{ matrix.version }}
60- - name : " Install npm@8.x "
48+ - name : Setup npm
6149 run : npm i -g npm@next-8
62- - name : " Install monorepo packages "
50+ - name : Install dependencies
6351 # This installs all the dependencies of ./packages/*
6452 # See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
6553 run : npm ci --foreground-scripts
66- - name : " Configure AWS credentials"
54+ - name : Setup AWS credentials
6755 uses : aws-actions/configure-aws-credentials@v1.6.1
6856 with :
6957 role-to-assume : ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
7058 aws-region : eu-west-1
71- - name : " Run packages integration tests"
59+ - name : Run integration tests on utils
7260 run : |
7361 RUNTIME=nodejs${{ matrix.version }}x npm run test:e2e -w packages/${{ matrix.package }}
7462 layer-e2e-tests :
7563 runs-on : ubuntu-latest
64+ env :
65+ NODE_ENV : dev
66+ PR_NUMBER : ${{ inputs.prNumber }}
7667 permissions :
7768 id-token : write # needed to interact with GitHub's OIDC Token endpoint.
7869 contents : read
@@ -81,14 +72,30 @@ jobs:
8172 matrix :
8273 version : [12, 14, 16]
8374 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 != '' }}
8590 uses : actions/checkout@v3
86- - name : Use NodeJS
91+ with :
92+ ref : ${{ steps.extract_PR_details.outputs.headSHA }}
93+ - name : Setup NodeJS
8794 uses : actions/setup-node@v3
8895 with :
8996 # Always use version 16 as we use TypeScript target es2020
9097 node-version : 16
91- - name : Install npm@8.x
98+ - name : Setup npm
9299 run : npm i -g npm@next-8
93100 - name : " Configure AWS credentials"
94101 uses : aws-actions/configure-aws-credentials@v1.6.1
@@ -115,9 +122,8 @@ jobs:
115122 if : steps.cache-node-modules.outputs.cache-hit == 'true'
116123 run : |
117124 npm run build -w packages/commons
118- - name : " Run layer integration tests "
125+ - name : Run integration test on layers
119126 run : |
120127 npm ci --foreground-scripts
121128 RUNTIME=nodejs${{ matrix.version }}.x npm run test:e2e
122129 working-directory : layer-publisher
123-
0 commit comments