Skip to content

Commit

Permalink
docs(core): adding bitbucket pipelines doc (#9567)
Browse files Browse the repository at this point in the history
Co-authored-by: galarbel-ampliospeech <gal.arbel@ampliospeech.com>
  • Loading branch information
bcabanes and galarbel-ampliospeech committed Mar 28, 2022
1 parent f1400c6 commit 8498fe9
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/map.json
Expand Up @@ -1397,6 +1397,11 @@
"id": "monorepo-ci-gitlab",
"file": "shared/monorepo-ci-gitlab"
},
{
"name": "Setting up Bitbucket",
"id": "monorepo-ci-bitbucket-pipelines",
"file": "shared/monorepo-ci-bitbucket-pipelines"
},
{
"name": "Distributed CI",
"id": "distributed-builds",
Expand Down
1 change: 1 addition & 0 deletions docs/shared/ci-overview.md
Expand Up @@ -18,3 +18,4 @@ The following guides cover optimizing your CI/CD environments with affected comm
- [Setting up CI using CircleCI](/ci/monorepo-ci-circle-ci)
- [Setting up CI using Azure Pipelines](/ci/monorepo-ci-azure)
- [Setting up CI using Jenkins](/ci/monorepo-ci-jenkins)
- [Setting up CI using Bitbucket Pipelines](/ci/monorepo-ci-bitbucket-pipeline)
54 changes: 54 additions & 0 deletions docs/shared/monorepo-ci-bitbucket-pipelines.md
@@ -0,0 +1,54 @@
# Configuring CI Using Bitbucket Pipelines and Nx

Nx is a smart, fast and extensible build system, and it works really well with monorepos. Monorepos provide a lot of advantages:

- Everything at that current commit works together. Changes can be verified across all affected parts of the organization.
- Easy to split code into composable modules
- Easier dependency management
- One toolchain setup
- Code editors and IDEs are "workspace" aware
- Consistent developer experience
- And more ...

But they come with their own technical challenges. The more code you add into your repository, the slower the CI gets.

## Setting Bitbucket Pipelines

Below is an example of a Bitbucket Pipeline setup for an Nx workspace only building and testing what is affected.

```yaml
...

pipelines:
pull-requests:
'**':
- step:
name: "Build and test affected apps on Pull Requests"
caches: # optional
- node
script:
- npm i
- npx nx affected --target=build --base=origin/master --head=HEAD --parallel --max-parallel=3
- npx nx affected --target=test --base=origin/master --head=HEAD --parallel --max-parallel=2

branches:
main:
- step:
name: "Build and test affected apps on 'main' branch changes"
caches: # optional
- node
script:
- npm i
- npx nx affected --target=build --base=HEAD~1 --parallel --max-parallel=3
- npx nx affected --target=test --base=HEAD~1 --parallel --max-parallel=2
```

The `pull-requests` and `main` jobs implement the CI workflow.

## Distributed CI with Nx Cloud

A computation cache is created on your local machine to make the developer experience faster. This allows you to not waste time re-building, re-testing, re-linting, or any number of other actions you might take on code that hasn't changed. Because the cache is stored locally, you are the only member of your team that can take advantage of these instant commands. You can manage and share this cache manually.

Nx Cloud allows this cache to be shared across your entire organization, meaning that any cacheable operation completed on your workspace only needs to be run once. Nx Cloud also allows you to distribute your CI across multiple machines to make sure the CI is fast even for very large repos.

Learn more about [configuring your CI](https://nx.app/docs/configuring-ci) environment using Nx Cloud with [Distributed Caching](https://nx.app/docs/distributed-caching) and [Distributed Task Execution](https://nx.app/docs/distributed-execution) in the Nx Cloud docs.

1 comment on commit 8498fe9

@vercel
Copy link

@vercel vercel bot commented on 8498fe9 Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.