-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
.gitlab-ci.yml
80 lines (72 loc) · 1.99 KB
/
.gitlab-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
include:
- template: Workflows/MergeRequest-Pipelines.gitlab-ci.yml
stages:
- affected
- build
default:
image: node:20.12
variables:
CI: 'true'
NX_CLOUD_ACCESS_TOKEN: $NX_CLOUD_TOKEN
NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 2
# Cache template
.node-cache: &node-cache
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
policy: pull
# Creating template for DTE agents
.dte-agent:
interruptible: true
cache:
<<: *node-cache
before_script:
- corepack enable pnpm
- corepack install
- pnpm config set store-dir .pnpm-store
- pnpm install
script:
- pnpm exec nx-cloud start-agent
# Creating template for a job running DTE (orchestrator)
.base-pipeline:
interruptible: true
only:
- main
- merge_requests
cache:
<<: *node-cache
policy: pull-push
before_script:
- corepack enable pnpm
- corepack install
- pnpm config set store-dir .pnpm-store
- pnpm install
- NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
artifacts:
expire_in: 5 days
paths:
- node_modules/.cache/nx
- dist
# Main job running DTE
CI:
stage: affected
extends: .base-pipeline
script:
- pnpm exec nx-cloud start-ci-run --stop-agents-after="build"
- pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
- pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
after_script:
- pnpm exec nx-cloud stop-all-agents
# Create as many agents as you want
nx-dte-agent1:
extends: .dte-agent
stage: affected
nx-dte-agent2:
extends: .dte-agent
stage: affected
# nx-dte-agent3:
# extends: .dte-agent
# stage: affected