semantic-release / condition-travis

:no_entry_sign: semantic-release plugin to check Travis CI environment before publishing.
MIT License
9 stars 11 forks source link

Support Travis Enterprise #100

Closed SimenB closed 6 years ago

SimenB commented 6 years ago

See https://github.com/semantic-release/semantic-release/issues/540

I'd be happy to provide a PR for this 🙂

SimenB commented 6 years ago

BTW, have you tried emailing Travis about getting access to an enterprise instance for testing? I haven't mailed them before, but I'm hopeful they'd be positive towards helping with an integration for semantic-release.

https://docs.travis-ci.com/user/enterprise/#Trials-and-Licensing

SimenB commented 6 years ago

Anyways, I can test on Travis Enterprise as we use it at work. Ay ideas on where to start? I have no idea from where the call which fails even comes from.

(and I don't think I can remotely debug either, so it'll be push and see what happnes...)

pvdlg commented 6 years ago

The problem is actually in https://github.com/semantic-release/travis-deploy-once which use https://github.com/pwmckenna/node-travis-ci. Unfortunately pwmckenna/node-travis-ci doesn't support Travis Enterprise. See lib/travis-http.js#L5.

In condition-travis we need to:

Then semantic-release/travis-deploy-once will have to make API calls with this url. There is multiple approach to achieve (by order of preference):

We would gladly accept PRs on all that!

For now you can also set the environment variable BUILD_LEADER_ID to select on which job number semantic-release should run. By doing so the call to semantic-release/travis-deploy-once will be skipped and no API call will be made. See an example here (The build stage part is not required).

SimenB commented 6 years ago

There is https://github.com/pwmckenna/node-travis-ci/issues/21

Which was opened up by a colleague of mine, so I should probably sync with him!

pvdlg commented 6 years ago

👍 It seems a PR would be welcomed to solve pwmckenna/node-travis-ci#21 :)

SimenB commented 6 years ago

PR sent. Not sure if it'll be released right away, though: https://github.com/pwmckenna/node-travis-ci/pull/19#issuecomment-346230739

I'll try the workaround!

SimenB commented 6 years ago

BUILD_LEADER_ID seems ignored - all 3 of my builds (node 8, 6, and 9) try to run semantic-release, and they all fail with the api error towards travis.

Setting environment variables from .travis.yml
...
$ export BUILD_LEADER_ID=1
pvdlg commented 6 years ago

That's quite surprising....The Node 6 job should exit right away due to https://github.com/semantic-release/semantic-release/blob/caribou/bin/semantic-release.js#L9

What value did you set for BUILD_LEADER_ID ?

pvdlg commented 6 years ago

Not if Travis allow to export variables like that. Can you set it in your travis.yml like that:

env:
  - BUILD_LEADER_ID=1
SimenB commented 6 years ago

Oh sorry, I lied. Node 6 is not ran! Both node 8 and node 9 is, though

Relevant part of my .travis.yml:

env:
  global:
  - GITHUB_URL=https://github.schibsted.io
  - GITHUB_PREFIX=/api/v3
  - NPM_USERNAME=$ARTIFACTORY_USER
  - NPM_PASSWORD=$ARTIFACTORY_NPM_SECRET
  - NPM_EMAIL=$ARTIFACTORY_USER
  - BUILD_LEADER_ID=1
  - secure: some token

With output on travis being:

Setting environment variables from .travis.yml
$ export GITHUB_URL=https://github.schibsted.io
$ export GITHUB_PREFIX=/api/v3
$ export NPM_USERNAME=$ARTIFACTORY_USER
$ export NPM_PASSWORD=$ARTIFACTORY_NPM_SECRET
$ export NPM_EMAIL=$ARTIFACTORY_USER
$ export BUILD_LEADER_ID=1
$ export GH_TOKEN=[secure]
SimenB commented 6 years ago

From what I can see in the code, the auth request to travis is always sent: https://github.com/semantic-release/travis-deploy-once/blob/ad21dc45a20f9029d3f14758e9ca7d58d4bc2eae/lib/travis-deploy-once.js#L31

pvdlg commented 6 years ago

Looking at the code more in detail the workaround will not work... The API is called no matter what...Sorry for the confusion.

SimenB commented 6 years ago

I looked into sending a PR, but because of waitForOtherJobs there's no way to avoid the API calls (unless I use build stages, I suppose, but those are not available on the version of Travis we're on)

pvdlg commented 6 years ago

Yes, we test if there is other jobs and if they are completed, even with Build stages enabled.

SimenB commented 6 years ago

Ok. Will give pwmckenna/node-travis-ci#22 a couple of days then, before I start thinking about replacing it in semantic-release/travis-deploy-once 🙂

Will send a PR to this repo tomorrow anyways, it's getting late

pvdlg commented 6 years ago

If we had to to re-implment the calls with an http library it would be great to do so with the API v3. As v2 is deprecated.