Skip to content

Commit f4ab46d

Browse files
Merge pull request #41 from ember-cli/try-scenarios
Support scenario testing
2 parents 0647711 + bb506ca commit f4ab46d

File tree

14 files changed

+237
-49
lines changed

14 files changed

+237
-49
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
slow-test:
8181
- defaults with npm
8282
- defaults with pnpm
83+
- try-scenarios
8384
steps:
8485
- uses: actions/checkout@v4
8586
- uses: pnpm/action-setup@v4

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/node_modules/
1+
/node_modules/
2+
.log/

files/.github/workflows/ci.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
name: "Tests"
3434
runs-on: ubuntu-latest
3535
timeout-minutes: 10
36+
outputs:
37+
matrix: ${{ steps.set-matrix.outputs.matrix }}
3638

3739
steps:
3840
- uses: actions/checkout@v4<% if (pnpm) { %>
@@ -45,6 +47,11 @@ jobs:
4547
run: <%= pnpm ? 'pnpm install --frozen-lockfile' : yarn ? 'yarn install --frozen-lockfile' : 'npm ci' %>
4648
- name: Run Tests
4749
run: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm run' %> test
50+
# For the Try Scenarios
51+
- id: set-matrix
52+
run: |
53+
<% if (pnpm) { %> echo "matrix=$(pnpm -s dlx @embroider/try list)" >> $GITHUB_OUTPUT<% } %>
54+
<% if (npm) { %> echo "matrix=$(npx @embroider/try list)" >> $GITHUB_OUTPUT<% } %>
4855
4956
floating:
5057
name: "Floating Dependencies"
@@ -64,22 +71,13 @@ jobs:
6471
run: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm run' %> test
6572

6673
try-scenarios:
67-
name: ${{ matrix.try-scenario }}
74+
name: ${{ matrix.name }}
6875
runs-on: ubuntu-latest
6976
needs: "test"
7077
timeout-minutes: 10
71-
7278
strategy:
7379
fail-fast: false
74-
matrix:
75-
try-scenario:
76-
- ember-lts-4.12
77-
- ember-lts-5.4
78-
- ember-release
79-
- ember-beta
80-
- ember-canary
81-
- embroider-safe
82-
- embroider-optimized
80+
matrix: ${{fromJson(needs.test.outputs.matrix)}}
8381

8482
steps:
8583
- uses: actions/checkout@v4<% if (pnpm) { %>
@@ -88,7 +86,14 @@ jobs:
8886
with:
8987
node-version: 18
9088
cache: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm' %>
89+
- name: Apply Scenario
90+
run: |
91+
<% if (pnpm) { %> pnpm dlx @embroider/try apply ${{ matrix.name }}<% } %>
92+
<% if (npm) { %> npx @embroider/try apply ${{ matrix.name }}<% } %>
9193
- name: Install Dependencies
92-
run: <%= pnpm ? 'pnpm install --frozen-lockfile' : yarn ? 'yarn install --frozen-lockfile' : 'npm ci' %>
94+
run: <%= pnpm ? 'pnpm install --no-lockfile' : yarn ? 'yarn install --no-lockfile' : 'npm install --no-package-lock' %>
9395
- name: Run Tests
94-
run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }} --skip-cleanup
96+
run: |
97+
<% if (pnpm) { %>pnpm test<% } %>
98+
<% if (npm) { %>npm test<% } %>
99+
env: ${{ matrix.env }}

files/.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
/coverage/
1010
pnpm-lock.yaml
1111
config/ember-cli-update.json
12+
*.yaml
13+
*.yml
14+
*.md
15+
*.html

files/.try.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
export default scenarios();
2+
3+
function scenarios() {
4+
return {
5+
scenarios: [
6+
compatEmberScenario('ember-lts-5.8', '~5.4.0'),
7+
compatEmberScenario('ember-lts-5.12', '~5.12.0'),
8+
emberScenario('~6.4.0'),
9+
emberScenario('latest'),
10+
emberScenario('beta'),
11+
emberScenario('alpha'),
12+
],
13+
};
14+
}
15+
16+
function emberScenario(tag) {
17+
return {
18+
name: `ember-${tag}`,
19+
npm: {
20+
devDependencies: {
21+
'ember-source': `npm:ember-source@${tag}`,
22+
},
23+
},
24+
};
25+
}
26+
27+
function emberCliBuildJS() {
28+
return `const EmberApp = require('ember-cli/lib/broccoli/ember-app');
29+
const { compatBuild } = require('@embroider/compat');
30+
module.exports = async function (defaults) {
31+
const { buildOnce } = await import('@embroider/vite');
32+
let app = new EmberApp(defaults);
33+
return compatBuild(app, buildOnce);
34+
};`;
35+
}
36+
37+
function compatEmberScenario(name, emberVersion) {
38+
return {
39+
name,
40+
npm: {
41+
devDependencies: {
42+
'ember-source': emberVersion,
43+
'@embroider/compat': '^4.0.3',
44+
'ember-cli': '^5.12.0',
45+
'ember-auto-import': '^2.10.0',
46+
'@ember/optional-features': '^2.2.0',
47+
},
48+
},
49+
env: {
50+
ENABLE_COMPAT_BUILD: true,
51+
},
52+
files: {
53+
'ember-cli-build.js': emberCliBuildJS(),
54+
'config/optional-features.json': JSON.stringify({
55+
'application-template-wrapper': false,
56+
'default-async-observers': true,
57+
'jquery-integration': false,
58+
'template-only-glimmer-components': true,
59+
'no-implicit-route-model': true,
60+
}),
61+
},
62+
};
63+
}

files/babel.config.cjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
const { buildMacros } = require('@embroider/macros/babel');
22

3+
const {
4+
babelCompatSupport,
5+
templateCompatSupport,
6+
} = require('@embroider/compat/babel');
7+
38
const macros = buildMacros();
49

10+
// For scenario testing
11+
const isCompat = Boolean(process.env.ENABLE_COMPAT_BUILD);
12+
513
module.exports = {
614
plugins: [<% if (typescript) { %>
715
['@babel/plugin-transform-typescript', {
@@ -12,7 +20,9 @@ module.exports = {
1220
[
1321
'babel-plugin-ember-template-compilation',
1422
{
15-
transforms: [...macros.templateMacros],
23+
transforms: [
24+
...(isCompat ? templateCompatSupport() : macros.templateMacros),
25+
],
1626
},
1727
],
1828
[
@@ -23,7 +33,7 @@ module.exports = {
2333
},
2434
},
2535
],
26-
...macros.babelMacros,
36+
...(isCompat ? babelCompatSupport() : macros.babelMacros),
2737
],
2838

2939
generatorOpts: {

files/gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
dist/
33
declarations/
44

5+
# from scenarios
6+
tmp/
7+
config/optional-features.json
8+
ember-cli-build.js
9+
510
# npm/pnpm/yarn pack output
611
*.tgz
712

files/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"lint:js:fix": "eslint . --fix",<% if (typescript) { %>
2626
"lint:types": "glint",<% } %>
2727
"start": "vite dev",
28-
"test": "vite build --mode=development && testem --file testem.cjs ci",
28+
"test": "vite build --mode=development && testem --file testem.cjs ci --port 0",
2929
"prepack": "rollup --config"
3030
},
3131
"dependencies": {
@@ -38,10 +38,11 @@
3838
"@babel/plugin-transform-typescript": "^7.25.2",<% } %>
3939
"@babel/runtime": "^7.25.6",
4040
"@ember/test-helpers": "^5.2.1",
41-
"@embroider/addon-dev": "^7.1.0",
42-
"@embroider/core": "^4.0.0-alpha.10",
43-
"@embroider/macros": "^1.17.0-alpha.8",
44-
"@embroider/vite": "^1.0.0-alpha.12",
41+
"@embroider/addon-dev": "^8.0.1",
42+
"@embroider/core": "^4.1.0",
43+
"@embroider/compat": "^4.1.0",
44+
"@embroider/macros": "^1.18.0",
45+
"@embroider/vite": "^1.1.5",
4546
"@eslint/js": "^9.17.0",
4647
"@glimmer/component": "^2.0.0",<% if (typescript) { %>
4748
"@glint/core": "^1.4.0",

files/vite.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { defineConfig } from 'vite';
2-
import { extensions, ember } from '@embroider/vite';
2+
import { extensions, ember, classicEmberSupport } from '@embroider/vite';
33
import { babel } from '@rollup/plugin-babel';
44

5+
// For scenario testing
6+
const isCompat = Boolean(process.env.ENABLE_COMPAT_BUILD);
7+
58
export default defineConfig({
69
resolve: {
710
alias: [
@@ -12,6 +15,7 @@ export default defineConfig({
1215
],
1316
},
1417
plugins: [
18+
...(isCompat ? [classicEmberSupport()] : []),
1519
ember(),
1620
babel({
1721
babelHelpers: 'inline',

tests/fixtures/default/.github/workflows/ci.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
name: "Tests"
3333
runs-on: ubuntu-latest
3434
timeout-minutes: 10
35+
outputs:
36+
matrix: ${{ steps.set-matrix.outputs.matrix }}
3537

3638
steps:
3739
- uses: actions/checkout@v4
@@ -43,6 +45,11 @@ jobs:
4345
run: npm ci
4446
- name: Run Tests
4547
run: npm run test
48+
# For the Try Scenarios
49+
- id: set-matrix
50+
run: |
51+
52+
echo "matrix=$(npx @embroider/try list)" >> $GITHUB_OUTPUT
4653
4754
floating:
4855
name: "Floating Dependencies"
@@ -61,30 +68,28 @@ jobs:
6168
run: npm run test
6269

6370
try-scenarios:
64-
name: ${{ matrix.try-scenario }}
71+
name: ${{ matrix.name }}
6572
runs-on: ubuntu-latest
6673
needs: "test"
6774
timeout-minutes: 10
68-
6975
strategy:
7076
fail-fast: false
71-
matrix:
72-
try-scenario:
73-
- ember-lts-4.12
74-
- ember-lts-5.4
75-
- ember-release
76-
- ember-beta
77-
- ember-canary
78-
- embroider-safe
79-
- embroider-optimized
77+
matrix: ${{fromJson(needs.test.outputs.matrix)}}
8078

8179
steps:
8280
- uses: actions/checkout@v4
8381
- uses: actions/setup-node@v4
8482
with:
8583
node-version: 18
8684
cache: npm
85+
- name: Apply Scenario
86+
run: |
87+
88+
npx @embroider/try apply ${{ matrix.name }}
8789
- name: Install Dependencies
88-
run: npm ci
90+
run: npm install --no-package-lock
8991
- name: Run Tests
90-
run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }} --skip-cleanup
92+
run: |
93+
94+
npm test
95+
env: ${{ matrix.env }}

0 commit comments

Comments
 (0)