-
Notifications
You must be signed in to change notification settings - Fork 49k
Add basic release script snapshot test #14280
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
Changes from 1 commit
b55f38e
0240640
c197be7
71c1046
341ebb3
bbb9d9e
4d53087
86d3036
43ac899
1018c30
baecb2e
26a00aa
b3d1a81
e624d14
3585929
0bbdbdd
40dde41
03abe2a
8747fa6
83745a7
02774ef
d30f652
38c8aca
82d170a
694b6a9
fce3353
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,9 @@ module.exports = ({cwd, dry, path, version}) => { | |
1. Open {yellow.bold ${standaloneFixturePath}} in the browser. | ||
2. It should say {italic "Hello world!"} | ||
3. Next go to {yellow.bold ${packagingFixturesPath}} and run {bold node build-all.js} | ||
4. Install the "serve" module ({bold npm install -g serve}) | ||
5. Go to the repo root and {bold serve -s .} | ||
6. Open {blue.bold http://localhost:5000/fixtures/packaging} | ||
4. Install the "pushstate-server" module ({bold npm install -g pushstate-server}) | ||
5. Go to the repo root and {bold pushstate-server -s .} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 9000 is the default port. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I see, fair. it throws an error with |
||
6. Open {blue.bold http://localhost:9000/fixtures/packaging} | ||
7. Verify every iframe shows {italic "Hello world!"} | ||
|
||
After completing the above steps, resume the release process by running: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const http = require('request-promise-json'); | ||
const {exec} = require('child-process-promise'); | ||
const {readdirSync} = require('fs'); | ||
const {readJsonSync} = require('fs-extra'); | ||
const {logPromise} = require('../utils'); | ||
|
||
const run = async ({build, cwd}) => { | ||
// https://circleci.com/docs/2.0/artifacts/#downloading-all-artifacts-for-a-build-on-circleci | ||
const metadataURL = `https://circleci.com/api/v1.1/project/github/facebook/react/${build}/artifacts?circle-token=${ | ||
process.env.CIRCLE_CI_API_TOKEN | ||
}`; | ||
const metadata = await http.get(metadataURL, true); | ||
const nodeModulesURL = metadata.find( | ||
entry => entry.path === 'home/circleci/project/node_modules.tgz' | ||
).url; | ||
|
||
// Download and extract artifact | ||
await exec(`rm -rf ${cwd}/build/node_modules*`); | ||
await exec(`curl ${nodeModulesURL} --output ${cwd}/build/node_modules.tgz`); | ||
await exec(`mkdir ${cwd}/build/node_modules`); | ||
await exec( | ||
`tar zxvf ${cwd}/build/node_modules.tgz -C ${cwd}/build/node_modules/` | ||
); | ||
|
||
// Unpack packages and parepare to publish | ||
const compressedPackages = readdirSync('build/node_modules/'); | ||
for (let i = 0; i < compressedPackages.length; i++) { | ||
await exec( | ||
`tar zxvf ${cwd}/build/node_modules/${ | ||
compressedPackages[i] | ||
} -C ${cwd}/build/node_modules/` | ||
); | ||
const packageJSON = readJsonSync( | ||
`${cwd}/build/node_modules/package/package.json` | ||
); | ||
await exec( | ||
`mv ${cwd}/build/node_modules/package ${cwd}/build/node_modules/${ | ||
packageJSON.name | ||
}` | ||
); | ||
} | ||
|
||
// Cleanup | ||
await exec(`rm ${cwd}/build/node_modules.tgz`); | ||
await exec(`rm ${cwd}/build/node_modules/*.tgz`); | ||
}; | ||
|
||
module.exports = async ({build, cwd}) => { | ||
return logPromise( | ||
run({build, cwd}), | ||
`Downloading artifacts from Circle CI for build ${chalk.yellow.bold( | ||
`${build}` | ||
)}` | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const commandLineArgs = require('command-line-args'); | ||
const commandLineUsage = require('command-line-usage'); | ||
const figlet = require('figlet'); | ||
|
||
const paramDefinitions = [ | ||
{ | ||
name: 'build', | ||
type: Number, | ||
description: | ||
'Circle CI build identifier (e.g. https://circleci.com/gh/facebook/react/<build>)', | ||
defaultValue: false, | ||
}, | ||
{ | ||
name: 'path', | ||
type: String, | ||
alias: 'p', | ||
description: | ||
'Location of React repository to release; defaults to [bold]{cwd}', | ||
defaultValue: '.', | ||
}, | ||
]; | ||
|
||
module.exports = () => { | ||
const params = commandLineArgs(paramDefinitions); | ||
|
||
if (!params.build) { | ||
const usage = commandLineUsage([ | ||
{ | ||
content: chalk | ||
.hex('#61dafb') | ||
.bold(figlet.textSync('react', {font: 'Graffiti'})), | ||
raw: true, | ||
}, | ||
{ | ||
content: | ||
'Prepare a Circle CI build to be published to NPM as a canary.', | ||
}, | ||
{ | ||
header: 'Options', | ||
optionList: paramDefinitions, | ||
}, | ||
{ | ||
header: 'Examples', | ||
content: [ | ||
{ | ||
desc: 'Example:', | ||
example: '$ ./prepare-canary.js [bold]{--build=}[underline]{12639}', | ||
}, | ||
], | ||
}, | ||
]); | ||
console.log(usage); | ||
process.exit(1); | ||
} | ||
|
||
return { | ||
...params, | ||
cwd: params.path, // For script convenience | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const {join, relative} = require('path'); | ||
|
||
module.exports = ({cwd, build, path}) => { | ||
const publishPath = relative( | ||
process.env.PWD, | ||
join(__dirname, '../publish.js') | ||
); | ||
const command = `${publishPath}` + (path ? ` -p ${path}` : ''); | ||
|
||
const packagingFixturesPath = join(cwd, 'fixtures/packaging'); | ||
const standaloneFixturePath = join( | ||
cwd, | ||
'fixtures/packaging/babel-standalone/dev.html' | ||
); | ||
|
||
console.log( | ||
chalk` | ||
{green.bold A potential canary has been prepared!} | ||
Next there are a couple of manual steps: | ||
|
||
{bold.underline Smoke test the packages} | ||
|
||
1. Open {yellow.bold ${standaloneFixturePath}} in the browser. | ||
2. It should say {italic "Hello world!"} | ||
3. Next go to {yellow.bold ${packagingFixturesPath}} and run {bold node build-all.js} | ||
4. Install the "pushstate-server" module ({bold npm install -g pushstate-server}) | ||
5. Go to the repo root and {bold pushstate-server -s .} | ||
6. Open {blue.bold http://localhost:9000/fixtures/packaging} | ||
7. Verify every iframe shows {italic "Hello world!"} | ||
|
||
After completing the above steps, you can publish this canary by running: | ||
{yellow.bold ${command}} | ||
`.replace(/\n +/g, '\n') | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const {handleError} = require('./utils'); | ||
|
||
const checkEnvironmentVariables = require('./shared-commands/check-environment-variables'); | ||
const downloadBuildArtifacts = require('./prepare-canary-commands/download-build-artifacts'); | ||
const parseParams = require('./prepare-canary-commands/parse-params'); | ||
const printSummary = require('./prepare-canary-commands/print-summary'); | ||
|
||
const run = async () => { | ||
try { | ||
const params = parseParams(); | ||
|
||
await checkEnvironmentVariables(params); | ||
await downloadBuildArtifacts(params); | ||
await printSummary(params); | ||
} catch (error) { | ||
handleError(error); | ||
} | ||
}; | ||
|
||
run(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you considered using npx for one off things like this? you could merge steps 4 and 5 with
npx pushstate-server . 9000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah maybe that's a good improvement :)