Skip to content

Commit

Permalink
fix(ember): Restore local and PR tests (#4205)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lobsterkatie authored and onurtemizkan committed Dec 19, 2021
1 parent 5e87b99 commit 64120ab
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 39 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,9 @@ jobs:
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Check changed files
id: changed-files-specific
uses: tj-actions/changed-files@v6.2
with:
files: .*packages\/ember($|/.*)
# Only run ember tests if the files above have changed
- name: Run Ember tests
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push'
run: yarn test --scope=@sentry/ember
- name: Compute test coverage
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push'
uses: codecov/codecov-action@v1

job_artifacts:
Expand Down
51 changes: 38 additions & 13 deletions packages/ember/config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,47 @@
const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe } = require('@embroider/test-setup');

/**
* Pick which versions of ember against which to test based on whether the tests are running locally, as part of a PR,
* or when merging to `master` or creating a release.
*
* @returns The versions which should be tested, along with their respective config
*/
module.exports = async function() {
return {
useYarn: true,
scenarios: [
{
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': '~3.20.0',
},
// whenever and wherever we test, we want to at least test against the latest version of ember
let scenarios = [
{
name: 'ember-release',
npm: {
devDependencies: {
'ember-source': await getChannelURL('release'),
},
},
},
];

// in CI we add a few more tests - LTS and embroider (which is an ember compiler)
if (process.env.GITHUB_ACTIONS) {
scenarios = scenarios.concat([
{
name: 'ember-release',
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': await getChannelURL('release'),
'ember-source': '~3.24.0',
},
},
},
embroiderSafe(),
]);
}

// finally, just to be extra thorough when merging to master and releasing, we add the beta channel and ember
// "classic" (a legacy version which was last current in late 2019)
if (
process.env.GITHUB_EVENT_NAME === 'push' &&
(process.env.GITHUB_HEAD_REF === 'master' || process.env.GITHUB_HEAD_REF.startsWith('release'))
) {
scenarios = scenarios.concat([
{
name: 'ember-beta',
npm: {
Expand All @@ -32,7 +53,6 @@ module.exports = async function() {
},
allowedToFail: true,
},
embroiderSafe(),
{
name: 'ember-classic',
env: {
Expand All @@ -48,6 +68,11 @@ module.exports = async function() {
},
},
},
],
]);
}

return {
useYarn: true,
scenarios,
};
};
5 changes: 2 additions & 3 deletions packages/ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
"prepublishOnly": "ember ts:precompile",
"postpublish": "ember ts:clean",
"start": "ember serve",
"test": "node ./scripts/run_tests.js",
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each"
"test": "ember try:each",
"test:all": "node ./scripts/run-CI-tests.js"
},
"dependencies": {
"@embroider/macros": "~0.47.2",
Expand Down
17 changes: 17 additions & 0 deletions packages/ember/scripts/run-CI-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*eslint-env node*/
const { spawnSync } = require('child_process');

console.log('Mimicking the CI environment in order to run tests against multiple versions of Ember');

const result = spawnSync('yarn test', {
shell: true,
stdio: 'inherit',
env: {
...process.env,
GITHUB_ACTIONS: true,
GITHUB_EVENT_NAME: 'push',
GITHUB_HEAD_REF: 'master',
},
});

process.exit(result.status);
15 changes: 0 additions & 15 deletions packages/ember/scripts/run_tests.js

This file was deleted.

0 comments on commit 64120ab

Please sign in to comment.