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

Commit

Permalink
Simplify CI config (#1908)
Browse files Browse the repository at this point in the history
Refactors our CI suite, moving from multiple simultaneous jobs to running building, linting, unit tests and e2e tests in sequence.

The net result is one job that has a slightly slower wall clock time for all jobs to complete (4.5ish mins => 5.5ish mins), but takes less CPU time overall - as the multiple jobs duplicate effort in doing yarn installs.

This means one job per node version (i.e. 3 checks total) instead of 4 jobs per node version (i.e. 12 checks total) which is easier to read in the checks list, and easier to configure. This is worth the extra minute or so taken IMO.
  • Loading branch information
BPScott authored May 21, 2021
1 parent 803c6d3 commit 191c3c8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 163 deletions.
164 changes: 17 additions & 147 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Node-CI

on:
push:
branches: [main]
pull_request:
branches: ['**']
push:
branches: [main]

jobs:
node-lint:
node-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
timeout-minutes: 10
timeout-minutes: 15

steps:
- uses: actions/checkout@v2
Expand All @@ -32,167 +32,37 @@ jobs:
name: Restore yarn cache
with:
path: ${{ steps.yarn-cache-get-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-node${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-node${{ matrix.node-version }}-yarn-
- uses: actions/cache@v2
id: sewing-kit-cache
name: Restore sewing-kit cache
with:
path: |
.sewing-kit/
key: ${{ runner.os }}-sewing-kit-${{ github.sha }}
restore-keys: |
${{ runner.os }}-sewing-kit-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: 💅🏼 Lint
run: |
yarn lint
yarn ci:lint-docs
node-build:
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-
- uses: actions/cache@v2
id: build-cache
name: Restore build cache
with:
path: |
.sewing-kit/
./packages/*/build/
key: ${{ runner.os }}-${{ matrix.node-version }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-build-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: 🔨 Build
run: yarn build

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-
- uses: actions/cache@v2
id: build-cache
name: Restore build cache
with:
# index packages files need to be cached for e2e tests
path: |
.sewing-kit/
./packages/*/build/
./packages/*/*.esnext
./packages/*/*.mjs
./packages/*/*.js
key: ${{ runner.os }}-${{ matrix.node-version }}-build-${{ github.sha }}
key: ${{ runner.os }}-node${{ matrix.node-version }}-sewing-kit-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-build-
${{ runner.os }}-node${{ matrix.node-version }}-sewing-kit-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile
run: yarn --frozen-lockfile

- name: 🔨 Build
run: yarn build

- name: E2E tests
run: yarn test --debug "(address|react-server)"

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-
- uses: actions/cache@v2
id: build-cache
name: Restore build cache
with:
path: |
.sewing-kit/
./packages/*/build/
key: ${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ matrix.node-version }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ matrix.node-version }}-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile
- name: 💅🏼 Lint
run: |
yarn lint
yarn ci:lint-docs
- name: Unit tests
run: yarn test:ci "^(?:(?!(address|react-server)).)*$"
run: yarn test "^(?:(?!(address|react-server)).)*$"

- name: E2E tests
run: yarn test --debug "(address|react-server)"
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"lint": "skn lint",
"lint:changelogs": "node scripts/lint-changelogs.js",
"ci:lint-docs": "yarn generate docs && ./scripts/check-docs.sh",
"_test": "NODE_ICU_DATA=node_modules/full-icu skn test",
"pretest": "yarn build",
"test": "yarn _test",
"test:ci": "yarn test --coverage",
"test": "NODE_ICU_DATA=node_modules/full-icu skn test",
"check": "lerna run check",
"release": "yarn lint:changelogs && lerna version --no-push --include-merged-tags",
"clean": "rimraf ./packages/*/build ./packages/*/*.{d.ts,js,esnext,mjs} .sewing-kit",
Expand Down
15 changes: 3 additions & 12 deletions shipit.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
ci:
require:
- node-unit-tests (10.x)
- node-unit-tests (12.x)
- node-unit-tests (14.x)
- node-e2e-tests (10.x)
- node-e2e-tests (12.x)
- node-e2e-tests (14.x)
- node-lint (10.x)
- node-lint (12.x)
- node-lint (14.x)
- node-build (10.x)
- node-build (12.x)
- node-build (14.x)
- node-tests (10.x)
- node-tests (12.x)
- node-tests (14.x)
dependencies:
post:
- npm config set @shopify:registry https://registry.npmjs.org
Expand Down

0 comments on commit 191c3c8

Please sign in to comment.