<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> This was changed in the generated ci workflow but not on the docs. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> This is changed in the docs as well so it's not confusing. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
34 lines
998 B
Markdown
34 lines
998 B
Markdown
# Configuring CI Using GitLab and Nx
|
|
|
|
Below is an example of a GitLab setup, building and testing only what is affected.
|
|
|
|
```yaml {% fileName=".gitlab-ci.yml" %}
|
|
image: node:20
|
|
|
|
variables:
|
|
GIT_DEPTH: 0
|
|
|
|
main:
|
|
interruptible: true
|
|
only:
|
|
- main
|
|
- merge_requests
|
|
cache:
|
|
key:
|
|
files:
|
|
- package-lock.json
|
|
paths:
|
|
- .npm/
|
|
script:
|
|
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
|
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
|
# - npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="e2e-ci"
|
|
|
|
- npm ci --cache .npm --prefer-offline
|
|
- NX_HEAD=$CI_COMMIT_SHA
|
|
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
|
|
|
|
- npx nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD
|
|
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build e2e-ci
|
|
```
|