Skip to content

Commit

Permalink
Merge pull request #9093 from ember-cli/update-support-detection
Browse files Browse the repository at this point in the history
Migrate supported Node version detection to use GitHub Actions config.
  • Loading branch information
rwjblue committed Mar 14, 2020
2 parents 4335303 + d93e4ee commit ea51896
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
8 changes: 7 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
/tmp/
/.*
*.log
!/.travis.yml
/yarn.lock
!docs/build/data.json

# the GitHub Action CI configuration is used by
# lib/utilities/platform-checker.js to determine what versions of Node are
# under test by the current version of ember-cli being used, this means we
# **must** publish this file (but it would be ignored by the `/.*` line just
# above)
!/.github/workflows/ci.yml
2 changes: 0 additions & 2 deletions docs/node-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Node.js](https://github.com/nodejs/LTS#lts_schedule).

## Current support:

* v8: Released as stable version then converted to LTS.
* Supported by ember-cli/ember-cli#master until: 2019-12-31.
* v10: Released as stable version then converted to LTS.
* Supported by ember-cli/ember-cli#master until: 2021-04-30.
* v12: Released as stable version then converted to LTS.
Expand Down
28 changes: 15 additions & 13 deletions lib/utilities/platform-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ const semver = require('semver');
const logger = require('heimdalljs-logger')('ember-cli:platform-checker:');
const loadConfig = require('./load-config');

let testedEngines;
if (process.platform === 'win32') {
testedEngines = loadConfig('appveyor.yml')
.environment.matrix.map(element => element.nodejs_version)
.join(' || ');
} else {
let travisConfig = loadConfig('.travis.yml');
let nodeVersions = new Set(travisConfig.node_js);

travisConfig.jobs.include.forEach(job => {
if (job.node_js) {
nodeVersions.add(job.node_js);
const ci = loadConfig('.github/workflows/ci.yml');
const nodeVersions = new Set();

for (let jobName in ci.jobs) {
let job = ci.jobs[jobName];

job.steps.forEach(step => {
let isSetupNode = step.uses === 'actions/setup-node@v1';
if (isSetupNode && step.with['node-version'].includes('${{') === false) {
nodeVersions.add(step.with['node-version']);
}
});

testedEngines = Array.from(nodeVersions).join(' || ');
if (job.strategy && job.strategy.matrix && job.strategy.matrix['node-version']) {
job.strategy.matrix['node-version'].forEach(version => nodeVersions.add(version));
}
}

const testedEngines = Array.from(nodeVersions).join(' || ');

let supportedEngines = loadConfig('package.json').engines.node;

module.exports = class PlatformChecker {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utilities/load-config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ describe('publishes the appropriate config files', function() {
let npmignore = loadConfig('.npmignore', EmberCLIDir);

it('has the config files', function() {
expect(npmignore).to.include('!/.travis.yml');
expect(npmignore).to.include('!/.github/workflows/ci.yml');
});
});
17 changes: 17 additions & 0 deletions tests/unit/utilities/platform-checker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ const expect = require('chai').expect;
const PlatformChecker = require('../../../lib/utilities/platform-checker');

describe('platform-checker', function() {
describe('known versions', function() {
function check(version, { isTested, isDeprecated, isValid }) {
it(`${version}`, function() {
let checker = new PlatformChecker(version);
expect(checker.isDeprecated).to.equal(isDeprecated);
expect(checker.isValid).to.equal(isValid);
expect(checker.isTested).to.equal(isTested);
});
}

check('v8.0.0', { isTested: false, isDeprecated: true, isValid: false });
check('v10.0.0', { isTested: true, isDeprecated: false, isValid: true });
check('v12.0.0', { isTested: true, isDeprecated: false, isValid: true });
check('v13.0.0', { isTested: true, isDeprecated: false, isValid: true });
check('v14.0.0', { isTested: false, isDeprecated: false, isValid: true });
});

it('checkIsDeprecated', function() {
expect(new PlatformChecker('v0.10.1').checkIsDeprecated('4 || 6')).to.be.equal(
true,
Expand Down

0 comments on commit ea51896

Please sign in to comment.