Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Parallel CI jobs #1705

Merged
merged 2 commits into from
Dec 10, 2020
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
112 changes: 102 additions & 10 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
name: Node-CI

on:
push:
branches: [master]
pull_request:
branches: [master]
on: push
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously setup just to run CI on pushes to master, not sure why. It now runs CI on all pushes to this repo.


jobs:
node-tests:
node-lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
Expand Down Expand Up @@ -39,16 +34,113 @@ jobs:
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: 🔨 Build
run: yarn build --verbose

- name: 💅🏼 Lint
run: |
yarn lint
yarn ci:lint-docs

node-build:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's a way to re-use all of this duplication :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem so - actions/starter-workflows#245.

I stumbled across the needs field while looking through their docs. Couldn't get it to work properly and it arguably ends up creating more duplication - 89013b8.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
name: Checkout

- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory
id: yarn-cache-get-dir
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
name: Restore yarn cache
with:
path: ${{ steps.yarn-cache-get-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: 🔨 Build
run: yarn build --verbose

node-e2e-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
name: Checkout

- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory
id: yarn-cache-get-dir
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
name: Restore yarn cache
with:
path: ${{ steps.yarn-cache-get-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: 🔨 Build
run: yarn build --verbose

- name: E2E tests
run: yarn test:ci --testPathPattern react-server address

node-unit-tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
name: Checkout

- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory
id: yarn-cache-get-dir
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
name: Restore yarn cache
with:
path: ${{ steps.yarn-cache-get-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: Unit tests
run: yarn test:ci --testPathIgnorePatterns react-server address
9 changes: 8 additions & 1 deletion packages/koa-metrics/src/test/timer.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {initTimer} from '../timer';

const NODE_VERSION = process.version;

describe('timer', () => {
it('measures the time between when initTimer and the returned timer objects stop method is called', async () => {
const timer = initTimer();
await delay(10);
const durationMillis = timer.stop();

expect(durationMillis).toBeGreaterThanOrEqual(10);
// Node 14 CI test are flaky with this test
expect(durationMillis).toBeGreaterThanOrEqual(isNode14() ? 9 : 10);
});
});

Expand All @@ -15,3 +18,7 @@ function delay(milliseconds: number) {
setTimeout(resolve, milliseconds);
});
}

function isNode14() {
return NODE_VERSION.includes('v14.');
}