Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
fix: use all jobs (e.g. matrix) for job leader election, not just "no…
Browse files Browse the repository at this point in the history
…de_js"
  • Loading branch information
boennemann authored and gr2m committed Aug 19, 2017
1 parent c30fe65 commit 9dadfd1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = async function travisDeployOnce (input) {
const buildId = parseInt(env.TRAVIS_BUILD_ID, 10)
const buildApi = travis.builds(buildId)
try {
var {build: {config, job_ids: jobs}} = await promisify(buildApi.get.bind(buildApi))()
var {jobs} = await promisify(buildApi.get.bind(buildApi))()
} catch (err) {
// https://github.com/semantic-release/travis-deploy-once/issues/3
// https://github.com/pwmckenna/node-travis-ci/issues/17
Expand All @@ -46,9 +46,9 @@ Go to https://travis-ci.com/, login with the GitHub user of this token and then
throw err
}

const buildLeader = env.BUILD_LEADER_ID || (config.node_js
? electBuildLeader(config.node_js)
: 1)
const buildLeader = env.BUILD_LEADER_ID || electBuildLeader(
jobs.map(job => job.config.node_js)
)

if (!env.TRAVIS_JOB_NUMBER.endsWith(`.${buildLeader}`)) return null
if (env.TRAVIS_TEST_RESULT === '1') return false
Expand All @@ -58,13 +58,13 @@ Go to https://travis-ci.com/, login with the GitHub user of this token and then
let attempt = 0
while (++attempt) {
let successes = 0
for (let jobId of jobs) {
if (jobId === currentJobId) {
for (let {id} of jobs) {
if (id === currentJobId) {
successes++
continue
}

const jobApi = travis.jobs(jobId)
const jobApi = travis.jobs(id)
const {job} = await promisify(jobApi.get.bind(jobApi))()

if (job.allow_failure) {
Expand Down

0 comments on commit 9dadfd1

Please sign in to comment.