Skip to content
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

test: verify public interfaces are compliant to TS4.0 #12013

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3f92c49
Merge branch 'next/release' into 'next/main' (#12005)
ashwinkumar6 Sep 11, 2023
366fd9d
feat: initial commit of ts-compliance-test
AllanZhengYP Sep 8, 2023
22164f5
test: add ts3.8 compliance test
AllanZhengYP Sep 12, 2023
41253ac
test: update tsc compliance test to target TS4.0
AllanZhengYP Sep 12, 2023
3c6b30e
chore: include cognito server path
AllanZhengYP Sep 12, 2023
e5e4e5a
Merge remote-tracking branch 'upstream/next/release' into typescript-…
AllanZhengYP Sep 12, 2023
1aeb0b1
chore: fix diffs
AllanZhengYP Sep 12, 2023
b174df7
test: add tsc compliance test to github actions
AllanZhengYP Sep 13, 2023
9b43f1e
Merge branch 'next/release' into typescript-upgrade-commit
AllanZhengYP Sep 13, 2023
44083a4
chore: add @smithy/[email protected] along with @aws-sdk/types
AllanZhengYP Sep 13, 2023
55faa18
chore: update yarn.lock
AllanZhengYP Sep 13, 2023
bbd50a8
chore: run yarn upgrade
AllanZhengYP Sep 13, 2023
8335928
Merge remote-tracking branch 'upstream/next/release' into typescript-…
AllanZhengYP Sep 18, 2023
93d9885
chore: fix git diff
AllanZhengYP Sep 18, 2023
4a46e15
chore: add documentation
AllanZhengYP Sep 18, 2023
2a710fa
Revert "chore: add @smithy/[email protected] along with @aws-sdk/types"
AllanZhengYP Sep 18, 2023
74d6124
Merge branch 'next/release' into typescript-upgrade-commit
jimblanc Sep 19, 2023
aa9f664
Merge branch 'next/release' into typescript-upgrade-commit
israx Sep 19, 2023
777ad50
feat: add aws-amplify to the tsc-compliance-test dev dependency
AllanZhengYP Sep 19, 2023
2001ab5
update yarn.lock
AllanZhengYP Sep 19, 2023
0716c95
fix: use @types/node@16 to compatible with ts4.0
AllanZhengYP Sep 19, 2023
01695a5
Merge branch 'next/release' into typescript-upgrade-commit
stocaaro Sep 19, 2023
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
17 changes: 17 additions & 0 deletions .github/workflows/callable-test-tsc-compliance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Test Github Actions
on: workflow_call

jobs:
tsc_compliance_test:
name: TSC Compliance Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
path: amplify-js
- name: Setup node and build the repository
uses: ./amplify-js/.github/actions/node-and-build
- name: Run GithubAction tests
working-directory: ./amplify-js
run: yarn test:tsc-compliance
4 changes: 4 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ jobs:
github-actions-test:
needs: prebuild
uses: ./.github/workflows/callable-test-github-actions.yml
tsc-compliance-test:
needs: prebuild
uses: ./.github/workflows/callable-test-tsc-compliance.yml
all-unit-tests-pass:
name: Unit and Bundle tests have passed
needs:
- unit-tests
- bundle-size-tests
- license-test
- github-actions-test
- tsc-compliance-test
runs-on: ubuntu-latest
# This is a bit of a hack - Branch protections depend upon selected
# workflows that run on hardware, not parents of many callable workflows.
Expand Down
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"packages/analytics",
"packages/storage",
"packages/aws-amplify",
"packages/adapter-nextjs"
"packages/adapter-nextjs",
"scripts/tsc-compliance-test"
],
"exact": true,
"version": "independent",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"setup-dev": "yarn && yarn bootstrap && yarn link-all && yarn build",
"setup-dev:react-native": "node ./scripts/setup-dev-rn",
"bootstrap": "lerna bootstrap",
"test": "lerna run test --stream && yarn test:license && yarn test:github-actions",
"test": "lerna run test --stream && yarn test:license && yarn test:github-actions && test:tsc-compliance",
"test:size": "lerna run test:size --no-bail",
"test:duplicates": "./scripts/duplicates-yarn.sh",
"test:license": "license-check-and-add check -f license_config.json",
"test:github-actions": "node ./scripts/test-github-actions.js",
"test:tsc-compliance": "yarn workspace tsc-compliance-test test:compliance:ts4.0",
"coverage": "codecov || exit 0",
"docs": "typedoc packages/**/src --name amplify-js --hideGenerator --excludePrivate --ignoreCompilerErrors --mode file --out docs/api --theme docs/amplify-theme/typedoc/ --readme README.md",
"build": "lerna run build --stream && yarn test:duplicates",
Expand Down Expand Up @@ -45,7 +46,8 @@
"packages/analytics",
"packages/storage",
"packages/aws-amplify",
"packages/adapter-nextjs"
"packages/adapter-nextjs",
"scripts/tsc-compliance-test"
],
"nohoist": [
"**/@types/react-native",
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"s3"
],
"dependencies": {
"@smithy/md5-js": "2.0.5",
"@smithy/md5-js": "2.0.7",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to pull in the latest @smithy/types fix

"@aws-sdk/types": "3.398.0",
"fast-xml-parser": "^4.2.5",
"buffer": "4.9.2",
Expand Down
5 changes: 5 additions & 0 deletions scripts/tsc-compliance-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is an **internal-only** package to make sure all the Amplify JS library public interfaces are always compatible
with TypeScript 4.0 compiler.

If any additional public APIs are added to the library, you must make sure the new API is included in the `ts4_0.ts`
file.
14 changes: 14 additions & 0 deletions scripts/tsc-compliance-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tsc-compliance-test",
"version": "0.1.0",
"license": "MIT",
"private": true,
"devDependencies": {
AllanZhengYP marked this conversation as resolved.
Show resolved Hide resolved
"@types/node": "^16.11.7",
"aws-amplify": "6.0.0",
"typescript": "4.0.x"
},
"scripts": {
"test:compliance:ts4.0": "tsc -p tsconfig.json"
}
}
31 changes: 31 additions & 0 deletions scripts/tsc-compliance-test/ts4_0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import * as Amplify from 'aws-amplify';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/adapter-nextjs subpath is not included because Next.js usually has more up-to-date TSC support. But it can be included too.

import * as analytics from 'aws-amplify/analytics';

import * as auth from 'aws-amplify/auth';
import * as authCognito from 'aws-amplify/auth/cognito';
import * as authServer from 'aws-amplify/auth/server';
import * as authCognitoServer from 'aws-amplify/auth/cognito/server';

import * as storage from 'aws-amplify/storage';
import * as storageServer from 'aws-amplify/storage/server';
import * as storageS3 from 'aws-amplify/storage/s3';
import * as storageS3Server from 'aws-amplify/storage/s3/server';

import * as utils from 'aws-amplify/utils';

export const allPublicPaths = [
Amplify,
analytics,
auth,
authCognito,
authServer,
authCognitoServer,
storage,
storageServer,
storageS3,
storageS3Server,
utils,
];
13 changes: 13 additions & 0 deletions scripts/tsc-compliance-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"noEmit": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"strict": true,
"target": "ESNext",
"lib": ["DOM", "ESNext.AsyncIterable", "ES2018.AsyncGenerator"],
"moduleResolution": "node",
"types": ["node"]
},
"include": ["ts4_0.ts"]
}
20 changes: 15 additions & 5 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading