From cc5c6ff8ceebf79fa672e092e2703ee2915c7596 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 25 Mar 2021 18:24:24 -0400 Subject: [PATCH 1/4] Add windows scenarios to CI matrix generator --- .github/workflows/ci.yml | 3 +- test-packages/support/suite-setup-util.ts | 34 +++++++++++++++-------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db8d0060b..af3138183 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,8 @@ jobs: test: needs: discover_matrix name: ${{ matrix.name }} - runs-on: ubuntu-latest + runs-on: "${{ matrix.os }}-latest" + strategy: fail-fast: false matrix: ${{fromJson(needs.discover_matrix.outputs.matrix)}} diff --git a/test-packages/support/suite-setup-util.ts b/test-packages/support/suite-setup-util.ts index c81fb6691..011565ae1 100644 --- a/test-packages/support/suite-setup-util.ts +++ b/test-packages/support/suite-setup-util.ts @@ -92,21 +92,31 @@ export async function githubMatrix() { dir: resolve(__dirname, '..', '..'), }); - // add our eslint - suites.unshift({ - name: 'lint', - command: 'yarn', - args: ['lint'], - dir: resolve(__dirname, '..', '..'), - }); - - return { - name: suites.map(s => s.name), - include: suites.map(s => ({ - name: s.name, + let include = [ + // add our eslint + { + name: 'lint', + os: 'ubuntu', + command: 'yarn lint', + dir: resolve(__dirname, '..', '..'), + }, + ...suites.map(s => ({ + name: `${s.name} ubuntu`, + os: 'ubuntu', + command: `${s.command} ${s.args.join(' ')}`, + dir: s.dir, + })), + ...suites.map(s => ({ + name: `${s.name} windows`, + os: 'windows', command: `${s.command} ${s.args.join(' ')}`, dir: s.dir, })), + ]; + + return { + name: include.map(s => s.name), + include, }; } From d5ddf22642a5fa1dea0ba61164287c89fb5d3ee2 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 26 Mar 2021 12:07:24 -0400 Subject: [PATCH 2/4] Ensure windows CI jobs use relative directory from repo root --- test-packages/support/suite-setup-util.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test-packages/support/suite-setup-util.ts b/test-packages/support/suite-setup-util.ts index 011565ae1..bfbc885a6 100644 --- a/test-packages/support/suite-setup-util.ts +++ b/test-packages/support/suite-setup-util.ts @@ -1,5 +1,5 @@ import { tmpdir } from 'os'; -import { basename, join, resolve } from 'path'; +import { basename, join, relative, resolve } from 'path'; import { readdirSync, statSync, unlinkSync, writeFileSync } from 'fs-extra'; // we sometimes run our various Ember app's test suites in parallel, and @@ -81,6 +81,12 @@ export async function allSuites({ includeEmberTry } = { includeEmberTry: true }) return suites; } +function relativeToEmbroiderRoot(absolutePath: string): string { + let embroiderRoot = resolve(__dirname, '../..'); + + return relative(embroiderRoot, absolutePath); +} + export async function githubMatrix() { let suites = await allSuites(); @@ -110,7 +116,7 @@ export async function githubMatrix() { name: `${s.name} windows`, os: 'windows', command: `${s.command} ${s.args.join(' ')}`, - dir: s.dir, + dir: relativeToEmbroiderRoot(s.dir), })), ]; From 6eb129f635852e47c94b897b52557e232ed9fbd9 Mon Sep 17 00:00:00 2001 From: Travis Hoover Date: Wed, 31 Mar 2021 11:08:37 -0700 Subject: [PATCH 3/4] Fixing additional Windows bugs --- package.json | 1 + packages/compat/src/detect-babel-plugins.ts | 10 +++++++--- packages/compat/src/v1-app.ts | 4 ++-- packages/router/package.json | 3 ++- packages/util/package.json | 5 +++-- packages/webpack/src/ember-webpack.ts | 1 + test-packages/engines-host-app/fastboot-tests/util.js | 6 +++--- test-packages/engines-host-app/package.json | 4 ++-- test-packages/fastboot-app/fastboot-tests/util.js | 6 +++--- test-packages/fastboot-app/package.json | 6 +++--- test-packages/macro-sample-addon/package.json | 2 +- test-packages/macro-tests/package.json | 2 +- test-packages/static-app/package.json | 6 +++--- yarn.lock | 9 ++++++++- 14 files changed, 40 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 98abbd163..3be626aa1 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@types/jest": "^24.0.11", "@typescript-eslint/eslint-plugin": "^4.1.1", "@typescript-eslint/parser": "^4.1.1", + "cross-env": "^7.0.3", "eslint": "^7.14.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-import": "^2.22.0", diff --git a/packages/compat/src/detect-babel-plugins.ts b/packages/compat/src/detect-babel-plugins.ts index de78c4647..4e596811a 100644 --- a/packages/compat/src/detect-babel-plugins.ts +++ b/packages/compat/src/detect-babel-plugins.ts @@ -1,4 +1,5 @@ import { PluginItem } from '@babel/core'; +import { join, sep } from 'path'; export function isEmberAutoImportDynamic(item: PluginItem): boolean { let pluginPath: string; @@ -9,7 +10,8 @@ export function isEmberAutoImportDynamic(item: PluginItem): boolean { } else { return false; } - return /(^|\/)ember-auto-import\//.test(pluginPath); + + return pluginPath.includes(join(sep, 'ember-auto-import', sep)); } export function isCompactReexports(item: PluginItem): boolean { @@ -21,7 +23,8 @@ export function isCompactReexports(item: PluginItem): boolean { } else { return false; } - return /(^|\/)babel-plugin-compact-reexports\//.test(pluginPath); + + return pluginPath.includes(join('babel-plugin-compact-reexports', sep)); } export function isColocationPlugin(item: PluginItem): boolean { @@ -33,5 +36,6 @@ export function isColocationPlugin(item: PluginItem): boolean { } else { return false; } - return /(^|\/)ember-cli-htmlbars\/lib\/colocated-babel-plugin/.test(pluginPath); + + return pluginPath.includes(join('ember-cli-htmlbars', 'lib', 'colocated-babel-plugin', sep)); } diff --git a/packages/compat/src/v1-app.ts b/packages/compat/src/v1-app.ts index 74005622d..2b815c96f 100644 --- a/packages/compat/src/v1-app.ts +++ b/packages/compat/src/v1-app.ts @@ -1,6 +1,6 @@ import { Memoize } from 'typescript-memoize'; import { sync as pkgUpSync } from 'pkg-up'; -import { join, dirname } from 'path'; +import { join, dirname, isAbsolute } from 'path'; import Funnel from 'broccoli-funnel'; import mergeTrees from 'broccoli-merge-trees'; import { WatchedDir } from 'broccoli-source'; @@ -532,7 +532,7 @@ export default class V1App { } // non node assets are local paths. They need an explicit `/` or `.` at // the start. - if (asset.startsWith('/') || asset.startsWith('.')) { + if (asset.startsWith('.') || isAbsolute(asset)) { return asset; } return './' + asset; diff --git a/packages/router/package.json b/packages/router/package.json index a3166d9ec..d1baaebf9 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -25,7 +25,7 @@ "test": "npm-run-all lint:* test:*", "test:all": "ember try:each", "test:ember": "ember test --test-port=0", - "test:classic": "CLASSIC=true ember test --test-port=0" + "test:classic": "cross-env CLASSIC=true ember test --test-port=0" }, "dependencies": { "@embroider/macros": "0.39.1", @@ -40,6 +40,7 @@ "@types/ember__routing": "^3.16.9", "babel-eslint": "^10.1.0", "broccoli-asset-rev": "^3.0.0", + "cross-env": "^7.0.3", "ember-cli": "~3.10.1", "ember-cli-dependency-checker": "^3.1.0", "ember-cli-eslint": "^5.1.0", diff --git a/packages/util/package.json b/packages/util/package.json index 922f90856..b8a76624d 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -23,8 +23,8 @@ "lint:js:fix": "eslint . --fix", "start": "ember serve", "test": "npm-run-all lint test:*", - "test:ember": "EMBROIDER_TEST_SETUP_FORCE=embroider EMBROIDER_TEST_SETUP_OPTIONS=optimized ember test --test-port=0", - "test:classic": "EMBROIDER_TEST_SETUP_FORCE=classic ember test --test-port=0", + "test:ember": "cross-env EMBROIDER_TEST_SETUP_FORCE=embroider EMBROIDER_TEST_SETUP_OPTIONS=optimized ember test --test-port=0", + "test:classic": "cross-env EMBROIDER_TEST_SETUP_FORCE=classic ember test --test-port=0", "test:ember-compatibility": "ember try:each" }, "dependencies": { @@ -46,6 +46,7 @@ "@typescript-eslint/parser": "^4.1.1", "babel-eslint": "^10.1.0", "broccoli-asset-rev": "^3.0.0", + "cross-env": "^7.0.3", "ember-auto-import": "^1.10.1", "ember-cli": "~3.25.2", "ember-cli-dependency-checker": "^3.2.0", diff --git a/packages/webpack/src/ember-webpack.ts b/packages/webpack/src/ember-webpack.ts index 0d48bf491..2922896d3 100644 --- a/packages/webpack/src/ember-webpack.ts +++ b/packages/webpack/src/ember-webpack.ts @@ -141,6 +141,7 @@ const Webpack: Packager = class Webpack implements PackagerInstance { hints: false, }, plugins: [ + //@ts-ignore new MiniCssExtractPlugin({ filename: `chunk.[chunkhash].css`, chunkFilename: `chunk.[chunkhash].css`, diff --git a/test-packages/engines-host-app/fastboot-tests/util.js b/test-packages/engines-host-app/fastboot-tests/util.js index 73e3ff924..254a132e3 100644 --- a/test-packages/engines-host-app/fastboot-tests/util.js +++ b/test-packages/engines-host-app/fastboot-tests/util.js @@ -22,9 +22,9 @@ module.exports = function setup(hooks) { return dom.window.document; } - hooks.before(async function(assert) { + hooks.before(async function (assert) { if (!process.env.REUSE_FASTBOOT_BUILD) { - execFileSync('node', ['./node_modules/.bin/ember', 'build']); + execFileSync('node', ['../../node_modules/ember-cli/bin/ember', 'build']); process.env.REUSE_FASTBOOT_BUILD = 'true'; } fastboot = new FastBoot({ @@ -33,7 +33,7 @@ module.exports = function setup(hooks) { }); this.visit = visit.bind(this, assert); }); - hooks.beforeEach(function(assert) { + hooks.beforeEach(function (assert) { this.visit = visit.bind(this, assert); }); }; diff --git a/test-packages/engines-host-app/package.json b/test-packages/engines-host-app/package.json index b43fc663d..f0298198d 100644 --- a/test-packages/engines-host-app/package.json +++ b/test-packages/engines-host-app/package.json @@ -18,9 +18,9 @@ "start": "ember serve", "test": "npm-run-all lint:* test:*", "test:ember": "ember test --test-port=0", - "test:ember-classic": "CLASSIC=true ember test --test-port=0", + "test:ember-classic": "cross-env CLASSIC=true ember test --test-port=0", "test:fastboot": "qunit fastboot-tests", - "test:fastboot-classic": "CLASSIC=true qunit fastboot-tests" + "test:fastboot-classic": "cross-env CLASSIC=true qunit fastboot-tests" }, "devDependencies": { "@ember/jquery": "^0.6.0", diff --git a/test-packages/fastboot-app/fastboot-tests/util.js b/test-packages/fastboot-app/fastboot-tests/util.js index fa6a6e79d..0e430ee70 100644 --- a/test-packages/fastboot-app/fastboot-tests/util.js +++ b/test-packages/fastboot-app/fastboot-tests/util.js @@ -22,9 +22,9 @@ module.exports = function setup(hooks, buildArgs = []) { return dom.window.document; } - hooks.before(async function(assert) { + hooks.before(async function (assert) { if (!process.env.REUSE_FASTBOOT_BUILD) { - execFileSync('node', ['./node_modules/.bin/ember', 'build', ...buildArgs]); + execFileSync('node', ['../../node_modules/ember-cli/bin/ember', 'build', ...buildArgs]); process.env.REUSE_FASTBOOT_BUILD = 'true'; } fastboot = new FastBoot({ @@ -33,7 +33,7 @@ module.exports = function setup(hooks, buildArgs = []) { }); this.visit = visit.bind(this, assert); }); - hooks.beforeEach(function(assert) { + hooks.beforeEach(function (assert) { this.visit = visit.bind(this, assert); }); }; diff --git a/test-packages/fastboot-app/package.json b/test-packages/fastboot-app/package.json index 414d48cc6..53c7863ee 100644 --- a/test-packages/fastboot-app/package.json +++ b/test-packages/fastboot-app/package.json @@ -18,11 +18,11 @@ "start": "ember serve", "test": "npm-run-all lint:* test:*", "test:ember": "ember test --test-port=0", - "test:ember-classic": "CLASSIC=true ember test --test-port=0", + "test:ember-classic": "cross-env CLASSIC=true ember test --test-port=0", "test:ember-production": "ember test --test-port=0 --environment=production", "test:fastboot": "qunit fastboot-tests", - "test:fastboot-production": "FASTBOOT_APP_PROD=true qunit fastboot-tests", - "test:fastboot-classic": "CLASSIC=true FASTBOOT_APP_PROD=true qunit fastboot-tests" + "test:fastboot-production": "cross-env FASTBOOT_APP_PROD=true qunit fastboot-tests", + "test:fastboot-classic": "cross-env CLASSIC=true FASTBOOT_APP_PROD=true qunit fastboot-tests" }, "devDependencies": { "@ember/optional-features": "^1.3.0", diff --git a/test-packages/macro-sample-addon/package.json b/test-packages/macro-sample-addon/package.json index 51d4bd10b..9cb910530 100644 --- a/test-packages/macro-sample-addon/package.json +++ b/test-packages/macro-sample-addon/package.json @@ -21,7 +21,7 @@ "test": "npm-run-all lint:* test:*", "test:all": "ember try:each", "test:ember": "ember test --test-port=0", - "test:classic:": "CLASSIC=true ember test --test-port=0" + "test:classic:": "cross-env CLASSIC=true ember test --test-port=0" }, "dependencies": { "@embroider/macros": "0.39.1", diff --git a/test-packages/macro-tests/package.json b/test-packages/macro-tests/package.json index fecc8ab04..c0aa06e4b 100644 --- a/test-packages/macro-tests/package.json +++ b/test-packages/macro-tests/package.json @@ -18,7 +18,7 @@ "start": "ember serve", "test": "npm-run-all lint:* test:*", "test:ember": "ember test --test-port=0", - "test:ember-classic": "CLASSIC=true ember test --test-port=0" + "test:ember-classic": "cross-env CLASSIC=true ember test --test-port=0" }, "devDependencies": { "@ember/jquery": "^0.6.0", diff --git a/test-packages/static-app/package.json b/test-packages/static-app/package.json index fdee4984e..82af92cab 100644 --- a/test-packages/static-app/package.json +++ b/test-packages/static-app/package.json @@ -18,9 +18,9 @@ "start": "ember serve", "test": "npm-run-all lint:* test:*", "test:ember": "ember test --test-port=0", - "test:ember-classic": "CLASSIC=true ember test --test-port=0", - "test:custom-root": "CUSTOM_ROOT_URL=/custom/ ember test --test-port=0", - "test:custom-relative-root": "CUSTOM_ROOT_URL=custom-relative-root-url/ ember test --test-port=0" + "test:ember-classic": "cross-env CLASSIC=true ember test --test-port=0", + "test:custom-root": "cross-env CUSTOM_ROOT_URL=/custom/ ember test --test-port=0", + "test:custom-relative-root": "cross-env CUSTOM_ROOT_URL=custom-relative-root-url/ ember test --test-port=0" }, "devDependencies": { "@ember/jquery": "^0.5.2", diff --git a/yarn.lock b/yarn.lock index 537f4ef64..9ff2c5825 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6115,6 +6115,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-env@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + cross-spawn@^6.0.0, cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -6126,7 +6133,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== From ac69c990944ed7d1ce557394f77581a41898c5b9 Mon Sep 17 00:00:00 2001 From: Travis Hoover Date: Thu, 1 Apr 2021 23:05:05 -0700 Subject: [PATCH 4/4] fixing remaing tests --- packages/core/src/app.ts | 5 +++-- packages/shared-internals/src/paths.ts | 2 +- test-packages/support/suite-setup-util.ts | 14 ++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/core/src/app.ts b/packages/core/src/app.ts index 96cb94349..3c8b861d2 100644 --- a/packages/core/src/app.ts +++ b/packages/core/src/app.ts @@ -1271,8 +1271,9 @@ export class AppBuilder { } let runtime = join(packageName, name).replace(this.resolvableExtensionsPattern, ''); - if (renamedModules && renamedModules[runtime]) { - runtime = renamedModules[runtime]; + let runtimeRenameLookup = runtime.split('\\').join('/'); + if (renamedModules && renamedModules[runtimeRenameLookup]) { + runtime = renamedModules[runtimeRenameLookup]; } runtime = runtime.split(sep).join('/'); lazyModules.push({ diff --git a/packages/shared-internals/src/paths.ts b/packages/shared-internals/src/paths.ts index cc961c05b..1fa771382 100644 --- a/packages/shared-internals/src/paths.ts +++ b/packages/shared-internals/src/paths.ts @@ -8,7 +8,7 @@ import { relative, isAbsolute, dirname, join, basename } from 'path'; // export function explicitRelative(fromDir: string, toFile: string) { let result = join(relative(fromDir, dirname(toFile)), basename(toFile)); - if (!result.startsWith('/') && !result.startsWith('.')) { + if (!isAbsolute(result) && !result.startsWith('.')) { result = './' + result; } if (isAbsolute(toFile) && result.endsWith(toFile)) { diff --git a/test-packages/support/suite-setup-util.ts b/test-packages/support/suite-setup-util.ts index bfbc885a6..c21c46eed 100644 --- a/test-packages/support/suite-setup-util.ts +++ b/test-packages/support/suite-setup-util.ts @@ -112,12 +112,14 @@ export async function githubMatrix() { command: `${s.command} ${s.args.join(' ')}`, dir: s.dir, })), - ...suites.map(s => ({ - name: `${s.name} windows`, - os: 'windows', - command: `${s.command} ${s.args.join(' ')}`, - dir: relativeToEmbroiderRoot(s.dir), - })), + ...suites + .filter(s => s.name !== 'node') // TODO: node tests do not work under windows yet + .map(s => ({ + name: `${s.name} windows`, + os: 'windows', + command: `${s.command} ${s.args.join(' ')}`, + dir: relativeToEmbroiderRoot(s.dir), + })), ]; return {