Skip to content

Commit 043b4ad

Browse files
authored
chore(ci): added cached dependencies to e2e workflow (#1517)
* chore(ci): added cached dependencies to e2e workflow * fix: runtime key in layers tests
1 parent 5d035a1 commit 043b4ad

File tree

4 files changed

+21
-36
lines changed

4 files changed

+21
-36
lines changed

Diff for: .github/actions/cached-node-modules/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ outputs:
1111
runs:
1212
using: "composite"
1313
steps:
14+
- name: Install npm
15+
if: ${{ inputs.nodeVersion != '18' }}
16+
shell: bash
17+
run: npm i -g npm@next-9
1418
- name: Cache node modules
1519
id: cache-node-modules
1620
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6

Diff for: .github/scripts/get_pr_info.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
module.exports = async ({ github, context, core }) => {
22
const prNumber = process.env.PR_NUMBER;
33

4-
if (prNumber === "") {
4+
if (prNumber === '') {
55
core.setFailed(`No PR number was passed. Aborting`);
66
}
77

8+
// Remove the `#` prefix from the PR number if it exists
9+
const prNumberWithoutPrefix = prNumber.replace('#', '');
10+
811
try {
912
const {
1013
data: { head, base },
1114
} = await github.rest.pulls.get({
1215
owner: context.repo.owner,
1316
repo: context.repo.repo,
14-
pull_number: prNumber,
17+
pull_number: prNumberWithoutPrefix,
1518
});
1619

17-
core.setOutput("headRef", head.ref);
18-
core.setOutput("headSHA", head.sha);
19-
core.setOutput("baseRef", base.ref);
20-
core.setOutput("baseSHA", base.sha);
20+
core.setOutput('headRef', head.ref);
21+
core.setOutput('headSHA', head.sha);
22+
core.setOutput('baseRef', base.ref);
23+
core.setOutput('baseSHA', base.sha);
2124
} catch (error) {
2225
core.setFailed(
2326
`Unable to retrieve info from PR number ${prNumber}.\n\n Error details: ${error}`

Diff for: .github/workflows/run-e2e-tests.yml

+7-29
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ jobs:
4545
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
4646
with:
4747
node-version: ${{ matrix.version }}
48-
- name: Setup npm
49-
run: npm i -g npm@next-8
50-
- name: Install dependencies
51-
# This installs all the dependencies of ./packages/*
52-
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
53-
run: npm ci --foreground-scripts
48+
- name: Setup dependencies
49+
uses: ./.github/actions/cached-node-modules
50+
with:
51+
nodeVersion: ${{ matrix.version }}
5452
- name: Setup AWS credentials
5553
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
5654
with:
@@ -95,36 +93,16 @@ jobs:
9593
with:
9694
# Always use version 18
9795
node-version: 18
98-
- name: Setup npm
99-
run: npm i -g npm@next-8
96+
- name: Setup dependencies
97+
uses: ./.github/actions/cached-node-modules
10098
- name: "Configure AWS credentials"
10199
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
102100
with:
103101
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
104102
aws-region: eu-west-1
105-
- name: Cache node modules for commons
106-
id: cache-node-modules
107-
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
108-
with:
109-
path: "./node_modules"
110-
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that
111-
# if one of them changes the cache is invalidated/discarded
112-
key: ${{ matrix.version }}-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
113-
- name: Install dependencies
114-
# We can skip the install if there was a cache hit
115-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
116-
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
117-
run: npm ci --foreground-scripts
118-
- name: Build packages
119-
# If there's a cache hit we still need to manually build the packages
120-
# this would otherwise have been done automatically as a part of the
121-
# postinstall npm hook
122-
if: steps.cache-node-modules.outputs.cache-hit == 'true'
123-
run: |
124-
npm run build -w packages/commons
125103
- name: Create layer files
126104
run: |
127105
export VERSION=latest
128106
bash .github/scripts/setup_tmp_layer_files.sh
129107
- name: Run integration test on layers
130-
run: RUNTIME=nodejs${{ matrix.version }}.x npm run test:e2e -w layers
108+
run: RUNTIME=nodejs${{ matrix.version }}x npm run test:e2e -w layers

Diff for: layers/tests/e2e/layerPublisher.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { v4 } from 'uuid';
3030
import path from 'path';
3131
import packageJson from '../../package.json';
3232

33-
const runtime: string = process.env.RUNTIME || 'nodejs1x';
33+
const runtime: string = process.env.RUNTIME || 'nodejs18x';
3434

3535
if (!isValidRuntimeKey(runtime)) {
3636
throw new Error(`Invalid runtime key: ${runtime}`);

0 commit comments

Comments
 (0)