-
-
Notifications
You must be signed in to change notification settings - Fork 782
93 lines (76 loc) · 2.47 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: CI
on:
push:
branches:
- main
pull_request:
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 3
NX_BRANCH: ${{ github.event.number || github.ref_name }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
VOLTA_FEATURE_PNPM: 1
SKIP_ENV_VALIDATION: true
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}}
CLERK_SECRET_KEY: ${{secrets.CLERK_SECRET_KEY}}
jobs:
main:
name: CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout [Pull Request]
if: ${{ github.event_name == 'pull_request' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: actions/checkout@v3
name: Checkout [Default Branch]
if: ${{ github.event_name != 'pull_request' }}
with:
fetch-depth: 0
- name: Derive SHAs for `nx affected` commands
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'main'
- name: Setup volta
uses: volta-cli/action@v4
- name: Install dependencies
run: pnpm install
- name: Initialize the Nx Cloud distributed CI run
run: pnpm nx-cloud start-ci-run
- name: Run commands in parallel
run: |
pids=()
NX_CLOUD_DISTRIBUTED_EXECUTION=false pnpm nx-cloud record -- pnpm format:check & pids+=($!)
pnpm nx affected -t lint --parallel=3 & pids+=($!)
pnpm nx affected -t typecheck --parallel=3 & pids+=($!)
NX_CLOUD_DISTRIBUTED_EXECUTION=false pnpm nx affected -t build --parallel=3 & pids+=($!)
# run all commands in parallel and bail if one of them fails
for pid in "${pids[@]}"; do
if ! wait $pid; then
echo "Process $pid failed"
exit 1
fi
done
exit 0
- name: Stop all running agents for this CI run
if: ${{ always() }}
run: pnpm nx-cloud stop-all-agents
agents:
name: Agent ${{ matrix.agent }}
runs-on: ubuntu-latest
strategy:
matrix:
agent: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup volta
uses: volta-cli/action@v4
- name: Install dependencies
run: pnpm install
- name: Start Nx Agent ${{ matrix.agent }}
run: pnpm nx-cloud start-agent
env:
NX_AGENT_NAME: ${{matrix.agent}}