Merge pull request #17803 from atom/aw/build-ci

Use npm and apm ci in CI builds
This commit is contained in:
Ash Wilson 2018-08-08 13:51:01 -04:00 committed by GitHub
commit 6367f82cc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 2237 additions and 2214 deletions

View File

@ -27,7 +27,7 @@ install:
- source /tmp/.nvm/nvm.sh
- nvm install $NODE_VERSION
- nvm use --delete-prefix $NODE_VERSION
- npm install -g npm@6.1.0
- npm install --global npm@6.2.0
- script/build --create-debian-package --create-rpm-package --compress-artifacts
script:

View File

@ -36,6 +36,7 @@ install:
- IF NOT EXIST %TEST_JUNIT_XML_ROOT% MKDIR %TEST_JUNIT_XML_ROOT%
- SET PATH=C:\Program Files\Atom\resources\cli;%PATH%
- ps: Install-Product node $env:NODE_VERSION $env:PLATFORM
- npm install --global npm@6.2.0
build_script:
- CD %APPVEYOR_BUILD_FOLDER%

View File

@ -17,6 +17,14 @@ process.on('unhandledRejection', function (e) {
process.exit(1)
})
// We can't use yargs until installScriptDependencies() is executed, so...
let ci = process.argv.indexOf('--ci') !== -1
if (!ci && process.env.CI === 'true' && process.argv.indexOf('--no-ci') === -1) {
console.log('Automatically enabling --ci because CI is set in the environment')
ci = true
}
verifyMachineRequirements()
if (dependenciesFingerprint.isOutdated()) {
@ -25,13 +33,13 @@ if (dependenciesFingerprint.isOutdated()) {
if (process.platform === 'win32') deleteMsbuildFromPath()
installScriptDependencies()
installApm()
installScriptDependencies(ci)
installApm(ci)
childProcess.execFileSync(
CONFIG.getApmBinPath(),
['--version'],
{stdio: 'inherit'}
)
runApmInstall(CONFIG.repositoryRootPath)
runApmInstall(CONFIG.repositoryRootPath, ci)
dependenciesFingerprint.write()

View File

@ -24,6 +24,7 @@ const argv = yargs
.describe('generate-api-docs', 'Only build the API documentation')
.describe('install', 'Install Atom')
.string('install')
.describe('ci', 'Install dependencies quickly (package-lock.json files must be up to date)')
.wrap(yargs.terminalWidth())
.argv

View File

@ -76,8 +76,8 @@ function getApmBinPath () {
return path.join(apmRootPath, 'node_modules', 'atom-package-manager', 'bin', apmBinName)
}
function getNpmBinPath () {
function getNpmBinPath (external = false) {
const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const localNpmBinPath = path.resolve(repositoryRootPath, 'script', 'node_modules', '.bin', npmBinName)
return fs.existsSync(localNpmBinPath) ? localNpmBinPath : npmBinName
return !external && fs.existsSync(localNpmBinPath) ? localNpmBinPath : npmBinName
}

View File

@ -4,8 +4,9 @@ const childProcess = require('child_process')
const CONFIG = require('../config')
module.exports = function () {
module.exports = function (ci) {
console.log('Installing apm')
// npm ci leaves apm with a bunch of unmet dependencies
childProcess.execFileSync(
CONFIG.getNpmBinPath(),
['--global-style', '--loglevel=error', 'install'],

View File

@ -4,11 +4,11 @@ const childProcess = require('child_process')
const CONFIG = require('../config')
module.exports = function () {
module.exports = function (ci) {
console.log('Installing script dependencies')
childProcess.execFileSync(
CONFIG.getNpmBinPath(),
['--loglevel=error', 'install'],
CONFIG.getNpmBinPath(ci),
['--loglevel=error', ci ? 'ci' : 'install'],
{env: process.env, cwd: CONFIG.scriptRootPath}
)
}

View File

@ -4,7 +4,7 @@ const childProcess = require('child_process')
const CONFIG = require('../config')
module.exports = function (packagePath) {
module.exports = function (packagePath, ci) {
const installEnv = Object.assign({}, process.env)
// Set resource path so that apm can load metadata related to Atom.
installEnv.ATOM_RESOURCE_PATH = CONFIG.repositoryRootPath
@ -13,7 +13,7 @@ module.exports = function (packagePath) {
installEnv.npm_config_target = CONFIG.appMetadata.electronVersion
childProcess.execFileSync(
CONFIG.getApmBinPath(),
['--loglevel=error', 'install'],
['--loglevel=error', ci ? 'ci' : 'install'],
{env: installEnv, cwd: packagePath, stdio: 'inherit'}
)
}

4404
script/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,9 @@ phases:
versionSpec: 8.9.3
displayName: Install Node.js 8.9.3
- script: npm install --global npm@6.2.0
displayName: Update npm
- script: |
apt-get update
apt-get install -y --no-install-recommends build-essential xvfb clang-3.5 fakeroot git libsecret-1-dev rpm libx11-dev libxkbfile-dev xz-utils xorriso zsync libxss1 libgconf2-4 libgtk-3-0

View File

@ -15,6 +15,9 @@ phases:
versionSpec: 8.9.3
displayName: Install Node.js 8.9.3
- script: npm install --global npm@6.2.0
displayName: Update npm
- script: |
if [ $IS_RELEASE_BRANCH == "true" ] || [ $IS_SIGNED_ZIP_BRANCH == "true" ]; then
script/build --code-sign --compress-artifacts

View File

@ -22,6 +22,12 @@ phases:
versionSpec: 8.9.3
displayName: Install Node.js 8.9.3
- script: |
ECHO Installing npm-windows-upgrade
npm install --global --production npm-windows-upgrade
ECHO Upgrading npm
npm-windows-upgrade --no-spinner --no-prompt --npm-version 6.2.0
- script: |
IF NOT EXIST C:\tmp MKDIR C:\tmp
SET SQUIRREL_TEMP=C:\tmp