diff --git a/.github/actions/cached-node-modules/action.yml b/.github/actions/cached-node-modules/action.yml index fbc0f2a2af..a9ebc6b05c 100644 --- a/.github/actions/cached-node-modules/action.yml +++ b/.github/actions/cached-node-modules/action.yml @@ -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 diff --git a/.github/scripts/get_pr_info.js b/.github/scripts/get_pr_info.js index ebb6a76d94..ece2f97f44 100644 --- a/.github/scripts/get_pr_info.js +++ b/.github/scripts/get_pr_info.js @@ -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}` diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 8e67675b87..1950c89b84 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -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: @@ -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 diff --git a/layers/tests/e2e/layerPublisher.test.ts b/layers/tests/e2e/layerPublisher.test.ts index 35efdefae7..3da035472f 100644 --- a/layers/tests/e2e/layerPublisher.test.ts +++ b/layers/tests/e2e/layerPublisher.test.ts @@ -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}`);