From 96a9b65ea7637a89f581f26874cdeff47944c350 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 23 Feb 2017 11:20:47 -0400 Subject: [PATCH] chore: ensure `npm run sass` was ran and the results committed (#1121) We recently encountered a UI regression caused by forgetting to commit the generated CSS files. The solution is to make the CI servers run `npm run sass` and check if there are unstaged files afterwards. If so, the tests halt. In order to avoid duplication between Travis CI and Appveyor CI, this logic has been encoded into a bash script at `scripts/ci`. See: https://github.com/resin-io/etcher/pull/1120 Signed-off-by: Juan Cruz Viotti --- .travis.yml | 3 ++- appveyor.yml | 1 + scripts/ci/ensure-staged-sass.sh | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 scripts/ci/ensure-staged-sass.sh diff --git a/.travis.yml b/.travis.yml index 82fdaab4..cc741fe4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,9 +54,10 @@ install: script: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm test; + ./scripts/ci/ensure-staged-sass.sh; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - ./scripts/build/docker/run-command.sh -r ${TARGET_ARCH} -s ${PWD} -c "xvfb-run --server-args=$XVFB_ARGS npm test"; + ./scripts/build/docker/run-command.sh -r ${TARGET_ARCH} -s ${PWD} -c "xvfb-run --server-args=$XVFB_ARGS npm test && ./scripts/ci/ensure-staged-sass.sh"; fi notifications: diff --git a/appveyor.yml b/appveyor.yml index 82aff304..5f0dd480 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,6 +43,7 @@ build: off test_script: - node --version - npm --version + - bash .\scripts\ci\ensure-staged-sass.sh - cmd: npm test notifications: diff --git a/scripts/ci/ensure-staged-sass.sh b/scripts/ci/ensure-staged-sass.sh new file mode 100755 index 00000000..fed53489 --- /dev/null +++ b/scripts/ci/ensure-staged-sass.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e +set -u + +npm run sass + +# From http://stackoverflow.com/a/9393642/1641422 +if [[ -n $(git status -s) ]]; then + echo "There are unstaged sass changes. Please commit the result of:" 1>&2 + echo "" + echo " npm run sass" 1>&2 + echo "" + exit 1 +fi