Skip to content

Commit

Permalink
Use GitHub Actions for parallel running
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Oct 9, 2019
1 parent 4c259f3 commit 4c395fc
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 32 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests
on:
pull_request:
branches: [master]

jobs:
tests:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Install
run: yarn install
- name: Linting
run: yarn lint:js
- name: Test
run: yarn test

integration_tests:
name: Integration Tests
strategy:
matrix:
ember_version: ['3.10', '3.13']
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Install
run: yarn install
- name: Test
env:
EMBER_VERSION: ${{ matrix.ember_version }}
run: yarn test:integration
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

40 changes: 30 additions & 10 deletions test/run-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
/* eslint-disable no-console */
const versions = ['3.10', '3.13'];

const { spawn } = require('child_process');
// const versions = [process.env.EMBER_VERSION]
const allVersions = ['3.10', '3.13'];

const execa = require('execa');
const path = require('path');

async function kill(subprocess) {
setTimeout(() => {
subprocess.cancel();
subprocess.kill('SIGTERM');
}, 1000);

console.log(`Requesting SIGTERM of ${subprocess.pid}`);
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, 1000);
});
}

async function runTestForVersion(version) {
console.log(`
Running Integration Test for Ember ${version}
Expand All @@ -22,8 +37,7 @@ async function runTestForVersion(version) {
console.log('starting serve');

// We use spawn for this one so we can kill it later without throwing an error
const emberServe = spawn('yarn', ['start'], execOpts);
emberServe.stderr.pipe(process.stderr);
const emberServe = execa('yarn', ['start'], { cwd: inputDir });

await new Promise(resolve => {
emberServe.stdout.on('data', data => {
Expand All @@ -39,7 +53,7 @@ async function runTestForVersion(version) {

console.log('codemod complete, ending serve');

emberServe.kill('SIGTERM');
await kill(emberServe);

console.log('comparing results');

Expand All @@ -55,13 +69,19 @@ async function runTestForVersion(version) {
console.log('codemod ran successfully! 🎉');
}


(async () => {
for (let version of versions) {
await runTestForVersion(version);
let emberVersion = process.env.EMBER_VERSION;
if (!emberVersion) {
console.error(`No EMBER_VERSION set. No scenarios to run.`);
process.exit(1);
}

process.exit(0);
})();
if (!allVersions.includes(`${emberVersion}`)) {
console.error(`EMBER_VERSION is not allowed. Available: ${allVersions.join(', ')}`);
process.exit(1);
}

await runTestForVersion(emberVersion);

process.exit(0);
})();

0 comments on commit 4c395fc

Please sign in to comment.