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
This commit is contained in:
		
					parent
					
						
							
								0fc172fcaf
							
						
					
				
			
			
				commit
				
					
						a45afddb75
					
				
			
		
					 6 changed files with 35 additions and 18 deletions
				
			
		| 
						 | 
					@ -196,17 +196,17 @@ step-delete-git-directories: &step-delete-git-directories
 | 
				
			||||||
        sudo rm -rf src/.git
 | 
					        sudo rm -rf src/.git
 | 
				
			||||||
      fi
 | 
					      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
 | 
					# 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
 | 
					# we are on a macOS machine to get the correct state
 | 
				
			||||||
step-install-npm-deps-on-mac: &step-install-npm-deps-on-mac
 | 
					step-install-npm-deps-on-mac: &step-install-npm-deps-on-mac
 | 
				
			||||||
  run:
 | 
					  run:
 | 
				
			||||||
    name: Install NPM Dependencies on MacOS
 | 
					    name: Install node_modules on MacOS
 | 
				
			||||||
    command: |
 | 
					    command: |
 | 
				
			||||||
      if [ "`uname`" == "Darwin" ]; then
 | 
					      if [ "`uname`" == "Darwin" ]; then
 | 
				
			||||||
        cd src/electron
 | 
					        cd src/electron
 | 
				
			||||||
        npm install
 | 
					        node script/yarn install
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This step handles the differences between the linux "gclient sync"
 | 
					# 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: |
 | 
					    command: |
 | 
				
			||||||
      if [ "`uname`" == "Darwin" ]; then
 | 
					      if [ "`uname`" == "Darwin" ]; then
 | 
				
			||||||
        cd src/electron
 | 
					        cd src/electron
 | 
				
			||||||
        npm run create-typescript-definitions
 | 
					        node script/yarn create-typescript-definitions
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
step-fix-known-hosts-linux: &step-fix-known-hosts-linux
 | 
					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.
 | 
					          # but then we would lint its contents (at least gn format), and it doesn't pass it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          cd src/electron
 | 
					          cd src/electron
 | 
				
			||||||
          npm install
 | 
					          node script/yarn install
 | 
				
			||||||
          npm run lint
 | 
					          node script/yarn lint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
steps-checkout: &steps-checkout
 | 
					steps-checkout: &steps-checkout
 | 
				
			||||||
  steps:
 | 
					  steps:
 | 
				
			||||||
| 
						 | 
					@ -872,7 +872,7 @@ steps-tests: &steps-tests
 | 
				
			||||||
        command: |
 | 
					        command: |
 | 
				
			||||||
          cd src
 | 
					          cd src
 | 
				
			||||||
          export ELECTRON_OUT_DIR=Default
 | 
					          export ELECTRON_OUT_DIR=Default
 | 
				
			||||||
          (cd electron && npm run test -- --ci --enable-logging)
 | 
					          (cd electron && node script/yarn test -- --ci --enable-logging)
 | 
				
			||||||
    - run:
 | 
					    - run:
 | 
				
			||||||
        name: Check test results existence
 | 
					        name: Check test results existence
 | 
				
			||||||
        command: |
 | 
					        command: |
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,7 +111,7 @@ test_script:
 | 
				
			||||||
        echo "Skipping tests for $env:GN_CONFIG build"
 | 
					        echo "Skipping tests for $env:GN_CONFIG build"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
  - cd electron
 | 
					  - 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 ..
 | 
					  - 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 )
 | 
					  - 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"
 | 
					  - echo "About to verify mksnapshot"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,9 @@
 | 
				
			||||||
// KEEP IN SYNC WITH DEPS FILE
 | 
					const { GitProcess } = require('dugite')
 | 
				
			||||||
const YARN_VERSION = '1.15.2'
 | 
					const fs = require('fs')
 | 
				
			||||||
 | 
					const path = require('path')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
 | 
					const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { GitProcess } = require('dugite')
 | 
					 | 
				
			||||||
const path = require('path')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
require('colors')
 | 
					require('colors')
 | 
				
			||||||
const pass = '\u2713'.green
 | 
					const pass = '\u2713'.green
 | 
				
			||||||
const fail = '\u2717'.red
 | 
					const fail = '\u2717'.red
 | 
				
			||||||
| 
						 | 
					@ -45,6 +43,5 @@ module.exports = {
 | 
				
			||||||
  getCurrentBranch,
 | 
					  getCurrentBranch,
 | 
				
			||||||
  getElectronExec,
 | 
					  getElectronExec,
 | 
				
			||||||
  getAbsoluteElectronExec,
 | 
					  getAbsoluteElectronExec,
 | 
				
			||||||
  OUT_DIR,
 | 
					  OUT_DIR
 | 
				
			||||||
  YARN_VERSION
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ const NAN_DIR = path.resolve(BASE, 'third_party', 'nan')
 | 
				
			||||||
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
 | 
					const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const utils = require('./lib/utils')
 | 
					const utils = require('./lib/utils')
 | 
				
			||||||
 | 
					const { YARN_VERSION } = require('./yarn')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (!process.mainModule) {
 | 
					if (!process.mainModule) {
 | 
				
			||||||
  throw new Error('Must call the nan spec runner directly')
 | 
					  throw new Error('Must call the nan spec runner directly')
 | 
				
			||||||
| 
						 | 
					@ -29,7 +30,7 @@ async function main () {
 | 
				
			||||||
    return process.exit(buildStatus)
 | 
					    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,
 | 
					    env,
 | 
				
			||||||
    cwd: NAN_DIR,
 | 
					    cwd: NAN_DIR,
 | 
				
			||||||
    stdio: 'inherit'
 | 
					    stdio: 'inherit'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ for (const flag of unknownFlags) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const utils = require('./lib/utils')
 | 
					const utils = require('./lib/utils')
 | 
				
			||||||
 | 
					const { YARN_VERSION } = require('./yarn')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const BASE = path.resolve(__dirname, '../..')
 | 
					const BASE = path.resolve(__dirname, '../..')
 | 
				
			||||||
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
 | 
					const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
 | 
				
			||||||
| 
						 | 
					@ -144,7 +145,7 @@ async function installSpecModules () {
 | 
				
			||||||
    npm_config_nodedir: nodeDir,
 | 
					    npm_config_nodedir: nodeDir,
 | 
				
			||||||
    npm_config_msvs_version: '2017'
 | 
					    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,
 | 
					    env,
 | 
				
			||||||
    cwd: path.resolve(__dirname, '../spec'),
 | 
					    cwd: path.resolve(__dirname, '../spec'),
 | 
				
			||||||
    stdio: 'inherit'
 | 
					    stdio: 'inherit'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								script/yarn.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								script/yarn.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue