Skip to content

Commit

Permalink
fix: use node 'current' in UT, allow disable
Browse files Browse the repository at this point in the history
* fix: use node 'current' in UT, allow disable

* chore: allow for falsy override

* fix: use input instead of var
  • Loading branch information
iowillhoit committed May 13, 2024
1 parent 64c4d4d commit a1fcc30
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
28 changes: 24 additions & 4 deletions .github/actions/determineNodeVersions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
nodeVersionOverride:
description: Semver version to set version and version-1
required: false
nodeDisableCurrent:
description: Disable testing on Node "current"
required: false

outputs:
nodeVersions:
Expand All @@ -18,6 +21,9 @@ runs:
shell: bash
id: node-versions
run: |
# Current can be disabled by setting the "nodeDisableCurrent" input to "true"
# IF "NODE_VERSION" is overridden, "NODE_VERSION_CURRENT" will also be disabled
NODE_VERSION_CURRENT="current"
NODE_VERSION="${{ inputs.nodeVersionOverride || 'lts/*' }}"
NODE_PREVIOUS_LTS="lts/-1"
Expand All @@ -33,16 +39,30 @@ runs:
fi
{
echo 'nodeVersions<<EOF'
jq -n --arg v1 "$NODE_VERSION" --arg v2 "$NODE_PREVIOUS_LTS" '[$v1, $v2]'
echo EOF
echo "nodeVersions<<EOF"
if [ "$NODE_VERSION" = "lts/*" ] && [ "${{ inputs.nodeDisableCurrent }}" != "true" ]; then
jq -n --arg v1 "$NODE_VERSION_CURRENT" --arg v2 "$NODE_VERSION" --arg v3 "$NODE_PREVIOUS_LTS" '[$v1, $v2, $v3]'
else
jq -n --arg v1 "$NODE_VERSION" --arg v2 "$NODE_PREVIOUS_LTS" '[$v1, $v2]'
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
# Sample output looks like this:
#
# nodeVersions<<EOF
# [
# "current",
# "lts/*",
# "lts/-1",
# ]
# EOF
#
# OR...
#
# nodeVersions<<EOF
# [
# "18.15.0",
# "17"
# "16"
# ]
# EOF
1 change: 1 addition & 0 deletions .github/workflows/unitTestsLinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
id: determine-node-versions
with:
nodeVersionOverride: ${{ vars.NODE_VERSION_OVERRIDE }} # default is 'lts/*' and 'lts/-1'
nodeDisableCurrent: ${{ vars.UT_DISABLE_NODE_CURRENT }} # default is falsy

linux-unit-tests:
needs: determine-node-versions
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unitTestsWindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
id: determine-node-versions
with:
nodeVersionOverride: ${{ vars.NODE_VERSION_OVERRIDE }} # default is 'lts/*' and 'lts/-1'
nodeDisableCurrent: ${{ vars.UT_DISABLE_NODE_CURRENT }} # default is falsy

windows-unit-tests:
needs: determine-node-versions
Expand Down

0 comments on commit a1fcc30

Please sign in to comment.