Skip to content

Commit 38add48

Browse files
authored
ci: fix non-pr triggered run-tests workflow (#3317)
1 parent 9ef6f09 commit 38add48

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

.github/workflows/run-tests.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
description: "The versions of Next.js to test against (quoted and comma separated)"
1111
required: false
1212
default: "latest"
13+
runOnWindows:
14+
description: "Run tests on Windows"
15+
type: boolean
1316

1417
jobs:
1518
setup:
@@ -48,10 +51,24 @@ jobs:
4851
uses: actions/github-script@v8
4952
with:
5053
script: |
51-
const { versionsToTest, runOnWindows } = ${{ steps.check-labels.outputs.result }} ?? {}
54+
// steps.check-labels.outputs.result will be not defined on non-PR events, so we create
55+
// either a JSON string or an empty string first and later will check if string is empty
56+
// and either parse JSON string or use a default empty object
57+
const checkLabelsResult = '${{ steps.check-labels.outputs.result }}';
58+
let { versionsToTest, runOnWindows } = checkLabelsResult ? JSON.parse(checkLabelsResult) : {}
5259
5360
if ('${{ github.event_name }}' === 'workflow_dispatch') {
54-
core.setOutput('matrix', '${{ github.event.inputs.versions }}');
61+
// attempt some massaging of input to cover potential variants of inputs
62+
// - `["latest", "canary"]`
63+
// - `latest, canary`
64+
// - `"latest", "canary"`
65+
// - `'latest','canary'`
66+
// Will strip `[]'"` and whitespaces first, then split by comma
67+
const normalizedVersionsInputArray = `${{ github.event.inputs.versions }}`
68+
.replaceAll(/["'\[\]\s]+/g, "")
69+
.split(',')
70+
71+
core.setOutput('matrix', JSON.stringify(normalizedVersionsInputArray));
5572
} else if ('${{ github.event_name }}' === 'schedule' || versionsToTest === 'all') {
5673
core.setOutput('matrix', '["latest", "canary", "15.5.9", "14.2.35", "13.5.1"]');
5774
} else if (versionsToTest === 'latest-and-canary') {
@@ -60,6 +77,10 @@ jobs:
6077
core.setOutput('matrix', '["latest"]');
6178
}
6279
80+
if ('${{ github.event_name }}' === 'workflow_dispatch' && "${{ github.event.inputs.runOnWindows }}" == "true") {
81+
runOnWindows = true
82+
}
83+
6384
if (runOnWindows) {
6485
core.setOutput('os', '["ubuntu-latest", "windows-2025"]');
6586
} else {

0 commit comments

Comments
 (0)