-
Notifications
You must be signed in to change notification settings - Fork 875
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
- Loading branch information
Showing
1 changed file
with
14 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,45 @@ | ||
import groovy.transform.Field | ||
|
||
@Field final List osToTests = [ | ||
'macos', | ||
'windows', | ||
'linux' | ||
] | ||
// Global for which yarn version to use | ||
@Field final String yarnVersion = '1.3.2' | ||
// Global for having the path to yarn (prevent concurrency issue with yarn cache) | ||
@Field final String yarnPath = './node_modules/.bin/yarn' | ||
@Field final String nodeVersion = '10.4.1' | ||
|
||
// Step for running tests on a specific nodejs version with windows | ||
def windowsStep () { | ||
node(label: 'windows') { | ||
ansiColor('xterm') { | ||
// need to make sure we're using the right line endings | ||
bat 'git config --global core.autocrlf input' | ||
checkout scm | ||
fileExists 'package.json' | ||
nodejs('10.4.1') { | ||
// delete node_modules if it's there | ||
nodejs(nodeVersion) { | ||
bat 'del /s /q node_modules >nul 2>&1' | ||
// install local version of yarn (prevent concurrency issues again) | ||
bat 'npm install yarn@' + yarnVersion | ||
// force visual studio version | ||
bat yarnPath + ' config set msvs_version 2015 --global' | ||
// install dependencies with a mutex lock | ||
bat yarnPath + ' --mutex network' | ||
// build binaries | ||
bat yarnPath + ' build' | ||
archiveArtifacts 'dist\\*.exe' | ||
bat 'npx yarn@1.9.4 config set msvs_version 2015 --global' | ||
bat 'npm run lint' | ||
bat 'npm run build' | ||
archiveArtifacts 'dist\\*' | ||
cleanWs() | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Step for running tests on a specific nodejs version with unix compatible OS | ||
def unixStep(nodeLabel) { | ||
node(label: nodeLabel) { | ||
ansiColor('xterm') { | ||
checkout scm | ||
fileExists 'package.json' | ||
nodejs('10.4.1') { | ||
nodejs(nodeVersion) { | ||
sh 'rm -rf node_modules/' | ||
sh 'npm install yarn@' + yarnVersion | ||
sh yarnPath + ' --mutex network' | ||
sh yarnPath + ' build' | ||
sh 'npm run lint' | ||
sh 'npm run build' | ||
archiveArtifacts 'dist/*' | ||
cleanWs() | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Helper function for getting the right platform + version | ||
def getStep(os) { | ||
return { | ||
if (os == 'macos' || os == 'linux') { | ||
return unixStep(os) | ||
} | ||
if (os == 'windows') { | ||
return windowsStep() | ||
} | ||
} | ||
} | ||
|
||
stage('Builds') { | ||
// Create map for all the os+version combinations | ||
def steps = [:] | ||
for (os in osToTests) { | ||
def stepName = os + ' Build' | ||
steps[(stepName)] = getStep(os) | ||
} | ||
// execute those steps in parallel | ||
parallel steps | ||
parallel( | ||
"windows": windowsStep(), | ||
"macos": unixStep("macos"), | ||
"linux": unixStep("linux") | ||
) | ||
} |