Skip to content

Commit

Permalink
Revert "Upgrade CI / re-roll lockfile (#455)"
Browse files Browse the repository at this point in the history
This reverts commit 579c090.
  • Loading branch information
scalvert authored Oct 2, 2023
1 parent 579c090 commit cab0a91
Show file tree
Hide file tree
Showing 6 changed files with 21,899 additions and 2,096 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: volta-cli/action@v4
- run: npm install
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
with:
node-version: 10.x
- run: npm ci
- run: npm run lint
- run: npm run test

Expand All @@ -28,9 +30,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: volta-cli/action@v4
- run: npm install
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
with:
node-version: 12.x
- run: npm ci
- run: npm test

try-scenarios:
Expand Down Expand Up @@ -59,9 +63,11 @@ jobs:
- embroider-optimized

steps:
- uses: actions/checkout@v3
- uses: volta-cli/action@v4
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
with:
node-version: 12.x
- name: install dependencies
run: npm install
run: npm ci
- name: test
run: node_modules/.bin/ember try:one ${{ matrix.ember-try-scenario }} --skip-cleanup
4 changes: 0 additions & 4 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ module.exports = async function () {
webpack: '^5.0.0',
},
devDependencies: {
'@types/ember__owner': '^4.0.3',
'ember-resolver': '^10.0.0',
'ember-source': await getChannelURL('beta'),
},
},
Expand All @@ -126,8 +124,6 @@ module.exports = async function () {
webpack: '^5.0.0',
},
devDependencies: {
'@types/ember__owner': '^4.0.3',
'ember-resolver': '^10.0.0',
'ember-source': await getChannelURL('canary'),
},
},
Expand Down
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ module.exports = {
*/
let babel = this.addons.find((a) => a.name === 'ember-cli-babel');

return babel.transpileTree(tree);
let input;

// ember-cli-typescript should ultimately handle this for us.
if (this.isDevelopingAddon()) {
const { BroccoliBabelPresetTypeScript } = require('broccoli-babel-preset-typescript'); // eslint-disable-line node/no-unpublished-require
input = new BroccoliBabelPresetTypeScript([tree]);
} else {
input = tree;
}
return babel.transpileTree(input);
},
};
212 changes: 212 additions & 0 deletions node-tests/force-highlander-addon-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
const QUnit = require('qunit');
const path = require('path');
const Addon = require('ember-cli/lib/models/addon');
const VersionChecker = require('ember-cli-version-checker');
const highlander = require('../force-highlander-addon');
const addonIndex = require('../index');

const test = QUnit.test;
const STABLE_FUNCTION_REF = () => {};

['ember-test-waiters', '@ember/test-waiters'].forEach((moduleName) => {
QUnit.module(`force-highlander-addon for ${moduleName}`, function (hooks) {
hooks.beforeEach(function () {
this.project = {
name: 'ember-top-level-package',
pkg: { version: '1.0.0' },
isEmberCLIProject: () => {},
_addonsInitialized: true,
addons: [
{
name: 'baz',
pkg: { version: '1.0.3' },
addons: [
{
name: moduleName,
pkg: { version: '1.1.0' },
addons: [
{
name: 'foo',
version: '1.0.0',
addons: [],
},
],
cacheKeyForTree: STABLE_FUNCTION_REF,
treeFor: STABLE_FUNCTION_REF,
included: STABLE_FUNCTION_REF,
},
],
treeFor: STABLE_FUNCTION_REF,
included: STABLE_FUNCTION_REF,
},
{
name: moduleName,
pkg: { version: '1.0.3' },
addons: [
{
name: 'blarg',
pkg: { version: '1.1.0' },
addons: [
{
name: 'foo',
version: '1.0.0',
addons: [],
},
],
cacheKeyForTree: STABLE_FUNCTION_REF,
treeFor: STABLE_FUNCTION_REF,
included: STABLE_FUNCTION_REF,
},
],
cacheKeyForTree: STABLE_FUNCTION_REF,
treeFor: STABLE_FUNCTION_REF,
included: STABLE_FUNCTION_REF,
},
{
name: 'foo',
pkg: { version: '1.0.0' },
addons: [
{
name: moduleName,
pkg: { version: '2.0.0' },
addons: [
{
name: 'foo',
pkg: { version: '1.0.0' },
addons: [],
},
],
cacheKeyForTree: STABLE_FUNCTION_REF,
treeFor: STABLE_FUNCTION_REF,
included: STABLE_FUNCTION_REF,
},
],
},
{
name: 'bar',
pkg: { version: '1.0.0' },
addons: [
{
name: moduleName,
pkg: { version: '3.0.1' },
addons: [
{
name: 'foo',
pkg: { version: '1.0.0' },
addons: [],
},
],
cacheKeyForTree: STABLE_FUNCTION_REF,
treeFor: STABLE_FUNCTION_REF,
included: STABLE_FUNCTION_REF,
},
],
},
],
};
});

test('findLatestVersion can find the latest version from the set', function (assert) {
let checker = VersionChecker.forProject(this.project);
let addons = [
...checker.filterAddonsByName('ember-test-waiters'),
...checker.filterAddonsByName('@ember/test-waiters'),
];
let latestVersion = highlander.findLatestVersion(addons);

assert.equal(latestVersion.pkg.version, '3.0.1');
});

test('findLatestVersion can find beta versions', function (assert) {
let addons = [
{
name: 'foo',
pkg: { version: '1.0.0' },
},
{
name: 'foo',
pkg: { version: '1.1.0-beta.1' },
},
];
let latestVersion = highlander.findLatestVersion(addons);

assert.equal(latestVersion.pkg.version, '1.1.0-beta.1');
});

test('forceHighlander nullifies non-latest addon `included` methods', function (assert) {
let testWaiterAddons = highlander.forceHighlander(this.project);

assert.equal(testWaiterAddons.length, 3);

testWaiterAddons.forEach((addon) => {
assert.notEqual(addon.included, STABLE_FUNCTION_REF);
});
});

test('forceHighlander monkey patches non-latest w/ latest `treeFor`', function (assert) {
let checker = VersionChecker.forProject(this.project);
let addons = [
...checker.filterAddonsByName('ember-test-waiters'),
...checker.filterAddonsByName('@ember/test-waiters'),
];
let latestVersion = highlander.findLatestVersion(addons);

latestVersion.treeFor = () => {
assert.step('latest `treeFor` called');
};

let nonLatestTestWaiterAddons = highlander.forceHighlander(this.project);

assert.equal(nonLatestTestWaiterAddons.length, 3);

nonLatestTestWaiterAddons.forEach((addon) => {
assert.notEqual(addon.treeFor, STABLE_FUNCTION_REF);
assert.notEqual(addon.cacheKeyForTree, STABLE_FUNCTION_REF);

addon.treeFor();
addon.cacheKeyForTree();
});

assert.verifySteps(
['latest `treeFor` called', 'latest `treeFor` called', 'latest `treeFor` called'],
'the latest version treeFor, cacheKeyForTree is called for all non-latest addons'
);
});

test('forceHighlander returns stable cache keys for each addon (`@ember/test-waiters` and `ember-test-waiters`)', function (assert) {
const AddonCtor = Addon.extend({
...addonIndex,
root: path.resolve(__dirname, '..'),
// eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects
pkg: { ...require('../package.json'), version: '5.0.5' },
});

const expectedLatest = new AddonCtor(this.project, this.project);
this.project.addons.push(expectedLatest);

let checker = VersionChecker.forProject(this.project);
let addons = [
...checker.filterAddonsByName('ember-test-waiters'),
...checker.filterAddonsByName('@ember/test-waiters'),
];

let latestVersion = highlander.findLatestVersion(addons);

assert.strictEqual(latestVersion, expectedLatest);
assert.ok(latestVersion.cacheKeyForTree().endsWith('@ember/test-waiters'));

let nonLatestTestWaiterAddons = highlander.forceHighlander(this.project);

assert.equal(nonLatestTestWaiterAddons.length, 4);

nonLatestTestWaiterAddons.forEach((addon) => {
assert.ok(addon.cacheKeyForTree().endsWith(moduleName));

assert.strictEqual(
latestVersion.cacheKeyForTree().replace('@ember/test-waiters', moduleName),
addon.cacheKeyForTree()
);
});
});
});
});
Loading

0 comments on commit cab0a91

Please sign in to comment.