From e0a745defdee0a1ee93d5e5a8986be5a014a3bcb Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 12 Jun 2017 21:17:06 +1000 Subject: [PATCH] add support for v8-canary builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/nodejs-nightly-builder/pull/1 Reviewed-By: João Reis --- README.md | 3 +-- list-builds.js | 10 ++++---- nightly-builder.js | 6 ++--- package.json | 11 +++++---- test.js | 57 ++++++++++++++++++++++++++++++++++++++++++++-- trigger-build.js | 4 ---- 6 files changed, 68 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c99a6f2..fc2fdfa 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,13 @@ $ nodejs-nightly-builder [--type ] --ref -- - ***"githubScheme"*** (optional, defaults to "https://github.com/"): the scheme for accessing the GitHub repository, including host and other components up to the "org/repo" - ***"githubAuthUser"***: the user for which the GitHub API is being accessed by - ***"githubAuthToken"***: the authentication token for accessing the API for the given user (e.g. obtained with https://github.com/rvagg/ghauth) - - ***"releaseUrlBase"*** (optional, defaults to "https://nodejs.org/download/"): the release URL base passed to `--configure` when building Node.js, this is given to Jenkins and passed down in to the builders, the `type` is appended to the end - ***"jenkinsToken"***: the token entered in the Jenkins job for building distributables, required to authenticate API triggered access - ***"jenkinsJobUrl"***: URL of the job being accessed, as you would as a normal user, e.g. "https://ci.nodejs.org/job/node-release" - ***"jenkinsCrumbUrl"***: the Jenkins API endpoint for obtaining a crumb for bypassing XSS checks during API access, e.g. "https://ci.nodejs.org/crumbIssuer/api/json" The GitHub API is used to check HEAD commits which is why an authentication token is required. -When run, `nodejs-nightly-builder` will first check whether a build is required. It does this by checking the file at `{releaseUrlBase}{type}/index.json`, where `{releaseUrlBase}` comes from the config file and `type` is provided on the commandline, e.g. `https://nodejs.org/download/nightly/index.json`. Nightly builds contain a commit sha that can be decoded from their version string. The HEAD commit is also pulled from GitHub for the `ref` (branch) provided on the commandline. If the latest build does not match the HEAD commit, a new nightly build is required. Nightly builds are triggered with Jenkins. +When run, `nodejs-nightly-builder` will first check whether a build is required. It does this by checking the file at `https://nodejs.org/download/{type}/index.json`, where `type` is provided on the commandline, e.g. `https://nodejs.org/download/nightly/index.json`. Nightly builds contain a commit sha that can be decoded from their version string. The HEAD commit is also pulled from GitHub for the `ref` (branch) provided on the commandline. If the latest build does not match the HEAD commit, a new nightly build is required. Nightly builds are triggered with Jenkins. ----------------------------------- diff --git a/list-builds.js b/list-builds.js index 7e65406..6319ca6 100644 --- a/list-builds.js +++ b/list-builds.js @@ -2,13 +2,11 @@ const jsonist = require('jsonist') -const indexUrl = '{releaseUrlBase}{type}/index.json' +const indexUrl = 'https://nodejs.org/download/{type}/index.json' function listBuilds (type, config, callback) { - let url = indexUrl - .replace(/\{type\}/, type) - .replace(/\{releaseUrlBase\}/, config.releaseUrlBase) + let url = indexUrl.replace(/\{type\}/, type) function onGet (err, data) { if (err) @@ -18,7 +16,7 @@ function listBuilds (type, config, callback) { return callback(new Error(`no builds for "${type}"`)) data = data.map(function (d) { - let m = d.version.match(/nightly(20\d\d)(\d\d)(\d\d)([0-9a-f]{7,})/) + let m = d.version.match(/(?:nightly|v8-canary)(20\d\d)(\d\d)(\d\d)([0-9a-f]{7,})/) , date = new Date(m && `${m[1]}-${m[2]}-${m[3]}` || d.date) , commit = m && m[4] @@ -41,7 +39,7 @@ function listBuilds (type, config, callback) { module.exports = listBuilds if (require.main == module) { - listBuilds('nightly', function (err, data) { + listBuilds(process.argv[2] || 'nightly', function (err, data) { if (err) throw err diff --git a/nightly-builder.js b/nightly-builder.js index 84a1e75..34c7be4 100755 --- a/nightly-builder.js +++ b/nightly-builder.js @@ -17,7 +17,6 @@ const argv = require('minimist')(process.argv.slice(2)) githubOrg : 'nodejs' , githubRepo : 'node' , githubScheme : 'https://github.com/' - , releaseUrlBase : 'https://nodejs.org/download/' } if (typeof argv.type != 'string') @@ -26,7 +25,7 @@ if (typeof argv.type != 'string') let config = argv.config && require(argv.config) config = xtend(defaultConfig, config) -if (!/^(nightly|next-nightly)$/.test(argv.type) +if (!/^(nightly|v8-canary)$/.test(argv.type) || typeof argv.ref != 'string' || typeof config.jenkinsToken != 'string' || typeof config.jenkinsJobUrl != 'string' @@ -36,11 +35,10 @@ if (!/^(nightly|next-nightly)$/.test(argv.type) || typeof config.githubRepo != 'string' || typeof config.githubOrg != 'string' || typeof config.githubScheme != 'string' - || typeof config.releaseUrlBase != 'string' ) { console.error('Invalid arguments or config') - console.error('Usage: nodejs-nightly-builder [--type ] --ref --config [--force]') + console.error('Usage: nodejs-nightly-builder [--type ] --ref --config [--force]') return process.exit(1) } diff --git a/package.json b/package.json index 1f35679..3bef8e8 100644 --- a/package.json +++ b/package.json @@ -14,18 +14,19 @@ }, "dependencies": { "after": "~0.8.2", - "bl": "~1.1.2", + "bl": "~1.2.1", "ghrepos": "~2.0.0", - "hyperquest": "~2.1.0", - "jsonist": "~1.3.0", + "hyperquest": "~2.1.2", + "jsonist": "~2.1.0", + "level": "~1.7.0", "minimist": "~1.2.0", - "strftime": "~0.9.2", + "strftime": "~0.10.0", "xtend": "~4.0.1" }, "devDependencies": { "application-config": "~1.0.1", "ghauth": "~3.2.1", - "tape": "~4.6.2" + "tape": "~4.6.3" }, "bin": { "nodejs-nightly-builder": "./nightly-builder.js" diff --git a/test.js b/test.js index 6c15e1a..71fc8f5 100644 --- a/test.js +++ b/test.js @@ -35,11 +35,34 @@ test('list-builds', function (t) { t.ok(data[0].date < new Date(), `date (${data[0].date.toISOString()}) looks correct`) t.ok(data[0].commit && data[0].commit.length >= 10, `commit (${data[0].commit}) looks right`) t.notEqual(data[0].commit, other, 'commit not the same as other type of commit') - other = data[0].commit // who's gonna be first?? + other = data[0].commit // who's gonna be first?? } } - listBuilds('nightly', { releaseUrlBase: 'https://nodejs.org/download/' }, verify()) + listBuilds('nightly', {}, verify()) +}) + + +test('list-builds v8-canary', function (t) { + t.plan(7) + let other = null + + + function verify () { + return function (err, data) { + t.error(err, 'no error') + t.ok(Array.isArray(data), 'is array') + t.ok(data.length >= 1, 'has data') + let m = data[0].version && data[0].version.match(/v\d+\.\d+\.\d+-v8-canary20\d{6}\w{10,}/) + t.ok(m, `version (${data[0].version}) looks correct`) + t.ok(data[0].date < new Date(), `date (${data[0].date.toISOString()}) looks correct`) + t.ok(data[0].commit && data[0].commit.length >= 10, `commit (${data[0].commit}) looks right`) + t.notEqual(data[0].commit, other, 'commit not the same as other type of commit') + other = data[0].commit // who's gonna be first?? + } + } + + listBuilds('v8-canary', {}, verify()) }) @@ -71,3 +94,33 @@ test('latest-commit', function (t) { }, verify()) }) }) + + +test('latest-commit v8-canary', function (t) { + t.plan(4) + let other = null + + appCfg(authOptions.configName).read(function (err, config) { + if (err) { + console.error('You need GitHub authentication credentials saved first, run `node test.js auth` to set this up') + return process.exit(1) + } + + function verify () { + return function (err, sha) { + t.error(err, 'no error') + t.equal(typeof sha, 'string', 'got sha') + t.equal(sha.length, 40, `sha looks good (${sha})`) + t.notEqual(sha, other, 'sha not the same as other type of sha') + other = sha // who's gonna be first?? + } + } + + latestCommit('v8-canary', 'heads/canary', { + githubOrg : 'nodejs' + , githubRepo : 'node-v8' + , githubAuthUser : config.user + , githubAuthToken : config.token + }, verify()) + }) +}) diff --git a/trigger-build.js b/trigger-build.js index a4ce472..a71c4f9 100644 --- a/trigger-build.js +++ b/trigger-build.js @@ -29,10 +29,6 @@ function triggerBuild(options, callback) { name : 'disttype' , value : options.type } - , { - name : 'release_urlbase' - , value : `${options.releaseUrlBase}${options.type}/` - } , { name : 'rc' , value : '0'