Skip to content

Commit

Permalink
Migrate internal workflow tests to shell scripts.
Browse files Browse the repository at this point in the history
Using `node`/`yarn` commands _after_ loading the `volta-cli/action` is
very error prone, and leads to false information.
  • Loading branch information
rwjblue committed Oct 6, 2020
1 parent 459d4a9 commit 9a1fb1f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 58 deletions.
44 changes: 24 additions & 20 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- master
- 'releases/*'

defaults:
run:
shell: bash

jobs:
test:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -33,15 +37,15 @@ jobs:
with:
volta-version: 0.6.3

- run: node tests/log-info.js
- run: node tests/check-version.js 'volta' '0.6.3'
- run: tests/log-info.sh
- run: tests/check-version.sh 'volta' '0.6.3'
- run: volta install [email protected] [email protected]
- run: which node
- run: volta which node
- run: node tests/check-version.js 'node' 'v10.0.0'
- run: tests/check-version.sh 'node' 'v10.0.0'
- run: which yarn
- run: volta which yarn
- run: node tests/check-version.js 'yarn' '1.19.0'
- run: tests/check-version.sh 'yarn' '1.19.0'


test-no-options:
Expand All @@ -58,15 +62,15 @@ jobs:
- run: npm run build
- uses: ./

- run: node tests/log-info.js
- run: node tests/check-version.js 'volta' 'current'
- run: tests/log-info.sh
- run: tests/check-version.sh 'volta' 'current'
- run: volta install [email protected] [email protected]
- run: which node
- run: volta which node
- run: node tests/check-version.js 'node' 'v12.16.1'
- run: tests/check-version.sh 'node' 'v12.16.1'
- run: which yarn
- run: volta which yarn
- run: node tests/check-version.js 'yarn' '1.19.1'
- run: tests/check-version.sh 'yarn' '1.19.1'

test-specific-volta:
runs-on: ${{ matrix.os }}
Expand All @@ -84,15 +88,15 @@ jobs:
with:
volta-version: 0.7.0

- run: node tests/log-info.js
- run: node tests/check-version.js 'volta' '0.7.0'
- run: tests/log-info.sh
- run: tests/check-version.sh 'volta' '0.7.0'
- run: volta install [email protected] [email protected]
- run: which node
- run: volta which node
- run: node tests/check-version.js 'node' 'v12.16.1'
- run: tests/check-version.sh 'node' 'v12.16.1'
- run: which yarn
- run: volta which yarn
- run: node tests/check-version.js 'yarn' '1.19.1'
- run: tests/check-version.sh 'yarn' '1.19.1'

test-specified-node-yarn-overrides-pinned-versions:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -120,14 +124,14 @@ jobs:
node-version: 12.14.0
yarn-version: 1.22.0

- run: node ./action/tests/log-info.js
- run: node ./action/tests/check-version.js 'volta' '0.7.1'
- run: tests/log-info.sh
- run: ./action/tests/check-version.sh 'volta' '0.7.1'
- run: which node
- run: volta which node
- run: node ./action/tests/check-version.js 'node' 'v12.14.0'
- run: ./action/tests/check-version.sh 'node' 'v12.14.0'
- run: which yarn
- run: volta which yarn
- run: node ./action/tests/check-version.js 'yarn' '1.22.0'
- run: ./action/tests/check-version.sh 'yarn' '1.22.0'

test-specific-volta-node-yarn:
runs-on: ${{ matrix.os }}
Expand All @@ -147,11 +151,11 @@ jobs:
node-version: 12.0.0
yarn-version: 1.22.0

- run: node tests/log-info.js
- run: node tests/check-version.js 'volta' '0.7.1'
- run: tests/log-info.sh
- run: tests/check-version.sh 'volta' '0.7.1'
- run: which node
- run: volta which node
- run: node tests/check-version.js 'node' 'v12.0.0'
- run: tests/check-version.sh 'node' 'v12.0.0'
- run: which yarn
- run: volta which yarn
- run: node tests/check-version.js 'yarn' '1.22.0'
- run: tests/check-version.sh 'yarn' '1.22.0'
24 changes: 0 additions & 24 deletions tests/check-version.js

This file was deleted.

19 changes: 19 additions & 0 deletions tests/check-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# exit when any command fails
set -e

command=$1
expectedVersion=$2

if [[ "$expectedVersion" == "current" ]]; then
scriptPath="$(dirname "$BASH_SOURCE")/latest-version.js"
expectedVersion="$(curl --silent "https://volta.sh/latest-version")"
fi

actualVersion="$($command --version)"
echo "Expected $expectedVersion; found $actualVersion"

if [[ "$actualVersion" != "$expectedVersion" ]]; then
exit 1
fi
14 changes: 0 additions & 14 deletions tests/log-info.js

This file was deleted.

13 changes: 13 additions & 0 deletions tests/log-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# exit when any command fails
set -e

echo "Current PATH: $PATH"
echo "Current VOLTA_HOME: $VOLTA_HOME"

voltaBinContents="$(ls $VOLTA_HOME/bin)"
echo "Current contents of $VOLTA_HOME\n$voltaBinContents"
echo "Path to volta: $(which volta)"
echo "Path to node: $(which node)"
echo "Path to yarn: $(which yarn)"

0 comments on commit 9a1fb1f

Please sign in to comment.