Skip to content
Permalink
Browse files

feat(release-check): add release-check on plugin projects

  • Loading branch information...
huochunpeng committed Mar 24, 2019
1 parent 245ce7e commit 05c5980a7217748596aafcb662e0de314c96fb7d
Showing with 131 additions and 63 deletions.
  1. +3 −1 RELEASE_INSTRUCTIONS.md
  2. +5 −0 build/tasks/release-checks/step.js
  3. +15 −9 build/tasks/release-checks/suite-steps.js
  4. +9 −2 build/tasks/release-checks/test-projects-selector.js
  5. +4 −4 build/tasks/release-checks/tests/generic/au-cypress.js
  6. +26 −16 build/tasks/release-checks/tests/generic/au-generate.js
  7. +1 −1 build/tasks/release-checks/tests/generic/au-jest.js
  8. +1 −1 build/tasks/release-checks/tests/generic/au-karma.js
  9. +1 −1 build/tasks/release-checks/tests/generic/au-lint.js
  10. +4 −4 build/tasks/release-checks/tests/generic/au-protractor.js
  11. +4 −4 build/tasks/release-checks/tests/generic/dotnet-run.js
  12. +2 −1 build/tasks/release-checks/tests/index.js
  13. +33 −0 build/tasks/release-checks/tests/plugin/au-build-plugin.js
  14. +3 −0 build/tasks/release-checks/tests/plugin/index.js
  15. +3 −3 build/tasks/release-checks/tests/requirejs/au-build.js
  16. +6 −6 build/tasks/release-checks/tests/requirejs/au-run.js
  17. +6 −6 build/tasks/release-checks/tests/webpack/au-run.js
  18. +1 −1 skeleton/cli-bundler/aurelia_project/tasks__if_babel/lint.js
  19. +1 −1 skeleton/cli-bundler/aurelia_project/tasks__if_typescript/lint.ts
  20. 0 skeleton/common/aurelia_project/generators/{component.ext → component.ext__if_not_plugin}
  21. 0 skeleton/common/aurelia_project/generators/{component.json → component.json__if_not_plugin}
  22. +1 −0 skeleton/plugin/aurelia_project/tasks/build-plugin.ext
  23. +2 −2 skeleton/protractor/aurelia_project/tasks/protractor.ext
@@ -4,7 +4,9 @@ This is an automated testing tool for projects that were generated by the Aureli
1. open the terminal, go into an empty directory and run `au generate-skeletons`
2. from the CLI repository folder, run `gulp release-check --path C:/Development/Aurelia/TestApps --latest-cli-url aurelia/cli#master`, substituting the path with the correct one.
* Note, on Windows, run PowerShell with "run as administrator".
3. Select for which projects you would like to run the tests
3. Select for which projects you would like to run the tests.
* To test all projects automatically, add `--all` to previous command.
* To test subset projects automatically, add `--select requirejs,babel` (only tests projects using requirejs and babel) to previous command.
4. Wait until tests complete
5. in the CLI repository folder there is now a release-checks-results folder containing the output and other artifacts, such as screenshots. Check these screenshots to make sure that pages have rendered correctly

@@ -1,4 +1,5 @@
const LogManager = require('aurelia-logging');
const _ = require('lodash');

module.exports = class Step {
constructor(title) {
@@ -13,4 +14,8 @@ module.exports = class Step {
getTitle() {
throw new Error('not implemented');
}

debug(message) {
this.logger.debug(_.trimEnd(message));
}
};
@@ -1,24 +1,30 @@
const path = require('path');
const tasks = require('./tasks/index');
const tests = require('./tests/index');
const applicable = require('../../../lib/workflow/applicable');

module.exports = function(suite) {
const features = suite.split('_');
const ext = applicable(features, 'typescript') ? '.ts' : '.js';
const plugin = applicable(features, 'plugin');

const steps = [
new tasks.ChangeDirectory(),
new tasks.InstallNodeModules(),
new tasks.InstallLatestAureliaCLI(),
new tests.generic.AuGenerateAttributeTests(ext),
new tests.generic.AuGenerateComponentTests(ext),
new tests.generic.AuGenerateElementTests(ext),
new tests.generic.AuGenerateValueConverterTests(ext),
new tests.generic.AuGenerateBindingBehaviorTests(ext),
new tests.generic.AuGenerateTaskTests(ext),
new tests.generic.AuGenerateGeneratorTests(ext)
new tests.generic.AuGenerateAttributeTests(ext, plugin),
new tests.generic.AuGenerateElementTests(ext, plugin),
new tests.generic.AuGenerateValueConverterTests(ext, plugin),
new tests.generic.AuGenerateBindingBehaviorTests(ext, plugin),
new tests.generic.AuGenerateTaskTests(ext, plugin),
new tests.generic.AuGenerateGeneratorTests(ext, plugin)
];

if (!plugin) {
steps.push(new tests.generic.AuGenerateComponentTests(ext));
} else {
steps.push(new tests.plugin.AuBuildPluginDoesNotThrowCommandLineErrors());
}

if (applicable(features, 'jest')) {
steps.push(
@@ -47,10 +53,10 @@ module.exports = function(suite) {
if (applicable(features, 'cli-bundler')) {
steps.push(
new tests.requirejs.AuBuildDoesNotThrowCommandLineErrors(),
new tests.requirejs.AuBuildWatchPicksUpFileChanges(),
new tests.requirejs.AuBuildWatchPicksUpFileChanges(plugin ? path.join('dev-app', 'app.html') : undefined),
new tests.requirejs.AuRunDoesNotThrowCommandLineErrors(),
new tests.requirejs.AuRunLaunchesServer(),
new tests.requirejs.AuRunWatchPicksUpFileChanges(),
new tests.requirejs.AuRunWatchPicksUpFileChanges(plugin ? path.join('dev-app', 'app.html') : undefined),
new tests.requirejs.AuRunAppLaunchesWithoutJavascriptErrors(),
new tests.requirejs.AuRunRendersPage(),
new tests.generic.AuLintFinishes()
@@ -2,6 +2,7 @@ const CLIOptions = require('../../../lib/cli-options').CLIOptions;
const cliOptions = new CLIOptions();
const fs = require('../../../lib/file-system');
const path = require('path');
const _ = require('lodash');

let userArgs = process.argv.slice(2);
Object.assign(cliOptions, {
@@ -37,7 +38,14 @@ module.exports = class TestProjectsSelector {
let dirs = await this.getSubDirs(dir);

if (dirs.length === 0) throw new Error('No subdirectory to test.');
if (!CLIOptions.hasFlag('all')) {

if (cliOptions.hasFlag('select')) {
const selectedFeatures = cliOptions.getFlagValue('select').split(',');
dirs = dirs.filter(d => {
const features = d.split('_');
return _.every(selectedFeatures, f => _.includes(features, f));
});
} else if (!cliOptions.hasFlag('all')) {
dirs = await this.choose(dirs);
}

@@ -49,7 +57,6 @@ module.exports = class TestProjectsSelector {
options.unshift({displayName: 'All'});

const answers = await ui.multiselect('Found test dirs.\r\nWhich would you like to run?', options);
console.log('answers', answers);
return answers.includes('All') ? dirs : answers;
}
};
@@ -7,7 +7,7 @@ class AuCypressRunsTests extends Test {
}

onCypressOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isCypressCompletedMessage(message)) {
this.success();
@@ -21,7 +21,7 @@ class AuCypressRunsTests extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isApplicationAvailableMessage(message)) {
this.cypressCommand = new ExecuteCommand('au', ['cypress', '--run'], (msg) => this.onCypressOutput(msg), (msg) => this.onCypressOutput(msg));
@@ -41,7 +41,7 @@ class AuCypressRunsTestsDotNet extends Test {
}

onCypressOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isCypressCompletedMessage(message)) {
this.success();
@@ -55,7 +55,7 @@ class AuCypressRunsTestsDotNet extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (message.indexOf('Now listening on: http://localhost:') > -1) {
this.cypressCommand = new ExecuteCommand('au', ['cypress'], (msg) => this.onCypressOutput(msg), (msg) => this.onCypressOutput(msg));
@@ -5,15 +5,16 @@ const path = require('path');
const _ = require('lodash');

class AuGenerateTests extends Test {
constructor(objectType, ext) {
constructor(objectType, ext, plugin) {
super(`au generate ${objectType}, writes ${objectType} file`);
this.objectType = objectType;
this.plugin = plugin;
this.ext = ext;
this.onFinish = this.onFinish.bind(this);
}

onFinish(message) {
this.logger.debug(message);
this.debug(message);

if (_.every(this.createdFiles(), fs.isFile)) {
this.success();
@@ -28,13 +29,22 @@ class AuGenerateTests extends Test {
path.join('src', `new-thing${this.ext}`)
];
} else if (this.objectType === 'element') {
if (this.plugin) {
return [
path.join('src', 'elements', 'new-thing.html'),
path.join('src', 'elements', `new-thing${this.ext}`)
];
}
return [
path.join('src', 'resources', 'elements', 'new-thing.html'),
path.join('src', 'resources', 'elements', `new-thing${this.ext}`)
];
} else if (this.objectType === 'task' || this.objectType === 'generator') {
return [path.join('aurelia_project', this.objectType + 's', `new-thing${this.ext}`)];
}
if (this.plugin) {
return [path.join('src', this.objectType + 's', `new-thing${this.ext}`)];
}
return [path.join('src', 'resources', this.objectType + 's', `new-thing${this.ext}`)];
}

@@ -56,44 +66,44 @@ class AuGenerateTests extends Test {
}

class AuGenerateAttributeTests extends AuGenerateTests {
constructor(ext) {
super('attribute', ext);
constructor(ext, plugin) {
super('attribute', ext, plugin);
}
}

class AuGenerateComponentTests extends AuGenerateTests {
constructor(ext) {
super('component', ext);
constructor(ext, plugin) {
super('component', ext, plugin);
}
}

class AuGenerateElementTests extends AuGenerateTests {
constructor(ext) {
super('element', ext);
constructor(ext, plugin) {
super('element', ext, plugin);
}
}

class AuGenerateValueConverterTests extends AuGenerateTests {
constructor(ext) {
super('value-converter', ext);
constructor(ext, plugin) {
super('value-converter', ext, plugin);
}
}

class AuGenerateBindingBehaviorTests extends AuGenerateTests {
constructor(ext) {
super('binding-behavior', ext);
constructor(ext, plugin) {
super('binding-behavior', ext, plugin);
}
}

class AuGenerateTaskTests extends AuGenerateTests {
constructor(ext) {
super('task', ext);
constructor(ext, plugin) {
super('task', ext, plugin);
}
}

class AuGenerateGeneratorTests extends AuGenerateTests {
constructor(ext) {
super('generator', ext);
constructor(ext, plugin) {
super('generator', ext, plugin);
}
}

@@ -7,7 +7,7 @@ class AuJestRunsTests extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isTestFinishedMessage(message)) {
this.success();
@@ -7,7 +7,7 @@ class AuKarmaRunsTests extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isTestFinishedMessage(message)) {
this.success();
@@ -7,7 +7,7 @@ class AuLintFinishes extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isTestFinishedMessage(message)) {
this.success();
@@ -7,7 +7,7 @@ class AuProtractorRunsTests extends Test {
}

onProtractorOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isProtractorCompletedMessage(message)) {
this.success();
@@ -17,7 +17,7 @@ class AuProtractorRunsTests extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isApplicationAvailableMessage(message)) {
this.protractorCommand = new ExecuteCommand('au', ['protractor'], (msg) => this.onProtractorOutput(msg));
@@ -38,7 +38,7 @@ class AuProtractorRunsTestsDotNet extends Test {
}

onProtractorOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isProtractorCompletedMessage(message)) {
this.success();
@@ -48,7 +48,7 @@ class AuProtractorRunsTestsDotNet extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (message.indexOf('Now listening on: http://localhost:') > -1) {
this.protractorCommand = new ExecuteCommand('au', ['protractor'], (msg) => this.onProtractorOutput(msg));
@@ -11,7 +11,7 @@ class DotNetRunDoesNotThrowCommandLineErrors extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (message.toLowerCase().indexOf('error') > -1) {
this.executeCommand.stop();
@@ -34,7 +34,7 @@ class DotNetRunLaunchesServer extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isApplicationAvailableMessage(message)) {
this.success();
@@ -54,7 +54,7 @@ class DotnetRunRendersPage extends Test {
}

onOutput(context, message) {
this.logger.debug(message);
this.debug(message);

if (isApplicationAvailableMessage(message)) {
const url = getURL(message);
@@ -81,7 +81,7 @@ class DotNetRunAppLaunchesWithoutJavascriptErrors extends Test {
}

onOutput(message) {
this.logger.debug(message);
this.debug(message);

if (isApplicationAvailableMessage(message)) {
const url = getURL(message);
@@ -1,5 +1,6 @@
module.exports = {
generic: require('./generic'),
requirejs: require('./requirejs'),
webpack: require('./webpack')
webpack: require('./webpack'),
plugin: require('./plugin')
};
@@ -0,0 +1,33 @@
const Test = require('../test');
const ExecuteCommand = require('../../tasks/execute-command');

class AuBuildPluginDoesNotThrowCommandLineErrors extends Test {
constructor() {
super('au build-plugin does not throw commandline errors');
}

onOutput(message) {
this.debug(message);

if (message.toLowerCase().indexOf('error') > -1) {
this.executeCommand.stop();
this.fail();
} else if (isBuildCompletedMessage(message)) {
this.success();
this.executeCommand.stop();
}
}

execute() {
this.executeCommand = new ExecuteCommand('au', ['build-plugin', '--watch'], (msg) => this.onOutput(msg));
return this.executeCommand.executeAsNodeScript();
}
}

function isBuildCompletedMessage(msg) {
return msg.indexOf('Finish building Aurelia plugin') > -1;
}

module.exports = {
AuBuildPluginDoesNotThrowCommandLineErrors
};
@@ -0,0 +1,3 @@
module.exports = {
...require('./au-build-plugin')
};
Oops, something went wrong.

0 comments on commit 05c5980

Please sign in to comment.
You can’t perform that action at this time.