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: fix create amplify installation in canary tests #635

Merged
merged 4 commits into from
Nov 13, 2023

Conversation

sobolk
Copy link
Member

@sobolk sobolk commented Nov 13, 2023

Issue #, if available:

Description of changes:

Fixes race condition that has been showing up in canary tests. I.e. it seems that running create-amplify with cold cache can result in corruption.

Sample logs:

sh: 1: create-amplify: not found
npm ERR! code 127
npm ERR! path /tmp/test-amplifya8FJI2
npm ERR! command failed
npm ERR! command sh -c create-amplify

npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2023-11-13T15_06_16_679Z-debug-0.log
npm ERR! code ENOTEMPTY
npm ERR! syscall rmdir
npm ERR! path /home/runner/.npm/_npx/337b6232b4e18c04/node_modules/iconv-lite/encodings
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rmdir '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/iconv-lite/encodings'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/y18n/build/index.cjs'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/escalade/dist/index.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/which/bin/node-which'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/cross-spawn/lib/enoent.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/mute-stream/lib/index.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/chalk/source/index.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/@inquirer/type/dist/cjs'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/command.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/y18n/build/lib'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/cross-spawn/lib/util'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/chalk/source/templates.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/error.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/chalk/source/util.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/y18n/build/lib'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/yargs-parser/build/lib'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/cross-spawn/lib/parse.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/y18n/build/lib'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/yargs-parser/build/lib'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/escalade/dist/index.mjs'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/cross-spawn/lib/util'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/kill.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/pipe.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/yargs-parser/build/lib'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/cross-spawn/lib/util'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/promise.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/stdio.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/yargs-parser/build/lib'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/stream.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/execa/lib/verbose.js'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/yargs-parser/build/lib'
npm ERR! code ENOTEMPTY
npm ERR! syscall rmdir
npm ERR! path /home/runner/.npm/_npx/337b6232b4e18c04/node_modules/cliui/build
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rmdir '/home/runner/.npm/_npx/337b6232b4e18c04/node_modules/cliui/build'

npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2023-11-13T16_06_18_016Z-debug-0.log
node:internal/errors:496

Test run
https://github.com/aws-amplify/amplify-backend/actions/runs/6853040384/job/18632951365

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

changeset-bot bot commented Nov 13, 2023

🦋 Changeset detected

Latest commit: 80de5ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines +40 to +47
// Force 'create-amplify' installation in npx cache by executing help command
// before tests run. Otherwise, installing 'create-amplify' concurrently
// may lead to race conditions and corrupted npx cache.
await execa('npm', ['create', 'amplify', '--yes', '--', '--help'], {
// Command must run outside of 'amplify-backend' workspace.
cwd: os.homedir(),
stdio: 'inherit',
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed with @Amplifiyer offline. and logged #637 to seek better solution.

@sobolk sobolk merged commit 1c602f6 into main Nov 13, 2023
20 checks passed
@sobolk sobolk deleted the install-create-amplify-not-in-parallel branch November 13, 2023 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants