greenkeeperio / greenkeeper-lockfile

:lock: Your lockfile, up to date, all the time
https://greenkeeper.io
183 stars 73 forks source link

CircleCI never updates #58

Open emmenko opened 7 years ago

emmenko commented 7 years ago

Hey guys,

we've noticed that on CircleCI greenkeeper-lockfile always skips to update.

image

This already happens when greenkeeper creates the branch (first commit).

By looking at the code it seems that the problem comes from correctBuild being false.

https://github.com/greenkeeperio/greenkeeper-lockfile/blob/e4ba1a322fab59b602c60d3f5427096a1775fe23/update.js#L33-L35

which is determined by

https://github.com/greenkeeperio/greenkeeper-lockfile/blob/e4ba1a322fab59b602c60d3f5427096a1775fe23/ci-services/circleci.js#L9

Now, if I look at the CI variables the CI_PULL_REQUEST is set

CI_PULL_REQUEST=https://github.com/xxx/xxx/pull/2204

So it seems that for CircleCI it will always skip to update.

What is the reason for using _.isEmpty(env.CI_PULL_REQUEST)? Is this supposed to work differently?

Thanks for the help!

emmenko commented 7 years ago

Short update here: in the last greenkeeper branch, it did work out at the end. By looking at the circleci env variables, it seems that at the time the build started, the PR was not created yet, thus the lockfile update worked as expected.

I'm wondering then if it's more of a race condition problem. By the time the build starts, if the PR is already created the lockfile update will be skipped, if the PR has not been created yet the lockfile update will run.

jasonLaster commented 6 years ago

I have a quick-fix branch here, that others can use. I'm not sure why we would want to ignore some branches from updating:

yarn global add greenkeeper-lockfile@github:jasonLaster/greenkeeper-lockfile

it seems that updating is cheap...

janl commented 6 years ago

Unsure about cheap, these are commits on the branch, we don’t want to be lackluster about them.

noahsw commented 6 years ago

Yarn would randomly fail to install this patch so I got this to work instead: yarn global add https://github.com/jasonLaster/greenkeeper-lockfile.git

paulmelnikow commented 6 years ago

In CircleCI it's difficult to detect whether or not a build is running on a pull request or a branch. This is from the Danger.js docs:

For setting up Circle CI, we recommend turning on "Only Build pull requests." in "Advanced Setting." Without this enabled, it is really tricky for Danger to know whether you are in a pull request or not, as the environment metadata isn't reliable. This may be different with Circle v2.

I wonder… would unsetting CI_PULL_REQUEST in the invocation of greenkeeper-lockfile-update have the same effect as @jasonLaster's quick-fix? This issue creates a bunch of extra work in Shields and I'd be happy for a workaround, especially if a correct solution is not possible. We squash-merge PR, so extra commits on the PR branch are not an issue.