From a12abc2a6cf6c2b5b18c416b6bc2750d97c9db10 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 22 May 2017 09:20:28 -0400 Subject: [PATCH] chore: unify CI scripts (#1434) Currently we have almost equal CI scripts implemented in bash (for Travis), and batch (for Appveyor). This commit takes advantage of MinGW bash to unify all the scripts as bash scripts. Signed-off-by: Juan Cruz Viotti --- .travis.yml | 15 ++++-- appveyor.yml | 8 ++-- scripts/ci/appveyor-build-installers.bat | 24 ---------- scripts/ci/appveyor-deploy.bat | 26 ---------- scripts/ci/appveyor-install.bat | 34 ------------- scripts/ci/appveyor-test.bat | 25 ---------- ...uild-installers.sh => build-installers.sh} | 29 +++++++++-- .../ci/{travis-deploy.sh => deploy-aws-s3.sh} | 31 +++++++++--- scripts/ci/{travis-install.sh => install.sh} | 48 +++++++++++++++---- scripts/ci/{travis-test.sh => test.sh} | 34 ++++++++++--- 10 files changed, 131 insertions(+), 143 deletions(-) delete mode 100755 scripts/ci/appveyor-build-installers.bat delete mode 100755 scripts/ci/appveyor-deploy.bat delete mode 100755 scripts/ci/appveyor-install.bat delete mode 100755 scripts/ci/appveyor-test.bat rename scripts/ci/{travis-build-installers.sh => build-installers.sh} (59%) rename scripts/ci/{travis-deploy.sh => deploy-aws-s3.sh} (57%) rename scripts/ci/{travis-install.sh => install.sh} (52%) rename scripts/ci/{travis-test.sh => test.sh} (57%) diff --git a/.travis.yml b/.travis.yml index 060a1d03..acffce84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,17 +33,24 @@ os: - linux - osx +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + export HOST_OS="darwin"; + else + export HOST_OS="$TRAVIS_OS_NAME"; + fi + install: - - travis_wait ./scripts/ci/travis-install.sh + - travis_wait ./scripts/ci/install.sh -o $HOST_OS -r $TARGET_ARCH script: - - ./scripts/ci/travis-test.sh - - ./scripts/ci/travis-build-installers.sh + - ./scripts/ci/test.sh -o $HOST_OS -r $TARGET_ARCH + - ./scripts/ci/build-installers.sh -o $HOST_OS -r $TARGET_ARCH deploy: provider: script skip_cleanup: true - script: scripts/ci/travis-deploy.sh + script: scripts/ci/deploy-aws-s3.sh -o $HOST_OS -r $TARGET_ARCH on: branch: master diff --git a/appveyor.yml b/appveyor.yml index 84366b5b..85d77ef8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,18 +28,18 @@ install: - set PATH=C:\Program Files (x86)\NSIS;%PATH% - set PATH=C:\MinGW\bin;%PATH% - set PATH=C:\MinGW\msys\1.0\bin;%PATH% - - .\scripts\ci\appveyor-install.bat + - bash .\scripts\ci\install.sh -o win32 -r %TARGET_ARCH% build: off test_script: - node --version - npm --version - - .\scripts\ci\appveyor-test.bat - - .\scripts\ci\appveyor-build-installers.bat + - bash .\scripts\ci\test.sh -o win32 -r %TARGET_ARCH% + - bash .\scripts\ci\build-installers.sh -o win32 -r %TARGET_ARCH% deploy_script: - - .\scripts\ci\appveyor-deploy.bat + - bash .\scripts\ci\deploy-aws-s3.sh -o win32 -r %TARGET_ARCH% notifications: diff --git a/scripts/ci/appveyor-build-installers.bat b/scripts/ci/appveyor-build-installers.bat deleted file mode 100755 index c7fcd252..00000000 --- a/scripts/ci/appveyor-build-installers.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off - -:: Copyright 2017 resin.io -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. - -IF "%APPVEYOR_REPO_BRANCH%"=="" ( - ECHO This script is only meant to run in Appveyor CI 1>&2 - EXIT /B 1 -) - -call make installers-all || ( EXIT /B 1 ) - -EXIT /B %ERRORLEVEL% diff --git a/scripts/ci/appveyor-deploy.bat b/scripts/ci/appveyor-deploy.bat deleted file mode 100755 index 69d233dd..00000000 --- a/scripts/ci/appveyor-deploy.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off - -:: Copyright 2017 resin.io -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. - -IF "%APPVEYOR_REPO_BRANCH%"=="" ( - ECHO This script is only meant to run in Appveyor CI 1>&2 - EXIT /B 1 -) - -IF %APPVEYOR_REPO_BRANCH%==master ( - call make publish-aws-s3 || ( EXIT /B 1 ) -) - -EXIT /B %ERRORLEVEL% diff --git a/scripts/ci/appveyor-install.bat b/scripts/ci/appveyor-install.bat deleted file mode 100755 index b9adad0d..00000000 --- a/scripts/ci/appveyor-install.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off - -:: Copyright 2017 resin.io -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. - -IF "%APPVEYOR_REPO_BRANCH%"=="" ( - ECHO This script is only meant to run in Appveyor CI 1>&2 - EXIT /B 1 -) - -call npm config set spin=false || ( EXIT /B 1 ) -call npm install -g uglify-es@3.0.3 || ( EXIT /B 1 ) - -call choco install nsis -version 2.51 || ( EXIT /B 1 ) -call choco install jq || ( EXIT /B 1 ) -call choco install curl || ( EXIT /B 1 ) - -call pip install -r requirements.txt || ( EXIT /B 1 ) - -call make info || ( EXIT /B 1 ) -call make electron-develop || ( EXIT /B 1 ) - -EXIT /B %ERRORLEVEL% diff --git a/scripts/ci/appveyor-test.bat b/scripts/ci/appveyor-test.bat deleted file mode 100755 index f454d570..00000000 --- a/scripts/ci/appveyor-test.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off - -:: Copyright 2017 resin.io -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. - -IF "%APPVEYOR_REPO_BRANCH%"=="" ( - ECHO This script is only meant to run in Appveyor CI 1>&2 - EXIT /B 1 -) - -call make sanity-checks || ( EXIT /B 1 ) -call npm test || ( EXIT /B 1 ) - -EXIT /B %ERRORLEVEL% diff --git a/scripts/ci/travis-build-installers.sh b/scripts/ci/build-installers.sh similarity index 59% rename from scripts/ci/travis-build-installers.sh rename to scripts/ci/build-installers.sh index a27af4fa..f1d80e84 100755 --- a/scripts/ci/travis-build-installers.sh +++ b/scripts/ci/build-installers.sh @@ -19,18 +19,37 @@ set -e set -u -if [ -z "$TRAVIS_OS_NAME" ]; then - echo "This script is only meant to run in Travis CI" 1>&2 +function usage() { + echo "Usage: $0" + echo "" + echo "Options" + echo "" + echo " -o " + echo " -r " exit 1 +} + +ARGV_OPERATING_SYSTEM="" +ARGV_ARCHITECTURE="" + +while getopts ":o:r:" option; do + case $option in + o) ARGV_OPERATING_SYSTEM=$OPTARG ;; + r) ARGV_ARCHITECTURE=$OPTARG ;; + *) usage ;; + esac +done + +if [ -z "$ARGV_OPERATING_SYSTEM" ] || [ -z "$ARGV_ARCHITECTURE" ]; then + usage fi -./scripts/build/check-dependency.sh make - -if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then +if [ "$ARGV_OPERATING_SYSTEM" == "linux" ]; then ./scripts/build/docker/run-command.sh \ -r "$TARGET_ARCH" \ -s "$(pwd)" \ -c 'make installers-all' else + ./scripts/build/check-dependency.sh make make installers-all fi diff --git a/scripts/ci/travis-deploy.sh b/scripts/ci/deploy-aws-s3.sh similarity index 57% rename from scripts/ci/travis-deploy.sh rename to scripts/ci/deploy-aws-s3.sh index e6568be4..006bc974 100755 --- a/scripts/ci/travis-deploy.sh +++ b/scripts/ci/deploy-aws-s3.sh @@ -19,18 +19,37 @@ set -e set -u -./scripts/build/check-dependency.sh make - -if [ -z "$TRAVIS_OS_NAME" ]; then - echo "This script is only meant to run in Travis CI" 1>&2 +function usage() { + echo "Usage: $0" + echo "" + echo "Options" + echo "" + echo " -o " + echo " -r " exit 1 +} + +ARGV_OPERATING_SYSTEM="" +ARGV_ARCHITECTURE="" + +while getopts ":o:r:" option; do + case $option in + o) ARGV_OPERATING_SYSTEM=$OPTARG ;; + r) ARGV_ARCHITECTURE=$OPTARG ;; + *) usage ;; + esac +done + +if [ -z "$ARGV_OPERATING_SYSTEM" ] || [ -z "$ARGV_ARCHITECTURE" ]; then + usage fi -if [ "$TRAVIS_OS_NAME" == "linux" ]; then +if [ "$ARGV_OPERATING_SYSTEM" == "linux" ]; then ./scripts/build/docker/run-command.sh \ - -r "$TARGET_ARCH" \ + -r "$ARGV_ARCHITECTURE" \ -s "$(pwd)" \ -c "make publish-aws-s3" else + ./scripts/build/check-dependency.sh make make publish-aws-s3 fi diff --git a/scripts/ci/travis-install.sh b/scripts/ci/install.sh similarity index 52% rename from scripts/ci/travis-install.sh rename to scripts/ci/install.sh index 16e741c9..e0c8b3d4 100755 --- a/scripts/ci/travis-install.sh +++ b/scripts/ci/install.sh @@ -19,26 +19,58 @@ set -e set -u -if [ -z "$TRAVIS_OS_NAME" ]; then - echo "This script is only meant to run in Travis CI" 1>&2 +function usage() { + echo "Usage: $0" + echo "" + echo "Options" + echo "" + echo " -o " + echo " -r " exit 1 +} + +ARGV_OPERATING_SYSTEM="" +ARGV_ARCHITECTURE="" + +while getopts ":o:r:" option; do + case $option in + o) ARGV_OPERATING_SYSTEM=$OPTARG ;; + r) ARGV_ARCHITECTURE=$OPTARG ;; + *) usage ;; + esac +done + +if [ -z "$ARGV_OPERATING_SYSTEM" ] || [ -z "$ARGV_ARCHITECTURE" ]; then + usage fi -if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then +if [ "$ARGV_OPERATING_SYSTEM" == "linux" ]; then ./scripts/build/docker/run-command.sh \ - -r "$TARGET_ARCH" \ + -r "$ARGV_ARCHITECTURE" \ -s "$(pwd)" \ -c "make info && make electron-develop" else - ./scripts/build/check-dependency.sh pip - ./scripts/build/check-dependency.sh brew - ./scripts/build/check-dependency.sh make + if [ "$ARGV_OPERATING_SYSTEM" == "darwin" ]; then + ./scripts/build/check-dependency.sh brew + brew install afsctool jq + elif [ "$ARGV_OPERATING_SYSTEM" == "win32" ]; then + ./scripts/build/check-dependency.sh choco + choco install nsis -version 2.51 + choco install jq + choco install curl + else + echo "Unsupported operating system: $ARGV_OPERATING_SYSTEM" 1>&2 + exit 1 + fi + ./scripts/build/check-dependency.sh npm + ./scripts/build/check-dependency.sh pip + ./scripts/build/check-dependency.sh make npm config set spin=false npm install -g uglify-es@3.0.3 pip install -r requirements.txt - brew install afsctool jq + make info make electron-develop fi diff --git a/scripts/ci/travis-test.sh b/scripts/ci/test.sh similarity index 57% rename from scripts/ci/travis-test.sh rename to scripts/ci/test.sh index 320c92f1..59a4dd1c 100755 --- a/scripts/ci/travis-test.sh +++ b/scripts/ci/test.sh @@ -19,20 +19,40 @@ set -e set -u -if [ -z "$TRAVIS_OS_NAME" ]; then - echo "This script is only meant to run in Travis CI" 1>&2 +function usage() { + echo "Usage: $0" + echo "" + echo "Options" + echo "" + echo " -o " + echo " -r " exit 1 +} + +ARGV_OPERATING_SYSTEM="" +ARGV_ARCHITECTURE="" + +while getopts ":o:r:" option; do + case $option in + o) ARGV_OPERATING_SYSTEM=$OPTARG ;; + r) ARGV_ARCHITECTURE=$OPTARG ;; + *) usage ;; + esac +done + +if [ -z "$ARGV_OPERATING_SYSTEM" ] || [ -z "$ARGV_ARCHITECTURE" ]; then + usage fi -./scripts/build/check-dependency.sh npm -./scripts/build/check-dependency.sh make - -if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then +if [ "$ARGV_OPERATING_SYSTEM" == "linux" ]; then ./scripts/build/docker/run-command.sh \ - -r "$TARGET_ARCH" \ + -r "$ARGV_ARCHITECTURE" \ -s "$(pwd)" \ -c 'make sanity-checks && xvfb-run --server-args=$XVFB_ARGS npm test' else + ./scripts/build/check-dependency.sh make + ./scripts/build/check-dependency.sh npm + make sanity-checks npm test fi