-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): add missing parts to ci workflws and update docs
(cherry picked from commit ab76d62)
- Loading branch information
1 parent
37649eb
commit 3078ecf
Showing
9 changed files
with
309 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,46 @@ | ||
# Configuring CI Using Bitbucket Pipelines and Nx | ||
|
||
Below is an example of an Bitbucket Pipelines, building and testing only what is affected. | ||
Below is an example of a Bitbucket Pipelines, building and testing only what is affected. | ||
|
||
```yaml {% fileName="bitbucket-pipelines.yml" %} | ||
image: node:20 | ||
|
||
clone: | ||
depth: full | ||
|
||
pipelines: | ||
pull-requests: | ||
'**': | ||
- step: | ||
name: 'Build and test affected apps on Pull Requests' | ||
caches: # optional | ||
- node | ||
script: | ||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution | ||
# This line enables 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="5 linux-medium-js" --stop-agents-after="e2e-ci" | ||
- npm ci | ||
|
||
- npx nx-cloud record -- nx format:check | ||
- npx nx affected -t lint test build --base=origin/master --head=HEAD | ||
- npx nx affected -t lint test build e2e-ci --base=origin/main | ||
|
||
branches: | ||
main: | ||
- step: | ||
name: "Build and test affected apps on 'main' branch changes" | ||
caches: # optional | ||
- node | ||
script: | ||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution | ||
- export NX_BRANCH=$BITBUCKET_PR_ID | ||
# This line enables 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="5 linux-medium-js" --stop-agents-after="e2e-ci" | ||
- npm ci | ||
|
||
- npx nx-cloud record -- nx format:check | ||
- npx nx affected -t lint test build --base=HEAD~1 | ||
- npx nx affected -t lint test build e2e-ci --base=HEAD~1 | ||
``` | ||
The `pull-requests` and `main` jobs implement the CI workflow. | ||
|
||
### Get the Commit of the Last Successful Build | ||
|
||
Unlike `GitHub Actions` and `CircleCI`, you don't have the metadata to help you track the last successful run on `main`. In the example below, the base is set to `HEAD~1` (for push) or branching point (for pull requests), but a more robust solution would be to tag an SHA in the main job once it succeeds and then use this tag as a base. See the [nx-tag-successful-ci-run](https://github.com/nrwl/nx-tag-successful-ci-run) and [nx-set-shas](https://github.com/nrwl/nx-set-shas) (version 1 implements tagging mechanism) repositories for more information. | ||
|
||
We also have to set `NX_BRANCH` explicitly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.