Skip to content

Commit 5dc218b

Browse files
rainecpCopybara
authored and
Copybara
committed
Add run_copybara script
GitOrigin-RevId: 68743d61f07bdeada23d9293886b1c064fd7e9a8
1 parent 8ec78bf commit 5dc218b

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

.buildkite/scripts/copy.bara.sky

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This is a configuration file for Copybara that defines the workflow for syncing changes between the OSS and monorepo.
2+
3+
MONOREPO_URL = "[email protected]:squareup/cash-server.git"
4+
OSS_REPO_URL = "[email protected]:cashapp/misk.git"
5+
6+
MONOREPO_BRANCH = "raine/misk-copybara" #main
7+
OSS_REPO_BRANCH = "raine/copybara-test" #master
8+
9+
MONOREPO_INCLUDES = ["misk/**"]
10+
MONOREPO_EXCLUDES = ["misk/copy.bara.sky", "misk/.buildkite/*"]
11+
12+
OSS_REPO_INCLUDES = ["**"]
13+
OSS_REPO_EXCLUDES = []
14+
15+
transforms = [
16+
core.move("", "misk", glob(["**"])),
17+
]
18+
19+
author = authoring.pass_thru("CashApp Copybara <[email protected]>")
20+
21+
# Push changes from the monorepo to the OSS repo
22+
core.workflow(
23+
name = "push",
24+
origin = git.origin(
25+
url = MONOREPO_URL,
26+
ref = MONOREPO_BRANCH,
27+
),
28+
origin_files = glob(MONOREPO_INCLUDES, exclude = MONOREPO_EXCLUDES),
29+
30+
destination = git.destination(
31+
url = OSS_REPO_URL,
32+
push = OSS_REPO_BRANCH,
33+
),
34+
destination_files = glob(OSS_REPO_INCLUDES, exclude = OSS_REPO_EXCLUDES),
35+
mode = "ITERATIVE",
36+
authoring = author,
37+
transformations = [
38+
metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
39+
#used when a PR is created in the OSS and we want to do a fake-merge
40+
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
41+
] + core.reverse(transforms),
42+
)
43+
44+
# Pull changes from the OSS to the monorepo (This is just for reference, the SoT is the monorepo)
45+
core.workflow(
46+
name = "pull",
47+
origin = git.origin(
48+
url = OSS_REPO_URL,
49+
ref = OSS_REPO_BRANCH,
50+
),
51+
origin_files = glob(OSS_REPO_INCLUDES, exclude = OSS_REPO_EXCLUDES),
52+
53+
destination = git.destination(
54+
url = MONOREPO_URL,
55+
push = MONOREPO_BRANCH,
56+
),
57+
destination_files = glob(MONOREPO_INCLUDES, exclude = MONOREPO_EXCLUDES),
58+
mode = "ITERATIVE",
59+
authoring = author,
60+
transformations = [
61+
metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
62+
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
63+
] + transforms,
64+
)

.buildkite/scripts/run_copybara

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
# Check if the workflow name is provided
6+
if [ "$#" -lt 1 ]; then
7+
echo "Usage: $0 <run_copybara workflow_name>"
8+
exit 1
9+
fi
10+
11+
WORKFLOW=$1
12+
echo "Running Copybara migration $WORKFLOW"
13+
../bin/copybara .buildkite/scripts/copy.bara.sky $WORKFLOW --git-committer-name Copybara \
14+
--git-committer-email [email protected]
15+
16+
# Check the exit status
17+
status=$?
18+
if [ $status -eq 4 ]; then
19+
echo "Copybara finished without changes made to the OSS repository."
20+
exit 0
21+
elif [ $status -ne 0 ]; then
22+
echo "Copybara failed with status $status."
23+
exit $status
24+
else
25+
echo "Copybara migration successful."
26+
exit 0
27+
fi

0 commit comments

Comments
 (0)