Skip to content

Commit c79b9ba

Browse files
authored
feat: allow skipping node-1 (#126)
1 parent 222f1e3 commit c79b9ba

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

.github/actions/determineNodeVersions/action.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
nodeDisableCurrent:
99
description: Disable testing on Node "current"
1010
required: false
11+
nodeDisablePrevious:
12+
description: Disable testing on Node "-1"
13+
required: false
1114

1215
outputs:
1316
nodeVersions:
@@ -41,16 +44,29 @@ runs:
4144
id: node-versions
4245
run: |
4346
# Current can be disabled by setting the "nodeDisableCurrent" input to "true"
47+
# Previous LTS can be disabled by setting the "nodeDisablePrevious" input to "true"
4448
# IF "NODE_VERSION" is overridden, "NODE_VERSION_CURRENT" will also be disabled
49+
4550
NODE_VERSION_CURRENT="current"
46-
NODE_VERSION="${INPUTS_NODE_VERSION_OVERRIDE:-lts/*}"
47-
NODE_PREVIOUS_LTS="lts/-1"
51+
if [ "$INPUTS_NODE_DISABLE_CURRENT" = "true" ] || [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ]; then
52+
NODE_VERSION_CURRENT=""
53+
fi
4854
55+
NODE_VERSION="lts/*"
4956
if [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ]; then
57+
NODE_VERSION="$INPUTS_NODE_VERSION_OVERRIDE"
58+
fi
59+
60+
NODE_PREVIOUS_LTS="lts/-1"
61+
if [ "$INPUTS_NODE_DISABLE_PREVIOUS" = "true" ]; then
62+
NODE_PREVIOUS_LTS=""
63+
fi
64+
65+
if [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ] && [ "$INPUTS_NODE_DISABLE_PREVIOUS" != "true" ] ; then
5066
NODE_VERSION_MAJOR=$(echo "$INPUTS_NODE_VERSION_OVERRIDE" | cut -d '.' -f 1)
5167
5268
# LTS-1 will always be the previous LTS, which is always even. Here we calculate the nearest LTS
53-
if [ $((NODE_VERSION_MAJOR % 2)) == 0 ]; then
69+
if [ $((NODE_VERSION_MAJOR % 2)) = 0 ]; then
5470
NODE_PREVIOUS_LTS="$((NODE_VERSION_MAJOR - 2))"
5571
else
5672
NODE_PREVIOUS_LTS="$((NODE_VERSION_MAJOR - 1))"
@@ -59,13 +75,10 @@ runs:
5975
6076
{
6177
echo "nodeVersions<<EOF"
62-
if [ "$NODE_VERSION" = "lts/*" ] && [ "$INPUTS_NODE_DISABLE_CURRENT" != "true" ]; then
63-
jq -n --arg v1 "$NODE_VERSION_CURRENT" --arg v2 "$NODE_VERSION" --arg v3 "$NODE_PREVIOUS_LTS" '[$v1, $v2, $v3]'
64-
else
65-
jq -n --arg v1 "$NODE_VERSION" --arg v2 "$NODE_PREVIOUS_LTS" '[$v1, $v2]'
66-
fi
78+
jq -n --arg v1 "$NODE_VERSION_CURRENT" --arg v2 "$NODE_VERSION" --arg v3 "$NODE_PREVIOUS_LTS" '[$v1, $v2, $v3] | map(select(. != ""))'
6779
echo "EOF"
6880
} >> "$GITHUB_OUTPUT"
6981
env:
7082
INPUTS_NODE_VERSION_OVERRIDE: ${{ inputs.nodeVersionOverride }}
7183
INPUTS_NODE_DISABLE_CURRENT: ${{ inputs.nodeDisableCurrent }}
84+
INPUTS_NODE_DISABLE_PREVIOUS: ${{ inputs.nodeDisablePrevious }}

.github/workflows/unitTestsLinux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
with:
1919
nodeVersionOverride: ${{ vars.NODE_VERSION_OVERRIDE }} # default is 'lts/*' and 'lts/-1'
2020
nodeDisableCurrent: ${{ vars.UT_DISABLE_NODE_CURRENT }} # default is falsy
21+
nodeDisablePrevious: ${{ vars.UT_DISABLE_NODE_PREVIOUS }} # default is falsy
2122

2223
prevent-typescript-dependency:
2324
if: ${{ inputs.skipTsDepCheck == false }}

.github/workflows/unitTestsWindows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
with:
1313
nodeVersionOverride: ${{ vars.NODE_VERSION_OVERRIDE }} # default is 'lts/*' and 'lts/-1'
1414
nodeDisableCurrent: ${{ vars.UT_DISABLE_NODE_CURRENT }} # default is falsy
15+
nodeDisablePrevious: ${{ vars.UT_DISABLE_NODE_PREVIOUS }} # default is falsy
1516

1617
windows-unit-tests:
1718
needs: determine-node-versions

0 commit comments

Comments
 (0)