|
10 | 10 | description: "The versions of Next.js to test against (quoted and comma separated)" |
11 | 11 | required: false |
12 | 12 | default: "latest" |
| 13 | + runOnWindows: |
| 14 | + description: "Run tests on Windows" |
| 15 | + type: boolean |
13 | 16 |
|
14 | 17 | jobs: |
15 | 18 | setup: |
@@ -48,10 +51,24 @@ jobs: |
48 | 51 | uses: actions/github-script@v8 |
49 | 52 | with: |
50 | 53 | 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) : {} |
52 | 59 |
|
53 | 60 | 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)); |
55 | 72 | } else if ('${{ github.event_name }}' === 'schedule' || versionsToTest === 'all') { |
56 | 73 | core.setOutput('matrix', '["latest", "canary", "15.5.9", "14.2.35", "13.5.1"]'); |
57 | 74 | } else if (versionsToTest === 'latest-and-canary') { |
|
60 | 77 | core.setOutput('matrix', '["latest"]'); |
61 | 78 | } |
62 | 79 |
|
| 80 | + if ('${{ github.event_name }}' === 'workflow_dispatch' && "${{ github.event.inputs.runOnWindows }}" == "true") { |
| 81 | + runOnWindows = true |
| 82 | + } |
| 83 | +
|
63 | 84 | if (runOnWindows) { |
64 | 85 | core.setOutput('os', '["ubuntu-latest", "windows-2025"]'); |
65 | 86 | } else { |
|
0 commit comments