Skip to content
Permalink
Browse files

build: unify YARN_VERSION variable usage and ensure CI uses yarn not …

…npm (#18607)

* build: unify YARN_VERSION variable usage and ensure CI uses yarn not npm

* chore: use a JS helper so that it can work on windows

* chore: make script/yarn without node_modules installed
  • Loading branch information...
MarshallOfSound committed Jun 5, 2019
1 parent 0fc172f commit a45afddb757d5a0d92e6d01ecd88060cb3de4af5
Showing with 35 additions and 18 deletions.
  1. +8 −8 .circleci/config.yml
  2. +1 −1 appveyor.yml
  3. +4 −7 script/lib/utils.js
  4. +2 −1 script/nan-spec-runner.js
  5. +2 −1 script/spec-runner.js
  6. +18 −0 script/yarn.js
@@ -196,17 +196,17 @@ step-delete-git-directories: &step-delete-git-directories
sudo rm -rf src/.git
fi
# On macOS the npm install command during gclient sync was run on a linux
# On macOS the yarn install command during gclient sync was run on a linux
# machine and therefore installed a slightly different set of dependencies
# Notably "fsevents" is a macOS only dependency, we rerun npm install once
# Notably "fsevents" is a macOS only dependency, we rerun yarn install once
# we are on a macOS machine to get the correct state
step-install-npm-deps-on-mac: &step-install-npm-deps-on-mac
run:
name: Install NPM Dependencies on MacOS
name: Install node_modules on MacOS
command: |
if [ "`uname`" == "Darwin" ]; then
cd src/electron
npm install
node script/yarn install
fi
# This step handles the differences between the linux "gclient sync"
@@ -524,7 +524,7 @@ step-maybe-generate-typescript-defs: &step-maybe-generate-typescript-defs
command: |
if [ "`uname`" == "Darwin" ]; then
cd src/electron
npm run create-typescript-definitions
node script/yarn create-typescript-definitions
fi
step-fix-known-hosts-linux: &step-fix-known-hosts-linux
@@ -568,8 +568,8 @@ steps-lint: &steps-lint
# but then we would lint its contents (at least gn format), and it doesn't pass it.
cd src/electron
npm install
npm run lint
node script/yarn install
node script/yarn lint
steps-checkout: &steps-checkout
steps:
@@ -872,7 +872,7 @@ steps-tests: &steps-tests
command: |
cd src
export ELECTRON_OUT_DIR=Default
(cd electron && npm run test -- --ci --enable-logging)
(cd electron && node script/yarn test -- --ci --enable-logging)
- run:
name: Check test results existence
command: |
@@ -111,7 +111,7 @@ test_script:
echo "Skipping tests for $env:GN_CONFIG build"
}
- cd electron
- if "%RUN_TESTS%"=="true" ( echo Running test suite & npm run test -- --ci --enable-logging)
- if "%RUN_TESTS%"=="true" ( echo Running test suite & node script/yarn test -- --ci --enable-logging)
- cd ..
- if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
- echo "About to verify mksnapshot"
@@ -1,11 +1,9 @@
// KEEP IN SYNC WITH DEPS FILE
const YARN_VERSION = '1.15.2'

const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'

const { GitProcess } = require('dugite')
const fs = require('fs')
const path = require('path')

const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'

require('colors')
const pass = '\u2713'.green
const fail = '\u2717'.red
@@ -45,6 +43,5 @@ module.exports = {
getCurrentBranch,
getElectronExec,
getAbsoluteElectronExec,
OUT_DIR,
YARN_VERSION
OUT_DIR
}
@@ -7,6 +7,7 @@ const NAN_DIR = path.resolve(BASE, 'third_party', 'nan')
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'

const utils = require('./lib/utils')
const { YARN_VERSION } = require('./yarn')

if (!process.mainModule) {
throw new Error('Must call the nan spec runner directly')
@@ -29,7 +30,7 @@ async function main () {
return process.exit(buildStatus)
}

const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${utils.YARN_VERSION}`, 'install'], {
const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install'], {
env,
cwd: NAN_DIR,
stdio: 'inherit'
@@ -22,6 +22,7 @@ for (const flag of unknownFlags) {
}

const utils = require('./lib/utils')
const { YARN_VERSION } = require('./yarn')

const BASE = path.resolve(__dirname, '../..')
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
@@ -144,7 +145,7 @@ async function installSpecModules () {
npm_config_nodedir: nodeDir,
npm_config_msvs_version: '2017'
})
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${utils.YARN_VERSION}`, 'install', '--frozen-lockfile'], {
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], {
env,
cwd: path.resolve(__dirname, '../spec'),
stdio: 'inherit'
@@ -0,0 +1,18 @@
const cp = require('child_process')
const fs = require('fs')
const path = require('path')

const YARN_VERSION = /'yarn_version': '(.+?)'/.exec(fs.readFileSync(path.resolve(__dirname, '../DEPS'), 'utf8'))[1]

exports.YARN_VERSION = YARN_VERSION

// If we are running "node script/yarn" run as the yarn CLI
if (process.mainModule === module) {
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'

const child = cp.spawn(NPX_CMD, [`yarn@${YARN_VERSION}`, ...process.argv.slice(2)], {
stdio: 'inherit'
})

child.on('exit', code => process.exit(code))
}

0 comments on commit a45afdd

Please sign in to comment.
You can’t perform that action at this time.