Skip to content

Commit

Permalink
feat: allow skipping node-1
Browse files Browse the repository at this point in the history
  • Loading branch information
iowillhoit committed Aug 29, 2024
1 parent 222f1e3 commit 47009d4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
29 changes: 21 additions & 8 deletions .github/actions/determineNodeVersions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
nodeDisableCurrent:
description: Disable testing on Node "current"
required: false
nodeDisablePrevious:
description: Disable testing on Node "-1"
required: false

outputs:
nodeVersions:
Expand Down Expand Up @@ -41,16 +44,29 @@ runs:
id: node-versions
run: |
# Current can be disabled by setting the "nodeDisableCurrent" input to "true"
# Previous LTS can be disabled by setting the "nodeDisablePrevious" input to "true"
# IF "NODE_VERSION" is overridden, "NODE_VERSION_CURRENT" will also be disabled
NODE_VERSION_CURRENT="current"
NODE_VERSION="${INPUTS_NODE_VERSION_OVERRIDE:-lts/*}"
NODE_PREVIOUS_LTS="lts/-1"
if [ "$INPUTS_NODE_DISABLE_CURRENT" = "true" ] || [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ]; then
NODE_VERSION_CURRENT=""
fi
NODE_VERSION="lts/*"
if [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ]; then
NODE_VERSION="$INPUTS_NODE_VERSION_OVERRIDE"
fi
NODE_PREVIOUS_LTS="lts/-1"
if [ "$INPUTS_NODE_DISABLE_PREVIOUS" = "true" ]; then
NODE_PREVIOUS_LTS=""
fi
if [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ] && [ "$INPUTS_NODE_DISABLE_PREVIOUS" != "true" ] ; then
NODE_VERSION_MAJOR=$(echo "$INPUTS_NODE_VERSION_OVERRIDE" | cut -d '.' -f 1)
# LTS-1 will always be the previous LTS, which is always even. Here we calculate the nearest LTS
if [ $((NODE_VERSION_MAJOR % 2)) == 0 ]; then
if [ $((NODE_VERSION_MAJOR % 2)) = 0 ]; then
NODE_PREVIOUS_LTS="$((NODE_VERSION_MAJOR - 2))"
else
NODE_PREVIOUS_LTS="$((NODE_VERSION_MAJOR - 1))"
Expand All @@ -59,13 +75,10 @@ runs:
{
echo "nodeVersions<<EOF"
if [ "$NODE_VERSION" = "lts/*" ] && [ "$INPUTS_NODE_DISABLE_CURRENT" != "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
jq -n --arg v1 "$NODE_VERSION_CURRENT" --arg v2 "$NODE_VERSION" --arg v3 "$NODE_PREVIOUS_LTS" '[$v1, $v2, $v3] | map(select(. != ""))'
echo "EOF"
} >> "$GITHUB_OUTPUT"
env:
INPUTS_NODE_VERSION_OVERRIDE: ${{ inputs.nodeVersionOverride }}
INPUTS_NODE_DISABLE_CURRENT: ${{ inputs.nodeDisableCurrent }}
INPUTS_NODE_DISABLE_PREVIOUS: ${{ inputs.nodeDisablePrevious }}
1 change: 1 addition & 0 deletions .github/workflows/unitTestsLinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
with:
nodeVersionOverride: ${{ vars.NODE_VERSION_OVERRIDE }} # default is 'lts/*' and 'lts/-1'
nodeDisableCurrent: ${{ vars.UT_DISABLE_NODE_CURRENT }} # default is falsy
nodeDisablePrevious: ${{ vars.UT_DISABLE_NODE_PREVIOUS }} # default is falsy

prevent-typescript-dependency:
if: ${{ inputs.skipTsDepCheck == false }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unitTestsWindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
with:
nodeVersionOverride: ${{ vars.NODE_VERSION_OVERRIDE }} # default is 'lts/*' and 'lts/-1'
nodeDisableCurrent: ${{ vars.UT_DISABLE_NODE_CURRENT }} # default is falsy
nodeDisablePrevious: ${{ vars.UT_DISABLE_NODE_PREVIOUS }} # default is falsy

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

0 comments on commit 47009d4

Please sign in to comment.