From d1a78e77d59f3cfcf45096d8b490b8eb17055ce7 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Fri, 20 Oct 2017 18:14:59 +0000 Subject: [PATCH] start moving appveyor build steps into shelljs file (#785) * start moving appveyor build steps into shelljs file * moved appveyor commands into shell script * build on this branch --- appveyor.yml | 16 +----------- package.json | 1 + scripts/win-appveyor-build.js | 49 +++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 15 deletions(-) create mode 100755 scripts/win-appveyor-build.js diff --git a/appveyor.yml b/appveyor.yml index 944f48397f..b919e805c3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -63,21 +63,7 @@ test_script: - npm pack - cd ../.. - # Only upload binary / NPM package from "develop" branch - # should this move into a batch file? - - IF %APPVEYOR_REPO_BRANCH%==develop IF %APPVEYOR_REPO_NAME%==cypress-io/cypress ( - echo Uploading NPM windows package && - node scripts/binary.js upload-npm-package --file cli/build/cypress-%NEXT_DEV_VERSION%.tgz --version %NEXT_DEV_VERSION% --hash %APPVEYOR_REPO_BRANCH%-%APPVEYOR_REPO_COMMIT%-%APPVEYOR_BUILD_ID% && - cat npm-package-url.json && - echo Building binary %NEXT_DEV_VERSION% && - npm run binary-build -- --platform windows --version %NEXT_DEV_VERSION% && - npm run binary-zip && - ls -l *.zip && - node scripts/binary.js upload-unique-binary --file cypress.zip --version %NEXT_DEV_VERSION% --hash %APPVEYOR_REPO_BRANCH%-%APPVEYOR_REPO_COMMIT%-%APPVEYOR_BUILD_ID% && - cat binary-url.json && - echo Running other test projects with new NPM package and binary && - node scripts/test-other-projects.js --npm npm-package-url.json --binary binary-url.json --provider appVeyor - ) + - node ./scripts/win-appveyor-build.js # Don't actually build. build: off diff --git a/package.json b/package.json index 5e776cf6dd..e591e4e4c1 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "prefixed-list": "^1.0.1", "print-arch": "^1.0.0", "ramda": "^0.24.1", + "shelljs": "^0.7.8", "snap-shot-it": "^4.0.1", "stop-only": "^1.1.0", "typescript": "^2.3.4", diff --git a/scripts/win-appveyor-build.js b/scripts/win-appveyor-build.js new file mode 100755 index 0000000000..66e82e6d29 --- /dev/null +++ b/scripts/win-appveyor-build.js @@ -0,0 +1,49 @@ +#!/usr/bin/env node + +/* eslint-disable no-console */ + +// builds Windows binary on AppVeyor CI +// but only on the right branch + +const shell = require('shelljs') +const la = require('lazy-ass') +const is = require('check-more-types') + +shell.set('-v') // verbose +shell.set('-e') // any error is fatal + +// https://www.appveyor.com/docs/environment-variables/ + +const isRightBranch = () => + process.env.APPVEYOR_REPO_BRANCH === 'develop' || + process.env.APPVEYOR_REPO_BRANCH === 'win-build-shell' + +const isPullRequest = () => + Boolean(process.env.APPVEYOR_PULL_REQUEST_NUMBER) + +const shouldBuildBinary = () => + isRightBranch() && !isPullRequest() + +if (!shouldBuildBinary()) { + console.log('should not build binary') + process.exit(0) +} + +console.log('building binary') + +const hash = `${process.env.APPVEYOR_REPO_BRANCH}-${process.env.APPVEYOR_REPO_COMMIT}-${process.env.APPVEYOR_BUILD_ID}` +const filename = `cypress-${process.env.NEXT_DEV_VERSION}.tgz` +const version = process.env.NEXT_DEV_VERSION +la(is.unemptyString(version), 'missing NEXT_DEV_VERSION') + +console.log('building version', version) +console.log('upload hash', hash) + +shell.exec(`node scripts/binary.js upload-npm-package --file cli/build/${filename} --version ${version} --hash ${hash}`) +shell.cat('npm-package-url.json') +shell.exec(`npm run binary-build -- --platform windows --version ${version}`) +shell.exec('npm run binary-zip') +shell.ls('-l', '*.zip') +shell.exec(`node scripts/binary.js upload-unique-binary --file cypress.zip --version ${version} --hash ${hash}`) +shell.cat('binary-url.json') +shell.exec('node scripts/test-other-projects.js --npm npm-package-url.json --binary binary-url.json --provider appVeyor')