Skip to content

feat: node compatibility test #1416

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 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions .changeset/bright-clouds-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/integration-tests': patch
---

install, build, unit test, and e2e test using lts/iron & lts/hydrogen
6 changes: 5 additions & 1 deletion .github/actions/setup_node/action.yml
Original file line number Diff line number Diff line change
@@ -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'
35 changes: 33 additions & 2 deletions .github/workflows/health_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,43 @@ 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:
- build
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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down