Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@ jobs:
name: Initialize project metadata
command: |
mkdir -p .project-metadata
touch .project-{a,b}-hash
mkdir -p tmp
touch tmp/.project-{a,b}-hash

- run:
name: Hash projects
command: |
git log --pretty=format:'%H' -n 1 -- project_a > .project-a-hash.new
git log --pretty=format:'%H' -n 1 -- project_b > .project-b-hash.new
git log --pretty=format:'%H' -n 1 -- project_a > tmp/.project-a-hash.new
git log --pretty=format:'%H' -n 1 -- project_b > tmp/.project-b-hash.new

- run:
name: Determine changed projects
command: |
if ! diff .project-a-hash{,.new} > /dev/null; then
if ! diff tmp/.project-a-hash{,.new} > /dev/null; then
touch .project-metadata/.project-a-changed
fi

if ! diff .project-b-hash{,.new} > /dev/null; then
if ! diff tmp/.project-b-hash{,.new} > /dev/null; then
touch .project-metadata/.project-b-changed
fi

- run:
name: Set current project hashes
command: |
mv .project-a-hash{.new,}
mv .project-b-hash{.new,}
mv tmp/.project-a-hash{.new,}
mv tmp/.project-b-hash{.new,}

- persist_to_workspace:
root: .
Expand All @@ -52,8 +53,7 @@ jobs:
- save_cache:
key: v1-project-metadata-{{ .Branch }}-{{ epoch }}
paths:
- .project-a-hash
- .project-b-hash
- tmp/*

project_a:
<<: *defaults
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# monorepo-builds
Playing around with configuring Circle CI for a monorepo
Playing around with configuring Circle CI for a monorepo.

Builds subprojects separately depending on whether they've been changed.
2 changes: 2 additions & 0 deletions project_a/file
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
change
change
change
2 changes: 2 additions & 0 deletions project_b/file
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
change
change
change