Skip to content

Commit ca035ca

Browse files
authored
Meta: Separate CI workflows (#487)
Splits CI jobs to run in parallel and make the reason of the failure clearer. Before: <img width="946" alt="CleanShot 2023-06-01 at 12 24 55@2x" src="https://github.com/WordPress/wordpress-playground/assets/205419/e1ce9b97-fb9d-474e-9435-dae31185d2d7"> After: <img width="937" alt="CleanShot 2023-06-01 at 13 28 43@2x" src="https://github.com/WordPress/wordpress-playground/assets/205419/a9c32ee2-fbe5-4aec-a7b3-0bbe805402d0">
1 parent 47c2832 commit ca035ca

File tree

2 files changed

+61
-11
lines changed

2 files changed

+61
-11
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Clone the repository, install dependencies, and configures nx variables
2+
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Fetch trunk
7+
shell: bash
8+
run: git fetch origin trunk --depth=1
9+
- uses: actions/setup-node@v3
10+
- name: Cache node modules
11+
id: cache-nodemodules
12+
uses: actions/cache@v2
13+
env:
14+
cache-name: cache-node-modules
15+
with:
16+
# caching node_modules
17+
path: node_modules
18+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
19+
restore-keys: |
20+
${{ runner.os }}-build-${{ env.cache-name }}-
21+
${{ runner.os }}-build-
22+
${{ runner.os }}-
23+
- name: Install Dependencies
24+
shell: bash
25+
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
26+
run: npm ci
27+
- name: Set NX_BASE
28+
shell: bash
29+
run: echo "NX_BASE=$(git rev-parse origin/trunk)" >> $GITHUB_ENV
30+
- name: Set NX_HEAD
31+
shell: bash
32+
run: echo "NX_HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV

.github/workflows/ci.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,37 @@ on:
66
pull_request:
77

88
jobs:
9-
main:
9+
warmup-cache:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
with:
14-
fetch-depth: 0
15-
- uses: actions/setup-node@v3
16-
- uses: nrwl/nx-set-shas@v3
17-
with:
18-
main-branch-name: 'trunk'
19-
- run: npm ci
12+
- uses: actions/checkout@v3
13+
- uses: ./.github/actions/prepare-playground
14+
format:
15+
runs-on: ubuntu-latest
16+
needs: [warmup-cache]
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: ./.github/actions/prepare-playground
2020
- run: npx nx format:check || npx prettier --check .
21+
- run: npx nx affected --target=lint
22+
typecheck:
23+
runs-on: ubuntu-latest
24+
needs: [warmup-cache]
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: ./.github/actions/prepare-playground
2128
- run: npx nx affected --target=typecheck
22-
- run: npx nx affected --target=lint --parallel=3
23-
- run: npx nx affected --target=test --parallel=3 --configuration=ci
29+
test:
30+
runs-on: ubuntu-latest
31+
needs: [warmup-cache]
32+
steps:
33+
- uses: actions/checkout@v3
34+
- uses: ./.github/actions/prepare-playground
35+
- run: npx nx affected --target=test --configuration=ci
36+
build:
37+
runs-on: ubuntu-latest
38+
needs: [warmup-cache]
39+
steps:
40+
- uses: actions/checkout@v3
41+
- uses: ./.github/actions/prepare-playground
2442
- run: npx nx affected --target=build --parallel=3

0 commit comments

Comments
 (0)