Skip to content

Commit 64120ab

Browse files
lobsterkatieonurtemizkan
authored andcommitted
fix(ember): Restore local and PR tests (#4205)
Given that ember tests take longer to run than most other tests (and have been known to fail for reasons having nothing to do with whatever PR we're working on), in #3571 we stopped running them locally and on PRs*, instead only running them when merging to `master` or releasing. *Provided the PR didn't touch any of the `@sentry/ember` code As a result, we didn't catch a currently-failing ember test until later than we would have liked. To prevent that from happening again, this restores the running of ember tests (both locally and on PRs), but restricts which tests run in each circumstance, in order to prevent this change from slowing down the overall repo test suite more than necessary. Specifically: - Locally, we run tests only against the current version of ember. - In the context of a PR, we run tests against the current version, the LTS version, and a version using `embroider` (which is an optional ember compiler many people use). - When merging to `master` or creating a release, for greatest safety, we test against current, LTS, embroider, beta, and "classic" (a legacy ember version). Key changes: - Up until now, the logic controlling which set of ember tests to run has been split between a script (`run_tests.js`, which differentiated local runs from CI runs), and the GHA workflow config (`build.yml`, which differentiated PRs from merges into master and creation of releases). That work is now consolidated into the ember-try config (since ember-try is the runner which needs to know which tests to run in the first place!). - As a result of the above change, the method for forcing tests for all versions of ember to run needed to be modified. That option is now handled by a new script, `run-CI-tests.js`, which simply mimics the the third situation above by setting environment variables, thereby tricking ember-try into thinking it needs to run all tests.
1 parent 5e87b99 commit 64120ab

File tree

5 files changed

+57
-39
lines changed

5 files changed

+57
-39
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,9 @@ jobs:
231231
with:
232232
path: ${{ env.CACHED_BUILD_PATHS }}
233233
key: ${{ env.BUILD_CACHE_KEY }}
234-
- name: Check changed files
235-
id: changed-files-specific
236-
uses: tj-actions/[email protected]
237-
with:
238-
files: .*packages\/ember($|/.*)
239-
# Only run ember tests if the files above have changed
240234
- name: Run Ember tests
241-
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push'
242235
run: yarn test --scope=@sentry/ember
243236
- name: Compute test coverage
244-
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push'
245237
uses: codecov/codecov-action@v1
246238

247239
job_artifacts:

packages/ember/config/ember-try.js

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,47 @@
33
const getChannelURL = require('ember-source-channel-url');
44
const { embroiderSafe } = require('@embroider/test-setup');
55

6+
/**
7+
* Pick which versions of ember against which to test based on whether the tests are running locally, as part of a PR,
8+
* or when merging to `master` or creating a release.
9+
*
10+
* @returns The versions which should be tested, along with their respective config
11+
*/
612
module.exports = async function() {
7-
return {
8-
useYarn: true,
9-
scenarios: [
10-
{
11-
name: 'ember-lts-3.20',
12-
npm: {
13-
devDependencies: {
14-
'ember-source': '~3.20.0',
15-
},
13+
// whenever and wherever we test, we want to at least test against the latest version of ember
14+
let scenarios = [
15+
{
16+
name: 'ember-release',
17+
npm: {
18+
devDependencies: {
19+
'ember-source': await getChannelURL('release'),
1620
},
1721
},
22+
},
23+
];
24+
25+
// in CI we add a few more tests - LTS and embroider (which is an ember compiler)
26+
if (process.env.GITHUB_ACTIONS) {
27+
scenarios = scenarios.concat([
1828
{
19-
name: 'ember-release',
29+
name: 'ember-lts-3.20',
2030
npm: {
2131
devDependencies: {
22-
'ember-source': await getChannelURL('release'),
32+
'ember-source': '~3.24.0',
2333
},
2434
},
2535
},
36+
embroiderSafe(),
37+
]);
38+
}
39+
40+
// finally, just to be extra thorough when merging to master and releasing, we add the beta channel and ember
41+
// "classic" (a legacy version which was last current in late 2019)
42+
if (
43+
process.env.GITHUB_EVENT_NAME === 'push' &&
44+
(process.env.GITHUB_HEAD_REF === 'master' || process.env.GITHUB_HEAD_REF.startsWith('release'))
45+
) {
46+
scenarios = scenarios.concat([
2647
{
2748
name: 'ember-beta',
2849
npm: {
@@ -32,7 +53,6 @@ module.exports = async function() {
3253
},
3354
allowedToFail: true,
3455
},
35-
embroiderSafe(),
3656
{
3757
name: 'ember-classic',
3858
env: {
@@ -48,6 +68,11 @@ module.exports = async function() {
4868
},
4969
},
5070
},
51-
],
71+
]);
72+
}
73+
74+
return {
75+
useYarn: true,
76+
scenarios,
5277
};
5378
};

packages/ember/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
"prepublishOnly": "ember ts:precompile",
2727
"postpublish": "ember ts:clean",
2828
"start": "ember serve",
29-
"test": "node ./scripts/run_tests.js",
30-
"test:ember": "ember test",
31-
"test:ember-compatibility": "ember try:each"
29+
"test": "ember try:each",
30+
"test:all": "node ./scripts/run-CI-tests.js"
3231
},
3332
"dependencies": {
3433
"@embroider/macros": "~0.47.2",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*eslint-env node*/
2+
const { spawnSync } = require('child_process');
3+
4+
console.log('Mimicking the CI environment in order to run tests against multiple versions of Ember');
5+
6+
const result = spawnSync('yarn test', {
7+
shell: true,
8+
stdio: 'inherit',
9+
env: {
10+
...process.env,
11+
GITHUB_ACTIONS: true,
12+
GITHUB_EVENT_NAME: 'push',
13+
GITHUB_HEAD_REF: 'master',
14+
},
15+
});
16+
17+
process.exit(result.status);

packages/ember/scripts/run_tests.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)