Skip to content

Commit

Permalink
Fail in CI when package tests fail (#5718)
Browse files Browse the repository at this point in the history
* Fail in CI when package tests fail

Fixes #5713

Co-authored-by: chris48s <[email protected]>
  • Loading branch information
paulmelnikow and chris48s authored Oct 16, 2020
1 parent aa5addb commit e1bd160
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
33 changes: 3 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,6 @@ services_steps: &services_steps
- store_test_results:
path: junit

run_package_tests: &run_package_tests
when: always
command: |
# https://discuss.circleci.com/t/switch-nodejs-version-on-machine-executor-solved/26675/3
set +e
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install $NODE_VERSION
nvm use $NODE_VERSION
node --version
# install the shields.io dependencies
npm ci
# run the package tests
npm run test:package
npm run check-types:package
# delete the sheilds.io dependencies
rm -rf node_modules/
# run a smoke test (render a badge with the CLI)
# with only the package dependencies installed
cd badge-maker
npm link
badge cactus grown :green @flat
package_steps: &package_steps
steps:
- checkout
Expand All @@ -132,31 +105,31 @@ package_steps: &package_steps
# https://nodejs.org/en/about/releases/

- run:
<<: *run_package_tests
environment:
mocha_reporter: mocha-junit-reporter
MOCHA_FILE: junit/badge-maker/v10/results.xml
NODE_VERSION: v10
CYPRESS_INSTALL_BINARY: 0
name: Run package tests on Node 10
command: scripts/run_package_tests.sh

- run:
<<: *run_package_tests
environment:
mocha_reporter: mocha-junit-reporter
MOCHA_FILE: junit/badge-maker/v12/results.xml
NODE_VERSION: v12
CYPRESS_INSTALL_BINARY: 0
name: Run package tests on Node 12
command: scripts/run_package_tests.sh

- run:
<<: *run_package_tests
environment:
mocha_reporter: mocha-junit-reporter
MOCHA_FILE: junit/badge-maker/v14/results.xml
NODE_VERSION: v14
CYPRESS_INSTALL_BINARY: 0
name: Run package tests on Node 14
command: scripts/run_package_tests.sh

- store_test_results:
path: junit
Expand Down
35 changes: 35 additions & 0 deletions scripts/run_package_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# https://discuss.circleci.com/t/switch-nodejs-version-on-machine-executor-solved/26675/3

# Start off less strict to work around various nvm errors.
set -e
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
nvm install $NODE_VERSION
nvm use $NODE_VERSION

# Stricter.
set -euo pipefail
node --version

# Install the shields.io dependencies.
if [[ "$NODE_VERSION" == "v10" ]]; then
# Avoid a depcheck error.
npm ci --ignore-scripts
else
npm ci
fi

# Run the package tests.
npm run test:package
npm run check-types:package

# Delete the shields.io dependencies.
rm -rf node_modules/

# Run a smoke test (render a badge with the CLI) with only the package
# dependencies installed.
cd badge-maker
npm link
badge cactus grown :green @flat

0 comments on commit e1bd160

Please sign in to comment.