Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] Cron job to check for external deprecations #6844

Merged
merged 8 commits into from
Dec 5, 2019
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
54 changes: 54 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Nightly'

on:
schedule:
- cron: '* 14 * * *' # 14:00 in UTC is 6am PST
branches:
- master

jobs:
test-all-deprecations:
strategy:
fail-fast: false
matrix:
scenario: [ember-beta, ember-canary]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies for master
run: yarn install
- name: Basic Tests
env:
CI: true
ASSERT_ALL_DEPRECATIONS: true
run: yarn test
Copy link
Contributor

Choose a reason for hiding this comment

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

we should run

  • basic tests
  • fastboot tests
  • fetch tests
  • encapsulation tests
  • canary/beta Ember tests

Copy link
Contributor

Choose a reason for hiding this comment

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

In a future PR we should also consider how to monitor for deprecations in the relationship-performance-test-app, but that can be ignored for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't set up fastboot tests and they aren't working right now, so not adding them currently. What are the fetch tests?
Added the others.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Gaurav0 can you clarify what you mean by:

I didn't set up fastboot tests and they aren't working right now

I am happy to merge this and add fastboot and fetch tests in follow up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I reverted updating test-helper.js in fastboot-test-app to assert on deprecations. I think the code I wrote with the custom QUnitAdapter for testem doesn't work in fastboot, that may be why it fails.

- name: Encapsulation tests
env:
CI: true
ASSERT_ALL_DEPRECATIONS: true
run: yarn test:encapsulation

test-all-deprecations-releases:
strategy:
fail-fast: false
matrix:
scenario: [ember-beta, ember-canary]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies for master
run: yarn install
- name: Basic Tests
env:
CI: true
ASSERT_ALL_DEPRECATIONS: true
run: yarn test:try-one ${{ matrix.scenario }}

4 changes: 3 additions & 1 deletion packages/-ember-data/testem.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const customDotReporter = require('@ember-data/unpublished-test-infra/src/testem/custom-dot-reporter');

const TestIE = process.env.TEST_IE11;

if (TestIE) {
Expand All @@ -7,7 +9,7 @@ if (TestIE) {
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
reporter: 'dot',
reporter: customDotReporter,
launch_in_ci: TestIE ? ['IE'] : ['Chrome'],
launch_in_dev: ['Chrome'],
browser_start_timeout: 120,
Expand Down
65 changes: 9 additions & 56 deletions packages/-ember-data/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,29 @@ import config from '../config/environment';
import RSVP from 'rsvp';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import { DEBUG } from '@glimmer/env';

import QUnit from 'qunit';
import { wait, asyncEqual, invokeAsync } from '@ember-data/unpublished-test-infra/test-support/async';
import configureAsserts from '@ember-data/unpublished-test-infra/test-support/qunit-asserts';
import additionalLegacyAsserts from '@ember-data/unpublished-test-infra/test-support/legacy';
import assertAllDeprecations from '@ember-data/unpublished-test-infra/test-support/assert-all-deprecations';
import customQUnitAdapter from '@ember-data/unpublished-test-infra/test-support/testem/custom-qunit-adapter';

if (window.Promise === undefined) {
window.Promise = RSVP.Promise;
}

configureAsserts();
additionalLegacyAsserts();

setApplication(Application.create(config.APP));

const { assert } = QUnit;
assertAllDeprecations();

QUnit.begin(() => {
function assertAllDeprecations(assert) {
if (typeof assert.test.expected === 'number') {
assert.test.expected += 1;
}
assert.expectNoDeprecation(undefined, undefined, deprecation => {
// only assert EmberData deprecations
const id = deprecation.options.id.toLowerCase();
const isEmberDataDeprecation =
id.includes('ds.') ||
id.includes('emberdata') ||
id.includes('ember-data') ||
id.includes('mismatched-inverse-relationship-data-from-payload');

if (!isEmberDataDeprecation) {
// eslint-disable-next-line no-console
console.warn('Detected Non-Ember-Data Deprecation:', deprecation.message, deprecation.options.stacktrace);
}

return isEmberDataDeprecation;
});
}
// ensure we don't regress quietly
// this plays nicely with `expectDeprecation`
if (DEBUG) {
QUnit.config.modules.forEach(mod => {
const hooks = (mod.hooks.afterEach = mod.hooks.afterEach || []);

if (mod.tests.length !== 0) {
hooks.unshift(assertAllDeprecations);
}
});
}
if (window.Testem) {
window.Testem.useCustomAdapter(customQUnitAdapter);
}

QUnit.begin(function() {
RSVP.configure('onerror', reason => {
// only print error messages if they're exceptions;
// otherwise, let a future turn of the event loop
Expand All @@ -64,26 +37,6 @@ QUnit.begin(() => {
});
});

assert.wait = wait;
assert.asyncEqual = asyncEqual;
assert.invokeAsync = invokeAsync;
assert.assertClean = function(promise) {
return promise.then(
this.wait(record => {
this.equal(record.get('hasDirtyAttributes'), false, 'The record is now clean');
return record;
})
);
};

assert.contains = function(array, item) {
this.ok(array.indexOf(item) !== -1, `array contains ${item}`);
};

assert.without = function(array, item) {
this.ok(array.indexOf(item) === -1, `array doesn't contain ${item}`);
};

QUnit.config.testTimeout = 2000;
QUnit.config.urlConfig.push({
id: 'enableoptionalfeatures',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import configureAsserts from '@ember-data/unpublished-test-infra/test-support/qunit-asserts';
import assertAllDeprecations from '@ember-data/unpublished-test-infra/test-support/assert-all-deprecations';

configureAsserts();

setApplication(Application.create(config.APP));

assertAllDeprecations();

start();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import configureAsserts from '@ember-data/unpublished-test-infra/test-support/qunit-asserts';
import assertAllDeprecations from '@ember-data/unpublished-test-infra/test-support/assert-all-deprecations';

configureAsserts();

setApplication(Application.create(config.APP));

assertAllDeprecations();

start();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import configureAsserts from '@ember-data/unpublished-test-infra/test-support/qunit-asserts';
import assertAllDeprecations from '@ember-data/unpublished-test-infra/test-support/assert-all-deprecations';

configureAsserts();

setApplication(Application.create(config.APP));

assertAllDeprecations();

start();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import configureAsserts from '@ember-data/unpublished-test-infra/test-support/qunit-asserts';
import assertAllDeprecations from '@ember-data/unpublished-test-infra/test-support/assert-all-deprecations';

configureAsserts();

setApplication(Application.create(config.APP));

assertAllDeprecations();

start();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import configureAsserts from '@ember-data/unpublished-test-infra/test-support/qunit-asserts';
import assertAllDeprecations from '@ember-data/unpublished-test-infra/test-support/assert-all-deprecations';

configureAsserts();

setApplication(Application.create(config.APP));

assertAllDeprecations();

start();
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable no-console */
import { DEBUG } from '@glimmer/env';
import QUnit from 'qunit';
import config from 'ember-get-config';

const { ASSERT_ALL_DEPRECATIONS } = config;

const ALL_ASSERTED_DEPRECATIONS = {};

function pushDeprecation(deprecation) {
if (deprecation in ALL_ASSERTED_DEPRECATIONS) {
ALL_ASSERTED_DEPRECATIONS[deprecation]++;
} else {
ALL_ASSERTED_DEPRECATIONS[deprecation] = 1;
}
}

export default function configureAssertAllDeprecations() {
QUnit.begin(() => {
function assertAllDeprecations(assert) {
if (typeof assert.test.expected === 'number') {
assert.test.expected += 1;
}
assert.expectNoDeprecation(undefined, undefined, deprecation => {
// only assert EmberData deprecations
const id = deprecation.options.id.toLowerCase();
const isEmberDataDeprecation =
id.includes('ds.') ||
id.includes('emberdata') ||
id.includes('ember-data') ||
id.includes('mismatched-inverse-relationship-data-from-payload');

if (!isEmberDataDeprecation) {
if (ASSERT_ALL_DEPRECATIONS) {
pushDeprecation((deprecation.options && deprecation.options.id) || deprecation);
} else {
console.warn('Detected Non-Ember-Data Deprecation:', deprecation.message, deprecation.options.stacktrace);
}
}

return ASSERT_ALL_DEPRECATIONS ? true : isEmberDataDeprecation;
});
}
// ensure we don't regress quietly
// this plays nicely with `expectDeprecation`
if (DEBUG) {
QUnit.config.modules.forEach(mod => {
const hooks = (mod.hooks.afterEach = mod.hooks.afterEach || []);

if (mod.tests.length !== 0) {
hooks.unshift(assertAllDeprecations);
}
});
}
});

QUnit.done(function() {
if (ASSERT_ALL_DEPRECATIONS) {
QUnit.config.deprecations = ALL_ASSERTED_DEPRECATIONS;
}
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { all, resolve } from 'rsvp';
import { run } from '@ember/runloop';

// Should not use these going forward, use async/await instead.
export function wait(callback, timeout) {
let done = this.async();

Expand Down
27 changes: 27 additions & 0 deletions packages/unpublished-test-infra/addon-test-support/legacy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { wait, asyncEqual, invokeAsync } from './async';
import QUnit from 'qunit';

const { assert } = QUnit;

export default function additionalLegacyAsserts() {
assert.wait = wait;
assert.asyncEqual = asyncEqual;
assert.invokeAsync = invokeAsync;

assert.assertClean = function(promise) {
return promise.then(
this.wait(record => {
this.equal(record.get('hasDirtyAttributes'), false, 'The record is now clean');
return record;
})
);
};

assert.contains = function(array, item) {
this.ok(array.indexOf(item) !== -1, `array contains ${item}`);
};

assert.without = function(array, item) {
this.ok(array.indexOf(item) === -1, `array doesn't contain ${item}`);
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import QUnit from 'qunit';

export default function customQUnitAdapter(socket) {
QUnit.done(function() {
let deprecations = QUnit.config.deprecations;
console.log(deprecations); // eslint-disable-line no-console

socket.emit('test-metadata', 'deprecations', deprecations);
});
}
4 changes: 3 additions & 1 deletion packages/unpublished-test-infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
"ember-cli-babel": "^7.12.0",
"ember-cli-blueprint-test-helpers": "^0.19.1",
"ember-cli-typescript": "^3.1.1",
"ember-get-config": "^0.2.4",
"ember-qunit": "^4.6.0",
"qunit": "^2.9.3",
"rsvp": "^4.8.5"
"rsvp": "^4.8.5",
"testem": "^2.17.0"
},
"engines": {
"node": ">= 8.0.0"
Expand Down
21 changes: 21 additions & 0 deletions packages/unpublished-test-infra/src/testem/custom-dot-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let DotReporter = require('testem/lib/reporters/dot_reporter');

class CustomDotReporter extends DotReporter {
finish() {
super.finish();

if (process.env.ASSERT_ALL_DEPRECATIONS === 'true') {
this.out.write('\n============ Deprecations ============\n');
this.out.write(JSON.stringify(this.deprecations, null, 2) + '\n');
this.out.write('======================================\n');
}
}

reportMetadata(tag, metadata) {
if (tag === 'deprecations') {
this.deprecations = metadata;
}
}
}

module.exports = CustomDotReporter;
Loading