Skip to content
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
57 changes: 41 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import parseTravisCiConfig from './parser/travis-ci';
import path from 'path';
import process from 'process';

interface EmberTryScenario {
scenario: string;
allowedToFail: boolean;
}

interface ConfigurationInterface {
browsers: string[];
emberTryScenarios: {
allowedToFail: string[];
required: string[];
};
emberTryScenarios: EmberTryScenario[];
nodeVersion: string;
packageManager: 'npm' | 'yarn';
}
Expand All @@ -32,17 +34,40 @@ const templateFile = path.join(
);
const data: ConfigurationInterface = parseTravisCiConfig() ?? {
browsers: ['chrome', 'firefox'],
emberTryScenarios: {
required: [
'ember-lts-3.16',
'ember-lts-3.20',
'ember-release',
'ember-beta',
'ember-default-with-jquery',
'ember-classic',
],
allowedToFail: ['ember-canary', 'embroider-tests'],
},
emberTryScenarios: [
{
scenario: 'ember-lts-3.16',
allowedToFail: false,
},
{
scenario: 'ember-lts-3.20',
allowedToFail: false,
},
{
scenario: 'ember-release',
allowedToFail: false,
},
{
scenario: 'ember-beta',
allowedToFail: false,
},
{
scenario: 'ember-default-with-jquery',
allowedToFail: false,
},
{
scenario: 'ember-classic',
allowedToFail: false,
},
{
scenario: 'ember-canary',
allowedToFail: true,
},
{
scenario: 'embroider-tests',
allowedToFail: true,
},
],
nodeVersion: '10.x',
packageManager: 'yarn',
};
Expand All @@ -60,4 +85,4 @@ ejs.renderFile(templateFile, data, options, function (err, str) {
fs.writeFileSync(gitHubActionsWorkflowFile, str);
});

export { ConfigurationInterface };
export { ConfigurationInterface, EmberTryScenario };
32 changes: 14 additions & 18 deletions src/parser/travis-ci.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConfigurationInterface } from '../index';
import { ConfigurationInterface, EmberTryScenario } from '../index';
import debug from '../utils/debug';
import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -62,38 +62,34 @@ export default function (): ConfigurationInterface | null {
);
const nodeVersion = `${config.node_js?.[0]}.x`;

const emberTryScenarios: string[] = config.jobs.include
.map(({ env }: { env: unknown }): string | null => {
const emberTryScenarios: EmberTryScenario[] = config.jobs.include
.map(({ env }: { env: unknown }) => {
if (typeof env !== 'string') {
return null;
}

const [key, value] = env.split('=');
return key === 'EMBER_TRY_SCENARIO' ? value : null;
})
.filter((_: string | null) => _ !== null);
const allowedToFailEmberTryScenarios: string[] = config.jobs.allow_failures
.map(({ env }: { env: unknown }): string | null => {
if (typeof env !== 'string') {

if (key !== 'EMBER_TRY_SCENARIO') {
return null;
}

const [key, value] = env.split('=');
return key === 'EMBER_TRY_SCENARIO' ? value : null;
return {
scenario: value,
allowedToFail: config.jobs.allow_failures.some(
({ env: envAllowedToFail }: { env: unknown }) => {
return envAllowedToFail === env;
}
),
};
})
.filter((_: string | null) => _ !== null);
const requiredEmberTryScenarios = emberTryScenarios.filter(
(scenario) => !allowedToFailEmberTryScenarios.includes(scenario)
);

const packageManager: 'npm' | 'yarn' = determinePackageManager(config);

return {
browsers,
emberTryScenarios: {
required: requiredEmberTryScenarios,
allowedToFail: allowedToFailEmberTryScenarios,
},
emberTryScenarios,
nodeVersion,
packageManager,
};
Expand Down
12 changes: 9 additions & 3 deletions templates/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,18 @@ jobs:
fail-fast: true
matrix:
ember-try-scenario: [<%
emberTryScenarios.required.forEach(function(scenario, index){ %>
<%- scenario %><% if (index < emberTryScenarios.required.length - 1) { %>,<% }}); %>
emberTryScenarios
.filter(({ allowedToFail }) => !allowedToFail)
.forEach(function({ scenario }, index, requiredEmberTryScenarios) {
const isLastElement = requiredEmberTryScenarios.length - 1 === index; %>
<%- scenario %><% if (!isLastElement) { %>,<% }
}); %>
]
allow-failure: [false]
include:<%
emberTryScenarios.allowedToFail.forEach(function(scenario){ %>
emberTryScenarios
.filter(({ allowedToFail }) => allowedToFail)
.forEach(function({ scenario }) { %>
- ember-try-scenario: <%- scenario %>
allow-failure: true<% }); %>

Expand Down