From 21c92624a9342d6fdbaafdf322ded5216b9188e5 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 1 May 2024 20:37:06 -0700 Subject: [PATCH] feat: use macos-(latest|13) based on node version (#440) --- .github/workflows/ci-release.yml | 14 +++++ .github/workflows/ci-test-workspace.yml | 14 +++++ .github/workflows/ci.yml | 14 +++++ lib/content/_job-matrix-yml.hbs | 10 ++++ lib/util/template.js | 3 ++ .../test/apply/source-snapshots.js.test.cjs | 54 +++++++++++++++++++ .../test/check/diff-snapshots.js.test.cjs | 2 +- 7 files changed, 110 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index d1c056c0..af138475 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -80,6 +80,9 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd @@ -89,6 +92,17 @@ jobs: - 20.5.0 - 20.x - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.17.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.5.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: ${{ matrix.platform.os }} defaults: run: diff --git a/.github/workflows/ci-test-workspace.yml b/.github/workflows/ci-test-workspace.yml index 64a0df3c..585d888e 100644 --- a/.github/workflows/ci-test-workspace.yml +++ b/.github/workflows/ci-test-workspace.yml @@ -61,6 +61,9 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd @@ -70,6 +73,17 @@ jobs: - 20.5.0 - 20.x - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.17.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.5.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: ${{ matrix.platform.os }} defaults: run: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca625af4..b934a8d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,9 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd @@ -70,6 +73,17 @@ jobs: - 20.5.0 - 20.x - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.17.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.5.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: ${{ matrix.platform.os }} defaults: run: diff --git a/lib/content/_job-matrix-yml.hbs b/lib/content/_job-matrix-yml.hbs index 5ad768b0..c8b731e1 100644 --- a/lib/content/_job-matrix-yml.hbs +++ b/lib/content/_job-matrix-yml.hbs @@ -11,6 +11,9 @@ strategy: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash {{/if}} {{#if windowsCI}} - name: Windows @@ -21,6 +24,13 @@ strategy: {{#each ciVersions}} - {{ . }} {{/each}} + {{#if macCI}} + exclude: + {{#each ciVersions}} + - platform: {name: macOS, os: macos-{{#if (lte (semverRangeMajor .) 14)}}latest{{else}}13{{/if}}, shell: bash} + node-version: {{ . }} + {{/each}} + {{/if}} runs-on: $\{{ matrix.platform.os }} defaults: run: diff --git a/lib/util/template.js b/lib/util/template.js index d035b3db..8a291f48 100644 --- a/lib/util/template.js +++ b/lib/util/template.js @@ -1,5 +1,6 @@ const Handlebars = require('handlebars') const { basename, extname, join } = require('path') +const { Range } = require('semver') const fs = require('fs') const DELETE = '__DELETE__' @@ -39,6 +40,8 @@ const setupHandlebars = (dirs) => { Handlebars.registerHelper('last', (arr) => arr[arr.length - 1]) Handlebars.registerHelper('json', (c) => JSON.stringify(c)) Handlebars.registerHelper('del', () => JSON.stringify(DELETE)) + Handlebars.registerHelper('semverRangeMajor', (v) => new Range(v).set[0][0].semver.major) + Handlebars.registerHelper('lte', (a, b) => a <= b) if (Array.isArray(dirs)) { const [baseDir, ...otherDirs] = dirs diff --git a/tap-snapshots/test/apply/source-snapshots.js.test.cjs b/tap-snapshots/test/apply/source-snapshots.js.test.cjs index e44a1f9f..5ef24507 100644 --- a/tap-snapshots/test/apply/source-snapshots.js.test.cjs +++ b/tap-snapshots/test/apply/source-snapshots.js.test.cjs @@ -471,11 +471,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -584,11 +590,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -1878,11 +1890,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -1978,11 +1996,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -2095,11 +2119,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -2214,11 +2244,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -3525,11 +3561,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -3625,11 +3667,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: @@ -3742,11 +3790,17 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 22.x + exclude: + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: \${{ matrix.platform.os }} defaults: run: diff --git a/tap-snapshots/test/check/diff-snapshots.js.test.cjs b/tap-snapshots/test/check/diff-snapshots.js.test.cjs index a14c85c3..2913d7bd 100644 --- a/tap-snapshots/test/check/diff-snapshots.js.test.cjs +++ b/tap-snapshots/test/check/diff-snapshots.js.test.cjs @@ -175,7 +175,7 @@ The repo file ci.yml needs to be updated: .github/workflows/ci.yml ======================================== - @@ -77,4 +77,24 @@ + @@ -97,4 +97,24 @@ shell: \${{ matrix.platform.shell }} steps: - name: Checkout