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

fix: e2e tests #771

Merged
merged 44 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6577ebf
chore: change branch to poc/pms-create-amplify
0618 Nov 28, 2023
63e498b
fix: gitIgnore test
0618 Nov 28, 2023
2649b52
Merge branch 'main' into poc/pms-create-amplify
0618 Nov 28, 2023
b12306f
fix: refactor e2e for pms
0618 Nov 28, 2023
0fdb132
chore: update package.lock
0618 Nov 28, 2023
dfe3aab
Merge branch 'main' into poc/pms-create-amplify
0618 Nov 28, 2023
5023934
chore: update package.lock
0618 Nov 29, 2023
12c183b
temp: refactor
0618 Nov 28, 2023
020f87a
temp: run 1 test
0618 Nov 29, 2023
1ca1400
temp: fix npx
0618 Nov 29, 2023
307e613
temp: install packages for yarn
0618 Nov 29, 2023
7d9537b
temp: update initial_project_file_generator
0618 Nov 29, 2023
333d33d
temp: install ts for yarn
0618 Nov 29, 2023
ab0af4e
temp: ignore node_modules and yarn.lock
0618 Nov 29, 2023
43ec0c6
temp: create yarn.lock for yarn stable
0618 Nov 29, 2023
efcbca4
temp: fix yarn-stable init
0618 Nov 29, 2023
5fc04ca
temp: fix --help
0618 Nov 29, 2023
2ab3397
fix: assert for gitignore
0618 Nov 29, 2023
d4e52ba
chore: change yarn stable install
0618 Nov 30, 2023
1c1ca48
Merge branch 'main' into poc/pms-create-amplify
0618 Nov 30, 2023
4a1a848
fix: not install yarn stable globally
0618 Dec 1, 2023
15fa887
add @yarnpkg/sdks base
0618 Dec 2, 2023
d25ba85
yarn stable use node-modules
0618 Dec 3, 2023
068c40b
remove emoji
0618 Dec 3, 2023
6a994f0
remove @yarnpkg/sdks
0618 Dec 3, 2023
430f0a1
yarn stable use node 18.18
0618 Dec 4, 2023
f1eb76a
yarn stable use node 20
0618 Dec 4, 2023
f7a167b
chore: re-enable all tests
0618 Dec 4, 2023
7d9bb78
Revert "chore: re-enable all tests"
0618 Dec 4, 2023
8edfb56
Merge branch 'poc/package-manager-support' into poc/pms-create-amplify
0618 Dec 4, 2023
26fe239
chore: uncomment test
0618 Dec 4, 2023
69aa2d4
chore: enable all initialStatues
0618 Dec 4, 2023
81d285d
test: change concurrencyLevel for yarn and yarn stable
0618 Dec 5, 2023
f45b6c8
add yarn-stable to test fails fast
0618 Dec 5, 2023
45090b2
chore: update changeset
0618 Dec 5, 2023
ac452fb
chore: change workflow trigger
0618 Dec 5, 2023
4728a4c
Merge branch 'main' into poc/fix-e2e
0618 Dec 5, 2023
0d83dd0
chore: yarn not install typescript in root folder
0618 Dec 5, 2023
5829bd3
chore: update package.lock
0618 Dec 5, 2023
ddf9e6c
Revert "chore: yarn not install typescript in root folder"
0618 Dec 5, 2023
e88dbee
chore: remove comment
0618 Dec 5, 2023
35ad270
Merge branch 'poc/package-manager-support' into poc/fix-e2e
0618 Dec 5, 2023
338457d
chore: fix typo
0618 Dec 5, 2023
f98ddb9
chore: rename yarn-classic and yarn modern
0618 Dec 5, 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
2 changes: 2 additions & 0 deletions .changeset/itchy-pigs-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
14 changes: 2 additions & 12 deletions .github/workflows/poc-e2e-flow-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: 'poc-e2e-flow-test'
on: # TODO: need to change the trigger
push:
branches:
- poc/e2e-create-amplify
- poc/pms-create-amplify

jobs:
install:
Expand Down Expand Up @@ -37,18 +37,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
pkg-manager: [npm, yarn, pnpm]
pkg-manager: [npm, yarn, yarn-stable, pnpm]
Copy link
Contributor

Choose a reason for hiding this comment

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

based on the discussion from the demo, can we name these something like yarn-classic and yarn-modern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed f98ddb9

node-version: [20]
include:
- os: ubuntu-latest
pkg-manager: yarn-stable
node-version: 19 # TODO: use Node 20 once https://github.com/yarnpkg/berry/pull/5961 is released
- os: macos-latest
pkg-manager: yarn-stable
node-version: 19 # TODO: use Node 20 once https://github.com/yarnpkg/berry/pull/5961 is released
- os: windows-latest
pkg-manager: yarn-stable
node-version: 19 # TODO: use Node 20 once https://github.com/yarnpkg/berry/pull/5961 is released
env:
ACKAGE_MANAGER_EXECUTABLE: ${{ matrix.pkg-manager }} # TODO: remove PACKAGE_MANAGER_EXECUTABLE once CLI is able to getPackageManager().
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize it's not part of this PR, but this seems to be setting the wrong env var

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!!! It's weird that the test ran as expected even with the wrong var name 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see ${{ matrix.pkg-manager }} was directly passed to the env var in the commend line. Github env var has never been used

runs-on: ${{ matrix.os }}
Expand Down
2,024 changes: 1,057 additions & 967 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/create-amplify/src/amplify_project_creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class AmplifyProjectCreator {
private readonly defaultDevPackages = [
'@aws-amplify/backend',
'@aws-amplify/backend-cli',
'typescript@^5.0.0',
'typescript@^5.0.0', // TODO: remove this line for yarn since it's installed in amplify/
Copy link
Member

Choose a reason for hiding this comment

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

is there any change here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed typescript from defaultDevPackages for yarn and yarn-stable because they need to be installed inside amplify/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

checked. amplify folder can't consume the package from its parent folder. It might work if we make it as a workspace, but I don't think we want to do that, do we?

];

private readonly defaultProdPackages = ['aws-amplify'];
Expand Down
33 changes: 32 additions & 1 deletion packages/create-amplify/src/initial_project_file_generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import fs from 'fs';
import _fs from 'fs/promises';
import { executeWithDebugLogger as _executeWithDebugLogger } from './execute_with_logger.js';
import { execa } from 'execa';
Expand All @@ -17,6 +18,12 @@ export class InitialProjectFileGenerator {
private readonly executeWithDebugLogger = _executeWithDebugLogger
) {}

private readonly executableName = !process.env.PACKAGE_MANAGER_EXECUTABLE
? 'npm'
: process.env.PACKAGE_MANAGER_EXECUTABLE === 'yarn-stable'
? 'yarn'
: process.env.PACKAGE_MANAGER_EXECUTABLE; // TODO: replace `process.env.PACKAGE_MANAGER_EXECUTABLE` with `getPackageManagerName()` once the test infra is ready.

/**
* Copies the template directory to an amplify folder within the projectRoot
*/
Expand All @@ -35,6 +42,16 @@ export class InitialProjectFileGenerator {
JSON.stringify(packageJsonContent, null, 2)
);

if (process.env.PACKAGE_MANAGER_EXECUTABLE === 'yarn-stable') {
fs.writeFile(path.resolve(targetDir, 'yarn.lock'), '', (err) => {
if (err) {
console.error(`Error creating ${targetDir}/${targetDir}`, err);
} else {
console.log(`${targetDir}/yarn.lock created successfully.`);
}
});
}

await this.initializeTsConfig(targetDir);
};

Expand All @@ -52,6 +69,20 @@ export class InitialProjectFileGenerator {
'es2022',
];

await this.executeWithDebugLogger(targetDir, 'npx', tscArgs, execa);
if (this.executableName.startsWith('yarn')) {
await this.executeWithDebugLogger(
targetDir,
'yarn',
['add', 'typescript@^5'],
execa
);
Comment on lines +73 to +78
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before we convert to hybrid PnP and Node_modules, we had to install typescript in amplify/ folder to make sure tsc works, but since we adopt the hybrid mode, I can try if we still need to install typescript.

Copy link
Member

Choose a reason for hiding this comment

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

please check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just checked and we have to install typescript at both root and amplify/ folder because

  1. amplify/ folder doesn't have access to the modoles in root folder if it's not a workspace
  2. we use tsc from the root folder in the e2e test for compile. Also we may use tsc for deploy.

}

await this.executeWithDebugLogger(
targetDir,
this.executableName === 'npm' ? 'npx' : this.executableName,
tscArgs,
execa
);
};
}
7 changes: 5 additions & 2 deletions packages/create-amplify/src/npm_project_initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export class NpmProjectInitializer {
private readonly execa = _execa
) {}

private readonly executableName =
process.env.PACKAGE_MANAGER_EXECUTABLE || 'npm'; // TODO: replace `process.env.PACKAGE_MANAGER_EXECUTABLE` with `getPackageManagerName()` once the test infra is ready.
private readonly executableName = !process.env.PACKAGE_MANAGER_EXECUTABLE
? 'npm'
: process.env.PACKAGE_MANAGER_EXECUTABLE === 'yarn-stable'
? 'yarn'
: process.env.PACKAGE_MANAGER_EXECUTABLE; // TODO: replace `process.env.PACKAGE_MANAGER_EXECUTABLE` with `getPackageManagerName()` once the test infra is ready.

/**
* If package.json already exists, this is a noop. Otherwise, `npm init` is executed to create a package.json file
Expand Down
Loading