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 self-update #676

Merged
merged 6 commits into from Oct 17, 2016
Merged

Fix self-update #676

merged 6 commits into from Oct 17, 2016

Conversation

danez
Copy link
Contributor

@danez danez commented Oct 11, 2016

This fixes self-update by doing:

  • enable the tests
  • use npm run build in the test instad of make build
  • invalidated roadrunner cache, so that the symlink to current gets reevaluated
  • do not do the request to github for the assets as they are already included in the release response
  • pick the correct asset from the asset list by doing a name-check (content-type is sometimes set to octet-stream for the tar file, so we can't use that)

The roadrunner change is necessary as the tests need to invalidate the path cache so that the next test can reevaluate the symlinks. Same for the actual self-update command which also changes the symlink. This depends on kittens/roadrunner#1

Fixes #612

Docs: yarnpkg/website#173

@danez danez mentioned this pull request Oct 11, 2016
@danez danez changed the title Enable self-update tests Fix self-update Oct 12, 2016
@bestander
Copy link
Member

Nice!
Should we wait for roadrunner fix to be propagated to upstream?

@danez
Copy link
Contributor Author

danez commented Oct 12, 2016

Yes I think so. @kittens can you have a look at kittens/roadrunner#1 ?

@@ -38,6 +38,7 @@ export function getModuleCacheDirectory(): string {
export const MODULE_CACHE_DIRECTORY = getModuleCacheDirectory();
export const LINK_REGISTRY_DIRECTORY = `${MODULE_CACHE_DIRECTORY}/.link`;
export const GLOBAL_MODULE_DIRECTORY = `${MODULE_CACHE_DIRECTORY}/.global`;
export const CACHE_FILENAME = path.join(userHome, '.yarn', '.roadrunner.json');
Copy link
Contributor Author

@danez danez Oct 12, 2016

Choose a reason for hiding this comment

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

I would like to use this variable in bin/yarn.js, but afaics I cannot simple import this file there right? Currently this line is duplicate here and in bin/yarn.js

Copy link
Member

Choose a reason for hiding this comment

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

.yarn is prone to change afaik.
There should be a constant with the folder 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.

I can extract that to an other constant, but then still it wouldn't be usable in bin/yarn.js I think.

return run(async (reporter, config) => {
// mock an existing self-update
await child.exec('make build');
await child.exec('npm run build');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is probably safe to assume that npm is available when running tests?

Copy link
Member

@bestander bestander Oct 12, 2016

Choose a reason for hiding this comment

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

Can we do "kpm run build"? :)
For now, yeah, we can assume there is some npm version on the dev environment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean yarn ? :P

Copy link
Member

Choose a reason for hiding this comment

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

Oh yeah, kpm has been engraved in my brain now :)

const version = await child.exec('node bin/yarn.js -V');
expect(version[0].trim(), `0.11.0`);
expect(version[0].trim(), '0.14.1');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to update the version as <0.14 was using the name kpm in the release


expect(await fs.exists(path.resolve(updatesFolder, 'v0.98.0'))).toBe(false);
expect(await fs.exists(path.resolve(updatesFolder, 'v0.99.0'))).toBe(true);
expect(await fs.exists(path.resolve(updatesFolder, 'v0.11.0'))).toBe(true);
expect(await fs.exists(path.resolve(updatesFolder, 'v0.15.0'))).toBe(true);
Copy link
Contributor Author

@danez danez Oct 12, 2016

Choose a reason for hiding this comment

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

This is updated to use 0.15 to check it picks the correct asset.

Copy link
Member

@Daniel15 Daniel15 left a comment

Choose a reason for hiding this comment

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

I think we can remove all the Github API stuff from this. Instead of using the Github API, you can hit https://yarnpkg.com/latest-version to get the version number. Then you can simply hit https://yarnpkg.com/latest.tar.gz to get the latest tarball. Much simpler 😄 . There's also https://yarnpkg.com/downloads/{version}/{file} for specific version.

@bestander
Copy link
Member

Good point, @Daniel15, dropping Github wrapper from dependencies is good for size and startup performance.
Limiting self-update to latest is a limitation but I guess reasonable.

@bestander
Copy link
Member

A good RFC discussion is how to enable self-update to be automatic.

@Daniel15
Copy link
Member

A good RFC discussion is how to enable self-update to be automatic.

For what it's worth, updates are handled along with the rest of the operating system if you use the Linux package (Ubuntu/Debian/CentOS), that's one major advantage of using them and one of the main reasons we built them :)

@bestander
Copy link
Member

Well, I mean the other 99.5 percent of users who don't use Linux :)

On 12 October 2016 at 20:29, Daniel Lo Nigro notifications@github.com
wrote:

A good RFC discussion is how to enable self-update to be automatic.

For what it's worth, updates are handled along with the rest of the
operating system if you use the Linux package (Ubuntu/Debian/CentOS),
that's one major advantage of using them and one of the main reasons we
built them :)


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#676 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACBdWKGAZSYIUIj8mYuKaKfjL6sgUFdKks5qzTUXgaJpZM4KT7EC
.

@Daniel15
Copy link
Member

@bestander Chocolatey handles updates too I believe, so Windows users are covered too once our Chocolatey package is approved. The Windows dev userbase is larger than the Mac OS dev userbase 😛 . The Windows installer probably needs a proper auto-update too, that downloads the latest MSI and installs it.

@bestander
Copy link
Member

bestander commented Oct 12, 2016

You don't expect every version of windows to install yarn with chocolatey?
But bikeshedding aside, I think we need to decide whether we want to keep this feature here or ditch it. If we keep it then let's offer users whether to enable it by default.

Some history: I added it here when we found that maintaining packages via yummy and Chef was too much hassle and it seemed like a reasonable idea to have a lightweight mechanism to get everyone on the same version within the org.
In the end we ended up checking in yarn.js instead of relying on Chef or building our own Chef for yarn self-updates.

As for the community project, I think we get quite a lot of benefits if most of users are getting updated to the latest stable whether it is done via package managers or via self-update.

@bestander
Copy link
Member

Also I am not a huge fan of this implementation, a bit too hacky

@danez
Copy link
Contributor Author

danez commented Oct 12, 2016

For macOS probably adding yarn to brew might probably also make it easy to install and update there.

How do we want to proceed with this PR? Should I do all the mentioned changes (not github etc.) and later you can still decide to remove/simplify it?

@bestander
Copy link
Member

@danez, let's do as @Daniel15 suggests and use the website API to get latest version.
Are you up to it?
We can bikeshed about whether we need this feature or enable it later.

@Daniel15
Copy link
Member

Should I do all the mentioned changes (not github etc.) and later you can still decide to remove/simplify it?

Yeah, that sounds good to me! Sorry I went a little off-topic in the comments. Removing all the Github stuff should simplify it quite a bit :)

@ithinkihaveacat
Copy link

@Daniel15 I don't know the implications of this but right now https://yarnpkg.com/latest-version does not list the latest version:

$ yarn -V
0.15.1
$ curl -s https://yarnpkg.com/latest-version
0.15.0

@bestander
Copy link
Member

Michael, could you file a bug?

On 13 October 2016 at 11:23, Michael Stillwell notifications@github.com
wrote:

@Daniel15 https://github.com/Daniel15 I don't know the implications of
this but right now https://yarnpkg.com/latest-version does not list the
latest version:

$ yarn -V
0.15.1
$ curl -s https://yarnpkg.com/latest-version
0.15.0


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#676 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACBdWM511I6iJJToPDjKCRw8WUbM6W2Gks5qzgaFgaJpZM4KT7EC
.

@danez
Copy link
Contributor Author

danez commented Oct 13, 2016

This is probably because there was no release (in as a consequence no new tarball) created on github, only the tag in git.

https://github.com/yarnpkg/yarn/releases

@ithinkihaveacat
Copy link

@bestander Sure, reported as #989.

@Daniel15
Copy link
Member

0.15.1 is not a "real" release, it was just a patch to the tarball and npm
package. All the other installation methods are still at 0.15.0

Sent from my phone.

On Oct 13, 2016 3:51 AM, "Michael Stillwell" notifications@github.com
wrote:

@bestander https://github.com/bestander Sure, reported as #989
#989.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#676 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAFnHQsKcGtR4pvU3NNbVc7ZxPH8-xr3ks5qzg0OgaJpZM4KT7EC
.

Copy link
Member

@Daniel15 Daniel15 left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@@ -33,7 +32,7 @@
"request": "^2.75.0",
"request-capture-har": "^1.1.4",
"rimraf": "^2.5.0",
"roadrunner": "^1.0.6",
"roadrunner": "danez/roadrunner#patch-1",
Copy link
Member

Choose a reason for hiding this comment

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

Should we wait for a release of roadrunner before merging this?

@@ -2237,14 +2223,6 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"

github@2.5.1:
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👍 🎉

@danez
Copy link
Contributor Author

danez commented Oct 13, 2016

The test are still failing, because of 0.15.1.

The problem is that https://yarnpkg.com/latest-version says to 0.15.0, but when downloading latest.tar.gz the package.json in this archive says 0.15.1. Im gonna try instead of relying on the package.json instead see where the current symlink points.

@Daniel15
Copy link
Member

It's tricky because 0.15.1 is not a "real" release - It was just a fixed re-release of the npm package and tarball, but everything else (Windows installer, Linux packages) are still on 0.15.0

@GantMan
Copy link

GantMan commented Oct 13, 2016

looking forward to this 👍

var path = require('path');
var CACHE_FILENAME = path.join(userHome, '.yarn', '.roadrunner.json');
mkdirp.sync(path.dirname(CACHE_FILENAME));
var constants = require('../lib-legacy/constants');
Copy link
Contributor Author

@danez danez Oct 13, 2016

Choose a reason for hiding this comment

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

I now also require constants here from lib-legacy, so that I can use the folder constants. I think that shouldn't be a problem.

version "1.0.6"
resolved "https://registry.yarnpkg.com/roadrunner/-/roadrunner-1.0.6.tgz#e466a15f9844289413d09943ad263574623ec1c9"
resolved "https://codeload.github.com/danez/roadrunner/tar.gz/2ead9501e3681fa7584b79e6e6546fb046a83f54"
Copy link
Member

Choose a reason for hiding this comment

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

Let's push the change upstream before merging this.

@danez
Copy link
Contributor Author

danez commented Oct 14, 2016

I noticed that it is possible to download a certain version of yarn see #751 (comment)
Should I add back the possibility to specify the version?

@Daniel15
Copy link
Member

Daniel15 commented Oct 14, 2016

Should I add back the possibility to specify the version?

Let's keep it simple - It's totally fine to only support updating to the most recent version 😄

@jamiebuilds
Copy link
Contributor

@danez you have a broken test:

 FAIL  __tests__/commands/self-update.js (10.597s)
  ● Self-update should work from self-updated location

    Error: Command failed: yarn run build
    /bin/sh: 1: yarn: not found

    Console output:


      at __tests__/commands/self-update.js:57:13
      at throw (native)
      at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at node_modules/babel-runtime/helpers/asyncToGenerator.js:30:20

  ✓ Self-update should download a release and symlink it as "current" (10365ms)
  ✕ Self-update should work from self-updated location (73ms)

@danez
Copy link
Contributor Author

danez commented Oct 17, 2016

CircleCI is not updating the dependencies :(

@bestander
Copy link
Member

I'll restart with cache clean

@danez
Copy link
Contributor Author

danez commented Oct 17, 2016

Seems there is no step on circleCI to install dependencies? At least I can't see one.

@bestander
Copy link
Member

bestander commented Oct 17, 2016

Yeah, odd, looks like cleaning all cache lost eslint and webpack.
Update: oh, yeah we were missing yarn install in circle.yml

@bestander
Copy link
Member

Created this one #1157

@bestander
Copy link
Member

@danez, could you please rebase it?
This should work now

Pick the correct file to download in self-update
We cannot rely that the first asset is always the tar file
This picks the correct file from the assets

Use dev version of roadrunner and reset it correctly

Enable self-update tests
@danez
Copy link
Contributor Author

danez commented Oct 17, 2016

Seems circleCI is to slow to run the tests :/ The test is anyway really ugly, and involves building yarn, so not sure if we should keep it.

@bestander
Copy link
Member

Hm, I would assume that download gets stuck.
Building yarn should be quite fast though.
This is an important test because it checks that self-update did not degrade because of the symlinks and yarn inside yarn situation.

What do you think of keeping this test disabled for a while and merge the rest?
Great work anyway!

@danez
Copy link
Contributor Author

danez commented Oct 17, 2016

Okay I disabled it now, even after 3 minutes it was running into a timeout.

As all the other downloads seem to be quiet fast it might also be the FS which is slow, and we copy a lot of stuff in this test.

@bestander bestander merged commit b584b4f into yarnpkg:master Oct 17, 2016
@bestander
Copy link
Member

Thanks, @danez!

@danez danez deleted the enable-self-update-tests branch October 17, 2016 14:56
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.

self-update throws error
6 participants