Skip to content

chore(ci): added cached dependencies to e2e workflow #1517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/cached-node-modules/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ outputs:
runs:
using: "composite"
steps:
- name: Install npm
if: ${{ inputs.nodeVersion != '18' }}
shell: bash
run: npm i -g npm@next-9
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
Expand Down
15 changes: 9 additions & 6 deletions .github/scripts/get_pr_info.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
module.exports = async ({ github, context, core }) => {
const prNumber = process.env.PR_NUMBER;

if (prNumber === "") {
if (prNumber === '') {
core.setFailed(`No PR number was passed. Aborting`);
}

// Remove the `#` prefix from the PR number if it exists
const prNumberWithoutPrefix = prNumber.replace('#', '');

try {
const {
data: { head, base },
} = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
pull_number: prNumberWithoutPrefix,
});

core.setOutput("headRef", head.ref);
core.setOutput("headSHA", head.sha);
core.setOutput("baseRef", base.ref);
core.setOutput("baseSHA", base.sha);
core.setOutput('headRef', head.ref);
core.setOutput('headSHA', head.sha);
core.setOutput('baseRef', base.ref);
core.setOutput('baseSHA', base.sha);
} catch (error) {
core.setFailed(
`Unable to retrieve info from PR number ${prNumber}.\n\n Error details: ${error}`
Expand Down
36 changes: 7 additions & 29 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ jobs:
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ matrix.version }}
- name: Setup npm
run: npm i -g npm@next-8
- name: Install dependencies
# This installs all the dependencies of ./packages/*
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
run: npm ci --foreground-scripts
- name: Setup dependencies
uses: ./.github/actions/cached-node-modules
with:
nodeVersion: ${{ matrix.version }}
- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with:
Expand Down Expand Up @@ -95,36 +93,16 @@ jobs:
with:
# Always use version 18
node-version: 18
- name: Setup npm
run: npm i -g npm@next-8
- name: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: "Configure AWS credentials"
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
aws-region: eu-west-1
- name: Cache node modules for commons
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
with:
path: "./node_modules"
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that
# if one of them changes the cache is invalidated/discarded
key: ${{ matrix.version }}-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# We can skip the install if there was a cache hit
if: steps.cache-node-modules.outputs.cache-hit != 'true'
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
run: npm ci --foreground-scripts
- name: Build packages
# If there's a cache hit we still need to manually build the packages
# this would otherwise have been done automatically as a part of the
# postinstall npm hook
if: steps.cache-node-modules.outputs.cache-hit == 'true'
run: |
npm run build -w packages/commons
- name: Create layer files
run: |
export VERSION=latest
bash .github/scripts/setup_tmp_layer_files.sh
- name: Run integration test on layers
run: RUNTIME=nodejs${{ matrix.version }}.x npm run test:e2e -w layers
run: RUNTIME=nodejs${{ matrix.version }}x npm run test:e2e -w layers
2 changes: 1 addition & 1 deletion layers/tests/e2e/layerPublisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { v4 } from 'uuid';
import path from 'path';
import packageJson from '../../package.json';

const runtime: string = process.env.RUNTIME || 'nodejs1x';
const runtime: string = process.env.RUNTIME || 'nodejs18x';

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