From 65735127a99d295e46a536614aabebc5399aaec0 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:14:22 -0400 Subject: [PATCH 1/8] Test macros against oldest declared node --- .github/workflows/ci.yml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01e299d315..088487879b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: CI on: workflow_dispatch: schedule: - - cron: '0 7 * * *' # daily, 7am + - cron: "0 7 * * *" # daily, 7am push: branches: @@ -22,8 +22,8 @@ jobs: strategy: fail-fast: false matrix: - node: ['20', '22', '24'] - os: [ubuntu-latest, 'macos-latest'] # TODO add windows here + node: ["20", "22", "24"] + os: [ubuntu-latest, "macos-latest"] # TODO add windows here steps: - uses: actions/checkout@v4 @@ -37,6 +37,28 @@ jobs: - run: pnpm install --no-lockfile - run: pnpm --filter "@embroider/*" test + extended-support: + runs-on: ${{matrix.os}} + timeout-minutes: 5 + + strategy: + fail-fast: false + matrix: + node: ["12"] + os: [ubuntu-latest, "macos-latest"] # TODO add windows here + + steps: + - uses: actions/checkout@v4 + - name: remove pinned node version + run: echo "auto-install-peers=false" > .npmrc + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{matrix.node}} + cache: pnpm + - run: pnpm install --no-lockfile + - run: pnpm --filter "@embroider/macros" test + preflight: runs-on: ubuntu-latest timeout-minutes: 5 @@ -55,9 +77,9 @@ jobs: echo "matrix=$matrix_json" >> $GITHUB_OUTPUT test: - needs: ['preflight'] + needs: ["preflight"] name: ${{ matrix.name }} - runs-on: '${{ matrix.os }}-latest' + runs-on: "${{ matrix.os }}-latest" timeout-minutes: 60 strategy: From 9d1a10945bb6806aea4bcfd7f981480f4d150276 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:23:23 -0400 Subject: [PATCH 2/8] Update CI --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 088487879b..5f445d6727 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,8 @@ jobs: fail-fast: false matrix: node: ["12"] - os: [ubuntu-latest, "macos-latest"] # TODO add windows here + os: [ubuntu-latest] + # macos doesn't have node 12 steps: - uses: actions/checkout@v4 From a177068d5808ce4e2f8c2e7c0c683d7c872caa30 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:23:52 -0400 Subject: [PATCH 3/8] Remove 'node:' prefix to support Node < 16 --- packages/macros/src/babel/app-ember-satisfies.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/macros/src/babel/app-ember-satisfies.ts b/packages/macros/src/babel/app-ember-satisfies.ts index 88700f39cc..7d54eb1d99 100644 --- a/packages/macros/src/babel/app-ember-satisfies.ts +++ b/packages/macros/src/babel/app-ember-satisfies.ts @@ -4,9 +4,9 @@ import type State from './state'; import { satisfies, coerce } from 'semver'; import error from './error'; import { assertArray } from './evaluate-json'; -import { pathToFileURL } from 'node:url'; -import { createRequire } from 'node:module'; -import { dirname } from 'node:path'; +import { pathToFileURL } from 'url'; +import { createRequire } from 'module'; +import { dirname } from 'path'; import findUp from 'find-up'; const packageName = 'ember-source'; From bb8a77d9e6c90b55b88e765235add70b528e4663 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Thu, 2 Oct 2025 14:09:43 +0100 Subject: [PATCH 4/8] test macros on legacy node versions --- .github/workflows/ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f445d6727..01ddf4e191 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,25 +37,23 @@ jobs: - run: pnpm install --no-lockfile - run: pnpm --filter "@embroider/*" test - extended-support: - runs-on: ${{matrix.os}} + legacy-macros: + runs-on: ubuntu-latest timeout-minutes: 5 strategy: fail-fast: false matrix: - node: ["12"] - os: [ubuntu-latest] - # macos doesn't have node 12 + node: ["12.22.12", "14.21.3", "16.20.2", "18.20.8", "20.19.5", "22.20.0", "24.9.0"] steps: - uses: actions/checkout@v4 - - name: remove pinned node version - run: echo "auto-install-peers=false" > .npmrc + - name: run test + run: echo "auto-install-peers=false\nuse-node-version=${{matrix.node}}" > .npmrc - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: - node-version: ${{matrix.node}} + node-version: 22 # this is only used for the pnpm install, the user-node-version above will be used in tests cache: pnpm - run: pnpm install --no-lockfile - run: pnpm --filter "@embroider/macros" test From 4ae5cc5dac65ad1ea84dcc4759fd0f73ee091fed Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Thu, 2 Oct 2025 14:19:45 +0100 Subject: [PATCH 5/8] verify node version on legacy test --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01ddf4e191..4622dd1f0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,6 +56,7 @@ jobs: node-version: 22 # this is only used for the pnpm install, the user-node-version above will be used in tests cache: pnpm - run: pnpm install --no-lockfile + - run: pnpm node -v - run: pnpm --filter "@embroider/macros" test preflight: From 4d672ce13f921ededb00fe54ab9da433cc2467f7 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Thu, 2 Oct 2025 14:22:59 +0100 Subject: [PATCH 6/8] use printf to override .npmrc --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4622dd1f0e..20500ca10f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,15 +48,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: run test - run: echo "auto-install-peers=false\nuse-node-version=${{matrix.node}}" > .npmrc - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: node-version: 22 # this is only used for the pnpm install, the user-node-version above will be used in tests cache: pnpm - run: pnpm install --no-lockfile + - name: downgrade Node Version in .npmrc + run: printf "auto-install-peers=false\nuse-node-version=${{matrix.node}}" > .npmrc - run: pnpm node -v + - run: cat .npmrc - run: pnpm --filter "@embroider/macros" test preflight: From 70868391670c6c580675963b7f98b7ea3a01daa6 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Thu, 2 Oct 2025 14:52:40 +0100 Subject: [PATCH 7/8] create a simple smoke test for macros --- .github/workflows/ci.yml | 2 +- packages/macros/package.json | 3 ++- packages/macros/smoke-test.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 packages/macros/smoke-test.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20500ca10f..86b5752f7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: run: printf "auto-install-peers=false\nuse-node-version=${{matrix.node}}" > .npmrc - run: pnpm node -v - run: cat .npmrc - - run: pnpm --filter "@embroider/macros" test + - run: pnpm --filter "@embroider/macros" test:smoke preflight: runs-on: ubuntu-latest diff --git a/packages/macros/package.json b/packages/macros/package.json index 5faaebcb61..ed86e19d55 100644 --- a/packages/macros/package.json +++ b/packages/macros/package.json @@ -26,7 +26,8 @@ "src/**/*.js.map" ], "scripts": { - "test": "vitest" + "test": "vitest", + "test:smoke": "node smoke-test.js" }, "dependencies": { "@embroider/shared-internals": "workspace:*", diff --git a/packages/macros/smoke-test.js b/packages/macros/smoke-test.js new file mode 100644 index 0000000000..ff7b450628 --- /dev/null +++ b/packages/macros/smoke-test.js @@ -0,0 +1,34 @@ +console.log(process.version); + +var babel = require("@babel/core"); + +const { join } = require('path'); + +const { MacrosConfig } = require('./src/node'); + +let config = MacrosConfig.for({}, __dirname); + +let response = babel.transform(` +import { macroCondition } from '@embroider/macros'; +export default function() { + if (macroCondition(true)) { + return 'alpha'; + } else { + return 'beta'; + } +} +`, { + filename: join(__dirname, 'sample.js'), + configFile: false, + plugins: config.babelPluginConfig(), +}); + + +if(response.code.trim() !== `export default function () { + { + return 'alpha'; + } +}`.trim()) { + console.error(response.code); + throw new Error("smoke test failed"); +} From beb5926ecda32e07c7a5d503f9d97dc3a1389109 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Thu, 2 Oct 2025 14:58:14 +0100 Subject: [PATCH 8/8] update snapshot because of new file --- packages/macros/tests/babel/import-sync.test.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/macros/tests/babel/import-sync.test.ts b/packages/macros/tests/babel/import-sync.test.ts index 03546bc517..5a40c58928 100644 --- a/packages/macros/tests/babel/import-sync.test.ts +++ b/packages/macros/tests/babel/import-sync.test.ts @@ -66,17 +66,19 @@ describe('importSync', function () { import * as _importSync20 from "../../README"; import * as _importSync40 from "../../node_modules"; import * as _importSync60 from "../../package"; - import * as _importSync80 from "../../src"; - import * as _importSync00 from "../../tests"; - import * as _importSync100 from "../../vitest.config"; + import * as _importSync80 from "../../smoke-test"; + import * as _importSync00 from "../../src"; + import * as _importSync100 from "../../tests"; + import * as _importSync120 from "../../vitest.config"; function getFile(file) { return { "README": esc(_importSync20), "node_modules": esc(_importSync40), "package": esc(_importSync60), - "src": esc(_importSync80), - "tests": esc(_importSync00), - "vitest.config": esc(_importSync100) + "smoke-test": esc(_importSync80), + "src": esc(_importSync00), + "tests": esc(_importSync100), + "vitest.config": esc(_importSync120) }[file].default; }" `);