Co-authored-by: Katerina Skroumpelou <mandarini@users.noreply.github.com> Co-authored-by: Colum Ferry <cferry09@gmail.com> Co-authored-by: Emily Xiong <xiongemi@gmail.com> Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com> Co-authored-by: Jason Jean <jasonjean1993@gmail.com> Co-authored-by: Victor Savkin <mail@vsavkin.com> Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
1.2 KiB
1.2 KiB
Configuring CI Using GitLab and Nx
Below is an example of an GitLab setup, building and testing only what is affected.
image: node:18
stages:
- lint
- test
- build
.distributed:
interruptible: true
only:
- main
- merge_requests
cache:
key:
files:
- package-lock.json
paths:
- .npm/
before_script:
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution
- npm ci --cache .npm --prefer-offline
- NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
variables:
GIT_DEPTH: 0
format-check:
stage: test
extends: .distributed
script:
- npx nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD
lint:
stage: test
extends: .distributed
script:
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint --parallel=3
test:
stage: test
extends: .distributed
script:
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t test --parallel=3
build:
stage: build
extends: .distributed
script:
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t build --parallel=3