Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions .github/workflows/ci.yml
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out we don't prettier ignore this

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
workflow_dispatch:
schedule:
- cron: '0 7 * * *' # daily, 7am
- cron: "0 7 * * *" # daily, 7am

push:
branches:
Expand All @@ -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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should ubuntu-latest be between quotes like macos-latest?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk, it appears to not matter somehow


steps:
- uses: actions/checkout@v4
Expand All @@ -37,6 +37,29 @@ jobs:
- run: pnpm install --no-lockfile
- run: pnpm --filter "@embroider/*" test

legacy-macros:
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
fail-fast: false
matrix:
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
- 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:smoke

preflight:
runs-on: ubuntu-latest
timeout-minutes: 5
Expand All @@ -55,9 +78,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:
Expand Down
3 changes: 2 additions & 1 deletion packages/macros/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"src/**/*.js.map"
],
"scripts": {
"test": "vitest"
"test": "vitest",
"test:smoke": "node smoke-test.js"
},
"dependencies": {
"@embroider/shared-internals": "workspace:*",
Expand Down
34 changes: 34 additions & 0 deletions packages/macros/smoke-test.js
Original file line number Diff line number Diff line change
@@ -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");
}
6 changes: 3 additions & 3 deletions packages/macros/src/babel/app-ember-satisfies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So simple. But ugh

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';
Expand Down
14 changes: 8 additions & 6 deletions packages/macros/tests/babel/import-sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}"
`);
Expand Down
Loading