Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Use verdaccio to test create-project #877

Merged
merged 9 commits into from
May 17, 2018
Merged

Use verdaccio to test create-project #877

merged 9 commits into from
May 17, 2018

Conversation

eliperelman
Copy link
Member

@eliperelman eliperelman commented May 17, 2018

Fixes #702.

@eliperelman eliperelman requested a review from edmorley May 17, 2018 14:58
Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

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

Nice PR! The Travis end-to-end times are actually quicker than master, even with the added overhead (though guess since smaller matrix). Definitely a better tradeoff IMO.

package.json Outdated
"validate:eslintrc:root": "eslint --no-eslintrc --print-config . -c ./.eslintrc.js > /dev/null",
"validate:eslintrc:eslint": "eslint --no-eslintrc --print-config . -c ./packages/eslint/eslintrc.js > /dev/null",
"validate:eslintrc:airbnb": "eslint --no-eslintrc --print-config . -c ./packages/airbnb/eslintrc.js > /dev/null",
"validate:eslintrc:airbnb-base": "eslint --no-eslintrc --print-config . -c ./packages/airbnb-base/eslintrc.js > /dev/null",
"validate:eslintrc:standardjs": "eslint --no-eslintrc --print-config . -c ./packages/standardjs/eslintrc.js > /dev/null",
"validate:eslintrc": "yarn validate:eslintrc:eslint && yarn validate:eslintrc:airbnb-base && yarn validate:eslintrc:airbnb && yarn validate:eslintrc:standardjs && yarn validate:eslintrc:root",
"version": "yarn changelog --package && git add CHANGELOG.md"
"version": "([[ -n \"$NEUTRINO_RELEASE\" ]] && yarn changelog --package && git add CHANGELOG.md) || exit 0"
Copy link
Member

Choose a reason for hiding this comment

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

bash 4 and above has a new -v conditional for "is this variable set" that doesn't need the dollar sign or quotes - that could make this easier to read. Also the current || exit 0 will hide any real errors that occur during the changelog command.

Something like this should work? (Rather than using [[ ! -v NEUTRINO_RELEASE ]], I've inverted the conditional name/purpose to avoid the negation)

"version": "[[ -v SKIP_CHANGELOG ]] || yarn changelog --package && git add CHANGELOG.md"

...or using test (I can't decide which looks cleaner):

"version": "test -v SKIP_CHANGELOG || yarn changelog --package && git add CHANGELOG.md"

package.json Outdated
"release:preview": "yarn build && lerna publish --force-publish=* --skip-git --skip-npm",
"test": "yarn test:all --no-verbose --match '!*@neutrinojs*'",
"test:all": "nyc --reporter lcov ava --verbose --fail-fast packages/*/test",
"test": "ava --fail-fast packages/*/test '!packages/create-project/test'",
Copy link
Member

Choose a reason for hiding this comment

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

The !packages/create-project/test doesn't seem to work for me locally (the create project test still tries to run), however it might just be a Windows-only issue. (Happy to ignore so long as it works for you / on Travis)

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if it's because it should be double-quoted?

yarn verdaccio --config verdaccio.yml & sleep 10;
yarn config set registry "http://localhost:4873";
npm config set registry "http://localhost:4873";
scripts/npm-adduser.js;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's possible to use anonymous publish mode to avoid the need for the npm-adduser.js step and the npm dependency?
https://www.verdaccio.org/docs/en/authentification.html#anonymous-publish

Copy link
Member Author

Choose a reason for hiding this comment

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

Oooooooo lemme try.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I remember trying this but was unable to get it to work in the past. I'll try it again.

--skip-npm \
--registry http://localhost:4873/ \
--yes \
--repo-version $(node_modules/.bin/semver -i patch $(npm view neutrino version));
Copy link
Member

Choose a reason for hiding this comment

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

Could we use --cd-version here to avoid the external request and dep on semver?
https://github.com/lerna/lerna#--cd-version

If not, perhaps let's use yarn for the version lookup instead of npm (yarn info neutrino version).

--registry http://localhost:4873/ \
--yes \
--repo-version $(node_modules/.bin/semver -i patch $(npm view neutrino version));
yarn lerna exec npm publish --registry http://localhost:4873/;
Copy link
Member

Choose a reason for hiding this comment

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

Could we try using yarn instead of npm here?


test.serial(preset, async t => {
if (tester) {
Copy link
Member

Choose a reason for hiding this comment

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

There are only 3 lines different between the true and false case here - what do you think about flattening this conditional and inlining them, to reduce duplication/potential for deviation and clarify what's different?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

--yes \
--repo-version $(node_modules/.bin/semver -i patch $(npm view neutrino version));
yarn lerna exec npm publish --registry http://localhost:4873/;
yarn test:create-project;
Copy link
Member

Choose a reason for hiding this comment

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

Missing trailing newline

@@ -0,0 +1,15 @@
#! /usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

Could you change this to (whitespace and "strict mode"):

#!/usr/bin/env bash

set -euo pipefail

Also, the ; at the end of each line isn't needed (it's only required when skipping the newline between multiple commands).

Btw a handy tool for bash scripts linting is:
https://github.com/koalaman/shellcheck

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, lost this in one my my resets.

package.json Outdated
"link:all": "lerna exec yarn link",
"lint": "node packages/neutrino/bin/neutrino lint",
"precommit": "lint-staged",
"random": "node -e \"process.stdout.write(require('crypto').randomBytes(8).toString('hex'))\"",
"release": "yarn build && lerna publish --force-publish=*",
"release": "yarn build && NEUTRINO_RELEASE=true lerna publish --force-publish=*",
Copy link
Member

Choose a reason for hiding this comment

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

The pre-existing yarn build doesn't actually do anything as far as I can tell? Should we remove it (either now or at another time)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

import { packages } from '../commands/init/utils'

if (process.env.NODE_ENV !== 'test') {
process.env.NODE_ENV = 'test';
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing this isn't needed since Neutrino sets NODE_ENV appropriately anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

We used it to drive stdio, but it was no longer used:

54c4a02#diff-00d28c6e44b222cb04e29211b7fffe8aL23

@eliperelman
Copy link
Member Author

Alright, let's see what happens.

Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

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

The quoting change for yarn test fixed the issue for me btw :-)

package.json Outdated
"changelog": "auto-changelog --remote upstream --commit-limit false",
"link:all": "lerna exec yarn link",
"lint": "node packages/neutrino/bin/neutrino lint",
"precommit": "lint-staged",
"random": "node -e \"process.stdout.write(require('crypto').randomBytes(8).toString('hex'))\"",
"release": "yarn build && NEUTRINO_RELEASE=true lerna publish --force-publish=*",
"release": "SKIP_CHANGELOG=true lerna publish --force-publish=*",
Copy link
Member

Choose a reason for hiding this comment

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

The SKIP_CHANGELOG needs to be moved to test:create-project now

"test:all": "nyc --reporter lcov ava --verbose --fail-fast packages/*/test",
"release": "lerna publish --force-publish=*",
"release:preview": "lerna publish --force-publish=* --skip-git --skip-npm",
"test": "ava --fail-fast packages/*/test \"!packages/create-project/test\"",
Copy link
Member

Choose a reason for hiding this comment

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

Could you document yarn test (and possibly yarn test:create-project, depending on how well it works locally) in development.md? :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

export SKIP_CHANGELOG=true
export YARN_AUTH_TOKEN="//localhost:4873/:_authToken=token"

yarn verdaccio --config verdaccio.yml & sleep 10
Copy link
Member

Choose a reason for hiding this comment

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

One way to ensure verdaccio has started, but save spending the full 10 seconds if it was faster, would be to do:

yarn verdaccio --config verdaccio.yml &
yarn config set registry "http://localhost:4873"
# Wait until Verdaccio has started and is accepting connections.
while ! nc -zw 1 localhost 4873; do sleep 1; done

(The wait line deliberately being after the yarn config set, since it gives a few more seconds for verdaccio to start, whilst also making use of the time, before sitting around idle)


yarn verdaccio --config verdaccio.yml & sleep 10
yarn config set registry "http://localhost:4873"
npm config set registry "http://localhost:4873"
Copy link
Member

Choose a reason for hiding this comment

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

The npm config line is no longer needed I think?

@eliperelman eliperelman merged commit ef553a9 into neutrinojs:master May 17, 2018
edmorley added a commit that referenced this pull request Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

2 participants