Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): streamline CI runs #12840

Merged
merged 7 commits into from
May 13, 2022
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
121 changes: 31 additions & 90 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,23 @@ concurrency:
cancel-in-progress: true

jobs:
prepare-yarn-cache:
name: Prepare yarn cache
strategy:
fail-fast: false
matrix:
# for some reason the Windows cache doesn't work
os: [ubuntu-latest, macOS-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: yarn

- name: Validate cache
env:
# Use PnP and disable postinstall scripts as this just needs to
# populate the cache for the other jobs
YARN_NODE_LINKER: pnp
YARN_ENABLE_SCRIPTS: false
run: yarn --immutable
prepare-yarn-cache-ubuntu:
uses: ./.github/workflows/prepare-cache.yml
with:
os: ubuntu-latest
prepare-yarn-cache-macos:
uses: ./.github/workflows/prepare-cache.yml
with:
os: macos-latest
prepare-yarn-cache-windows:
uses: ./.github/workflows/prepare-cache.yml
with:
os: windows-latest

ts-compatibility:
name: TypeScript Compatibility
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu

steps:
- uses: actions/checkout@v3
Expand All @@ -63,7 +51,7 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu

steps:
- uses: actions/checkout@v3
Expand All @@ -87,7 +75,7 @@ jobs:
yarn-validate:
name: Validate Yarn dependencies and constraints
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -99,68 +87,21 @@ jobs:
- name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")'
run: yarn dedupe --check

test:
name: Node v${{ matrix.node-version }} on ${{ matrix.os }} (${{ matrix.shard }})
strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x, 17.x, 18.x]
os: [ubuntu-latest, macOS-latest, windows-latest]
shard: ['1/4', '2/4', '3/4', '4/4']
runs-on: ${{ matrix.os }}
needs: prepare-yarn-cache

steps:
- name: Set git config
shell: bash
run: git config --global core.symlinks true
if: runner.os == 'Windows'
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: install
run: yarn --immutable
- name: build
run: yarn build:js
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}

test-jasmine:
name: Node LTS on ${{ matrix.os }} using jest-jasmine2 (${{ matrix.shard }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
shard: ['1/4', '2/4', '3/4', '4/4']
runs-on: ${{ matrix.os }}
needs: prepare-yarn-cache

steps:
- name: Set git config
shell: bash
run: git config --global core.symlinks true
if: runner.os == 'Windows'
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: yarn
- name: install
run: yarn --immutable
- name: build
run: yarn build:js
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
test-ubuntu:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-ubuntu
with:
os: ubuntu-latest
test-macos:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-macos
with:
os: macos-latest
test-windows:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-windows
with:
os: windows-latest

test-coverage:
name: Node LTS on Ubuntu with coverage (${{ matrix.shard }})
Expand All @@ -169,7 +110,7 @@ jobs:
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu

steps:
- uses: actions/checkout@v3
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/prepare-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Prepare CI cache

on:
workflow_call:
inputs:
os:
required: true
type: string

jobs:
prepare-yarn-cache:
name: Prepare yarn cache for ${{ inputs.os }}
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: yarn

- name: Validate cache
env:
# Use PnP and disable postinstall scripts as this just needs to
# populate the cache for the other jobs
YARN_NODE_LINKER: pnp
YARN_ENABLE_SCRIPTS: false
run: yarn --immutable
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test

on:
workflow_call:
inputs:
os:
required: true
type: string

jobs:
test:
strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x, 17.x, 18.x]
shard: ['1/4', '2/4', '3/4', '4/4']
name: Node v${{ matrix.node-version }} on ${{ inputs.os }} (${{ matrix.shard }})
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: install
run: yarn --immutable
- name: build
run: yarn build:js
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}

test-jasmine:
strategy:
fail-fast: false
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
name: Node LTS on ${{ inputs.os }} using jest-jasmine2 (${{ matrix.shard }})
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: yarn
- name: install
run: yarn --immutable
- name: build
run: yarn build:js
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}