From 29895a063c1f16615f065b75c9179313f198123a Mon Sep 17 00:00:00 2001 From: charles shin Date: Wed, 1 May 2024 02:45:19 -0700 Subject: [PATCH 1/6] feat: node compatibility test in CI --- .changeset/bright-clouds-drive.md | 5 +++ .github/actions/setup_node/action.yml | 6 +++- .github/workflows/health_checks.yml | 35 +++++++++++++++++-- .../access_testing_project.ts | 11 ++++-- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 .changeset/bright-clouds-drive.md diff --git a/.changeset/bright-clouds-drive.md b/.changeset/bright-clouds-drive.md new file mode 100644 index 00000000000..25e650f36ed --- /dev/null +++ b/.changeset/bright-clouds-drive.md @@ -0,0 +1,5 @@ +--- +'@aws-amplify/integration-tests': patch +--- + +install, build, unit test, and e2e test using lts/iron & lts/hydrogen diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml index 910ce6a12aa..3d09f8dca1d 100644 --- a/.github/actions/setup_node/action.yml +++ b/.github/actions/setup_node/action.yml @@ -1,10 +1,14 @@ # basic setup that applies to most jobs # checks out the repo and configures node name: setup_node +inputs: + node-version: + description: node version used to configure environment with + default: lts/hydrogen runs: using: composite steps: - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # version 3.8.1 with: - node-version: 18 + node-version: ${{ inputs.node-version }} cache: 'npm' diff --git a/.github/workflows/health_checks.yml b/.github/workflows/health_checks.yml index 56978cb13fa..91f502b71c7 100644 --- a/.github/workflows/health_checks.yml +++ b/.github/workflows/health_checks.yml @@ -21,19 +21,28 @@ jobs: # creates file system links that include drive letter. # Changing between standard and custom workers requires full install cache invalidation os: [ubuntu-latest, macos-14, windows-latest] + node: [lts/hydrogen, lts/iron] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0 - uses: ./.github/actions/setup_node + with: + node-version: ${{ matrix.node }} - uses: ./.github/actions/install_with_cache build: + strategy: + matrix: + node: [lts/hydrogen, lts/iron] runs-on: ubuntu-latest needs: - install steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0 - uses: ./.github/actions/setup_node + with: + node-version: ${{ matrix.node }} + - uses: ./.github/actions/install_with_cache - uses: ./.github/actions/build_with_cache test_with_coverage: needs: @@ -41,10 +50,14 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-14, windows-latest] + node: [lts/hydrogen, lts/iron] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0 - uses: ./.github/actions/setup_node + with: + node-version: ${{ matrix.node }} + - uses: ./.github/actions/install_with_cache - uses: ./.github/actions/restore_build_cache - run: npm run set-script-shell - run: npm run test:coverage:threshold @@ -137,6 +150,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-14-xlarge, windows-latest] + node-version: [lts/hydrogen, lts/iron] + # skip multiple node version test on other os + exclude: + - os: macos-14-xlarge + node-version: lts/iron + - os: windows-latest + node-version: lts/iron runs-on: ${{ matrix.os }} timeout-minutes: 25 needs: @@ -149,6 +169,8 @@ jobs: steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0 - uses: ./.github/actions/setup_node + with: + node-version: ${{ matrix.node-version }} - uses: ./.github/actions/restore_build_cache - run: cd packages/cli && npm link - name: Configure test tooling credentials @@ -171,6 +193,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-14, windows-latest] + node-version: [lts/hydrogen, lts/iron] + # skip multiple node version test on other os + exclude: + - os: macos-14 + node-version: lts/iron + - os: windows-latest + node-version: lts/iron runs-on: ${{ matrix.os }} timeout-minutes: ${{ matrix.os == 'windows-latest' && 35 || 25 }} needs: @@ -179,6 +208,8 @@ jobs: steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0 - uses: ./.github/actions/setup_node + with: + node-version: ${{ matrix.node-version }} - uses: ./.github/actions/restore_build_cache - run: cd packages/cli && npm link - name: Run e2e create-amplify tests @@ -191,7 +222,7 @@ jobs: matrix: os: [ubuntu-latest, macos-14, windows-latest] pkg-manager: [npm, yarn-classic, yarn-modern, pnpm] - node-version: [20] + node-version: ['lts/iron'] env: PACKAGE_MANAGER: ${{ matrix.pkg-manager }} runs-on: ${{ matrix.os }} @@ -207,7 +238,7 @@ jobs: - name: Checkout aws-amplify/amplify-cli repo uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Setup Node.js - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # version 3.8.1 + uses: ./.github/actions/setup_node with: node-version: ${{ matrix.node-version }} - name: Restore Build Cache diff --git a/packages/integration-tests/src/test-project-setup/access_testing_project.ts b/packages/integration-tests/src/test-project-setup/access_testing_project.ts index db795aae6f0..aa894be7dea 100644 --- a/packages/integration-tests/src/test-project-setup/access_testing_project.ts +++ b/packages/integration-tests/src/test-project-setup/access_testing_project.ts @@ -43,13 +43,20 @@ import crypto from 'node:crypto'; import { gql } from 'graphql-tag'; import { IamCredentials } from '../types.js'; import { AmplifyAuthCredentialsFactory } from '../amplify_auth_credentials_factory.js'; +import { SemVer } from 'semver'; // TODO: this is a work around // it seems like as of amplify v6 , some of the code only runs in the browser ... // see https://github.com/aws-amplify/amplify-js/issues/12751 -// @ts-expect-error altering typing for global to make compiler happy is not worth the effort assuming this is temporary workaround -globalThis.crypto = crypto; +if (process.versions.node) { + // node >= 20 now exposes crypto by default. This workaround is not needed: https://github.com/nodejs/node/pull/42083 + if (new SemVer(process.versions.node).major < 20) { + // @ts-expect-error altering typing for global to make compiler happy is not worth the effort assuming this is temporary workaround + globalThis.crypto = crypto; + } +} +// @ts /** * Creates access testing projects with typescript idioms. */ From 979d8d7c683ca948a94fb075cdb1172f8354e453 Mon Sep 17 00:00:00 2001 From: charles shin Date: Wed, 1 May 2024 16:39:36 -0700 Subject: [PATCH 2/6] use numbers instead of nvm format --- .github/workflows/health_checks.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/health_checks.yml b/.github/workflows/health_checks.yml index 91f502b71c7..a2cea6647e2 100644 --- a/.github/workflows/health_checks.yml +++ b/.github/workflows/health_checks.yml @@ -21,7 +21,7 @@ jobs: # creates file system links that include drive letter. # Changing between standard and custom workers requires full install cache invalidation os: [ubuntu-latest, macos-14, windows-latest] - node: [lts/hydrogen, lts/iron] + node: [18, 20] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: @@ -33,7 +33,7 @@ jobs: build: strategy: matrix: - node: [lts/hydrogen, lts/iron] + node: [18, 20] runs-on: ubuntu-latest needs: - install @@ -50,7 +50,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-14, windows-latest] - node: [lts/hydrogen, lts/iron] + node: [18, 20] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0 @@ -150,13 +150,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-14-xlarge, windows-latest] - node-version: [lts/hydrogen, lts/iron] + node-version: [18, 20] # skip multiple node version test on other os exclude: - os: macos-14-xlarge - node-version: lts/iron + node-version: 20 - os: windows-latest - node-version: lts/iron + node-version: 20 runs-on: ${{ matrix.os }} timeout-minutes: 25 needs: @@ -193,13 +193,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-14, windows-latest] - node-version: [lts/hydrogen, lts/iron] + node-version: [18, 20] # skip multiple node version test on other os exclude: - os: macos-14 - node-version: lts/iron + node-version: 20 - os: windows-latest - node-version: lts/iron + node-version: 20 runs-on: ${{ matrix.os }} timeout-minutes: ${{ matrix.os == 'windows-latest' && 35 || 25 }} needs: @@ -222,7 +222,7 @@ jobs: matrix: os: [ubuntu-latest, macos-14, windows-latest] pkg-manager: [npm, yarn-classic, yarn-modern, pnpm] - node-version: ['lts/iron'] + node-version: ['20'] env: PACKAGE_MANAGER: ${{ matrix.pkg-manager }} runs-on: ${{ matrix.os }} From 418742a92e52208d66da60f7c4815bdb9ed27f6d Mon Sep 17 00:00:00 2001 From: charles shin Date: Thu, 2 May 2024 01:30:43 -0700 Subject: [PATCH 3/6] update cache key with node version --- .github/actions/build_with_cache/action.yml | 5 ++++- .github/actions/install_with_cache/action.yml | 5 ++++- .github/actions/restore_build_cache/action.yml | 2 +- .github/actions/restore_install_cache/action.yml | 2 +- .github/actions/setup_node/action.yml | 2 +- .github/workflows/health_checks.yml | 9 ++++++++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/actions/build_with_cache/action.yml b/.github/actions/build_with_cache/action.yml index b7ab90b04c9..d7e18666697 100644 --- a/.github/actions/build_with_cache/action.yml +++ b/.github/actions/build_with_cache/action.yml @@ -1,5 +1,8 @@ name: build_with_cache description: builds the source code if cache miss and caches the result +inputs: + node-version: + default: 18 runs: using: composite steps: @@ -9,7 +12,7 @@ runs: id: build-cache with: path: '**/lib' - key: ${{ github.sha }} + key: ${{ github.sha }}-node${{ inputs.node-version }} enableCrossOsArchive: true # only build if cache miss - if: steps.build-cache.outputs.cache-hit != 'true' diff --git a/.github/actions/install_with_cache/action.yml b/.github/actions/install_with_cache/action.yml index cc6ec48b6ab..f1533dab5eb 100644 --- a/.github/actions/install_with_cache/action.yml +++ b/.github/actions/install_with_cache/action.yml @@ -1,5 +1,8 @@ name: install_with_cache description: installs node_modules if cache miss and stores in the cache +inputs: + node-version: + default: 18 runs: using: composite steps: @@ -10,7 +13,7 @@ runs: path: | node_modules packages/**/node_modules - key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-v2 + key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }}-v2 # only install if cache miss - if: steps.npm-cache.outputs.cache-hit != 'true' shell: bash diff --git a/.github/actions/restore_build_cache/action.yml b/.github/actions/restore_build_cache/action.yml index bea93d612d1..c77b5d8d71b 100644 --- a/.github/actions/restore_build_cache/action.yml +++ b/.github/actions/restore_build_cache/action.yml @@ -9,6 +9,6 @@ runs: id: build-cache with: path: '**/lib' - key: ${{ github.sha }} + key: ${{ github.sha }}-node${{ inputs.node-version }} fail-on-cache-miss: true enableCrossOsArchive: true diff --git a/.github/actions/restore_install_cache/action.yml b/.github/actions/restore_install_cache/action.yml index f9b801f2ca5..75970f5e254 100644 --- a/.github/actions/restore_install_cache/action.yml +++ b/.github/actions/restore_install_cache/action.yml @@ -10,5 +10,5 @@ runs: path: | node_modules packages/**/node_modules - key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }}-v2 fail-on-cache-miss: true diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml index 3d09f8dca1d..c8b4d41c6e5 100644 --- a/.github/actions/setup_node/action.yml +++ b/.github/actions/setup_node/action.yml @@ -4,7 +4,7 @@ name: setup_node inputs: node-version: description: node version used to configure environment with - default: lts/hydrogen + default: 18 runs: using: composite steps: diff --git a/.github/workflows/health_checks.yml b/.github/workflows/health_checks.yml index a2cea6647e2..c2b8a431995 100644 --- a/.github/workflows/health_checks.yml +++ b/.github/workflows/health_checks.yml @@ -30,6 +30,8 @@ jobs: with: node-version: ${{ matrix.node }} - uses: ./.github/actions/install_with_cache + with: + node-version: ${{ matrix.node }} build: strategy: matrix: @@ -42,8 +44,9 @@ jobs: - uses: ./.github/actions/setup_node with: node-version: ${{ matrix.node }} - - uses: ./.github/actions/install_with_cache - uses: ./.github/actions/build_with_cache + with: + node-version: ${{ matrix.node }} test_with_coverage: needs: - build @@ -58,7 +61,11 @@ jobs: with: node-version: ${{ matrix.node }} - uses: ./.github/actions/install_with_cache + with: + node-version: ${{ matrix.node }} - uses: ./.github/actions/restore_build_cache + with: + node-version: ${{ matrix.node }} - run: npm run set-script-shell - run: npm run test:coverage:threshold test_scripts: From 912ee785c64d5b9991a4f391c26634ce1a1bcc1f Mon Sep 17 00:00:00 2001 From: charles shin Date: Thu, 2 May 2024 01:51:59 -0700 Subject: [PATCH 4/6] add inputs to restore actions --- .github/actions/restore_build_cache/action.yml | 4 ++++ .github/actions/restore_install_cache/action.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/actions/restore_build_cache/action.yml b/.github/actions/restore_build_cache/action.yml index c77b5d8d71b..3fbfad0aeca 100644 --- a/.github/actions/restore_build_cache/action.yml +++ b/.github/actions/restore_build_cache/action.yml @@ -1,5 +1,9 @@ name: restore_build_cache description: composes restoring node_modules and restoring build artifacts +inputs: + node-version: + description: node version used to configure environment with + default: 18 runs: using: composite steps: diff --git a/.github/actions/restore_install_cache/action.yml b/.github/actions/restore_install_cache/action.yml index 75970f5e254..abcda7e3e41 100644 --- a/.github/actions/restore_install_cache/action.yml +++ b/.github/actions/restore_install_cache/action.yml @@ -1,5 +1,9 @@ name: restore_install_cache description: restores node_modules from the cache and fails if no cache entry found +inputs: + node-version: + description: node version used to configure environment with + default: 18 runs: using: composite steps: From cdc4d3ba9f11f9381445123f2505ef944841723b Mon Sep 17 00:00:00 2001 From: charles shin Date: Mon, 6 May 2024 10:08:10 -0700 Subject: [PATCH 5/6] removing v2 suffix --- .github/actions/install_with_cache/action.yml | 2 +- .github/actions/restore_install_cache/action.yml | 2 +- .../src/test-project-setup/access_testing_project.ts | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/actions/install_with_cache/action.yml b/.github/actions/install_with_cache/action.yml index f1533dab5eb..e85cc34a52b 100644 --- a/.github/actions/install_with_cache/action.yml +++ b/.github/actions/install_with_cache/action.yml @@ -13,7 +13,7 @@ runs: path: | node_modules packages/**/node_modules - key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }}-v2 + key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }} # only install if cache miss - if: steps.npm-cache.outputs.cache-hit != 'true' shell: bash diff --git a/.github/actions/restore_install_cache/action.yml b/.github/actions/restore_install_cache/action.yml index abcda7e3e41..21555760345 100644 --- a/.github/actions/restore_install_cache/action.yml +++ b/.github/actions/restore_install_cache/action.yml @@ -14,5 +14,5 @@ runs: path: | node_modules packages/**/node_modules - key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }}-v2 + key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }} fail-on-cache-miss: true diff --git a/packages/integration-tests/src/test-project-setup/access_testing_project.ts b/packages/integration-tests/src/test-project-setup/access_testing_project.ts index aa894be7dea..a9b51f37ae5 100644 --- a/packages/integration-tests/src/test-project-setup/access_testing_project.ts +++ b/packages/integration-tests/src/test-project-setup/access_testing_project.ts @@ -56,7 +56,6 @@ if (process.versions.node) { } } -// @ts /** * Creates access testing projects with typescript idioms. */ From be16ddbdc2ec77efe6ffbe46eb494eb12e2fa37c Mon Sep 17 00:00:00 2001 From: charles shin Date: Mon, 6 May 2024 10:13:52 -0700 Subject: [PATCH 6/6] try removing install cache --- .github/workflows/health_checks.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/health_checks.yml b/.github/workflows/health_checks.yml index c2b8a431995..e503c9f0fb0 100644 --- a/.github/workflows/health_checks.yml +++ b/.github/workflows/health_checks.yml @@ -60,9 +60,6 @@ jobs: - uses: ./.github/actions/setup_node with: node-version: ${{ matrix.node }} - - uses: ./.github/actions/install_with_cache - with: - node-version: ${{ matrix.node }} - uses: ./.github/actions/restore_build_cache with: node-version: ${{ matrix.node }}