From 519f54980405a212dcc67dff35e84016f0167e59 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Fri, 27 Sep 2024 09:15:12 +0200 Subject: [PATCH 1/3] docs: improve monorepo docs --- docs/tutorials/monorepo_guidance.md | 56 ++++++++++++++++++++++++----- mkdocs.yml | 1 + 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/docs/tutorials/monorepo_guidance.md b/docs/tutorials/monorepo_guidance.md index c4345d6bc2..78e37fd71f 100644 --- a/docs/tutorials/monorepo_guidance.md +++ b/docs/tutorials/monorepo_guidance.md @@ -3,7 +3,7 @@ This tutorial assumes the monorepo layout is designed with multiple components that can be released independently of each other, it also assumes that conventional commits with scopes are in use. Some suggested layouts: -``` +```sh . ├── library-b │   └── .cz.toml @@ -11,7 +11,7 @@ other, it also assumes that conventional commits with scopes are in use. Some su └── .cz.toml ``` -``` +```sh src ├── library-b │   └── .cz.toml @@ -19,23 +19,61 @@ src └── .cz.toml ``` -Each component will have its own changelog, commits will need to use scopes so only relevant commits are included in the -appropriate change log for a given component. Example config and commit for `library-b` +Sample `.cz.toml` for each component: ```toml +# library-b/.cz.toml [tool.commitizen] name = "cz_customize" version = "0.0.0" tag_format = "${version}-library-b" # the component name can be a prefix or suffix with or without a separator update_changelog_on_bump = true +``` + +```toml +# library-z/.cz.toml +[tool.commitizen] +name = "cz_customize" +version = "0.0.0" +tag_format = "${version}-library-z" +update_changelog_on_bump = true +``` + +And finally, to bump each of these: + +```sh +cz --config library-b/.cz.toml bump --yes +cz --config library-z/.cz.toml bump --yes +``` + +## Changelog per component + +In order to filter the correct commits for each component, you'll have to come up with a strategy. + +For example: + +- Trigger the pipeline based on the changed path, which can have some downsides, as you'll rely on the developer not including files from other files + - [github actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore) uses `path` + - [Jenkins](https://www.jenkins.io/doc/book/pipeline/syntax/#built-in-conditions) uses `changeset` + - [Gitlab](https://docs.gitlab.com/ee/ci/yaml/#ruleschanges) uses `rules:changes` +- Filter certain pattern of the commit message (recommended) + + +### Example with scope in conventional commits + +For this example, to include the message in the changelog, we will require commits to use a specific scope. +This way, only relevant commits will be included in the appropriate change log for a given component, and any other commit will be ignored. + +Example config and commit for `library-b`: + +```toml [tool.commitizen.customize] changelog_pattern = "^(feat|fix)\\(library-b\\)(!)?:" #the pattern on types can be a wild card or any types you wish to include ``` -example commit message for the above +A commit message looking like this, would be included: -`fix:(library-b) Some awesome message` - -If the above is followed and the `cz bump --changelog` is run in the directory containing the component the changelog -should be generated in the same directory with only commits scoped to the component. +``` +fix:(library-b) Some awesome message +``` diff --git a/mkdocs.yml b/mkdocs.yml index a0fb57fde2..f6a7eaa421 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -53,6 +53,7 @@ nav: - Github Actions: "tutorials/github_actions.md" - Jenkins pipeline: "tutorials/jenkins_pipeline.md" - Developmental releases: "tutorials/dev_releases.md" + - Monorepo support: "tutorials/monorepo_guidance.md" - FAQ: "faq.md" - Exit Codes: "exit_codes.md" - Third-Party Commitizen Templates: "third-party-commitizen.md" From 4aa1d79bae7e121f87a7a00b2d0ea7d91d402fdb Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Mon, 7 Oct 2024 11:27:20 +0200 Subject: [PATCH 2/3] docs: update docs/tutorials/monorepo_guidance.md Co-authored-by: Wei Lee --- docs/tutorials/monorepo_guidance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/monorepo_guidance.md b/docs/tutorials/monorepo_guidance.md index 78e37fd71f..a943b70bb5 100644 --- a/docs/tutorials/monorepo_guidance.md +++ b/docs/tutorials/monorepo_guidance.md @@ -3,7 +3,7 @@ This tutorial assumes the monorepo layout is designed with multiple components that can be released independently of each other, it also assumes that conventional commits with scopes are in use. Some suggested layouts: -```sh +```shell-session . ├── library-b │   └── .cz.toml From 5c78c68f91ceb7e3478e5a2f54fd5ff911aaac83 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Mon, 7 Oct 2024 11:27:29 +0200 Subject: [PATCH 3/3] docs: update docs/tutorials/monorepo_guidance.md Co-authored-by: Wei Lee --- docs/tutorials/monorepo_guidance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/monorepo_guidance.md b/docs/tutorials/monorepo_guidance.md index a943b70bb5..ba6d70fd82 100644 --- a/docs/tutorials/monorepo_guidance.md +++ b/docs/tutorials/monorepo_guidance.md @@ -11,7 +11,7 @@ other, it also assumes that conventional commits with scopes are in use. Some su └── .cz.toml ``` -```sh +```shell-session src ├── library-b │   └── .cz.toml