forked from elide-dev/elide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy.bara.sky
207 lines (187 loc) · 6.19 KB
/
copy.bara.sky
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
buildtoolsRepo = "[email protected]:elide-dev/buildtools.git"
buildtoolsBranch = "update/upstream"
buildtoolsHttp = "https://github.com/elide-dev/buildtools"
protocolRepo = "[email protected]:elide-dev/protocol.git"
protocolBranch = "live"
protocolHttp = "https://github.com/elide-dev/protocol"
frameworkRepo = "https://github.com/elide-dev/v3"
frameworkBranch = "v3"
def github_source_status(workflow_name, ctx_url = None):
"""After a migration runs, let the source know with a commit status."""
return core.dynamic_feedback(
impl = _github_source_status_impl,
params = {
"botlabel": workflow_name,
"ctxurl": ctx_url,
},
)
def _github_source_status_impl(ctx):
src_ref = ctx.revision.labels["GIT_SHA1"][0]
ctx.console.info("Notifying source ref '%s' of Copybara run" % src_ref)
ctx.origin.create_status(
src_ref,
"success",
"copybara/%s" % ctx.params["botlabel"],
"Migration completed",
ctx.params["ctxurl"],
)
def github_source_notification():
"""After migration action that notifies in GitHub PRs the status of the import."""
return core.dynamic_feedback(
impl = _github_notification_impl,
params = {},
)
def _github_notification_impl(ctx):
ctx.console.info("Notifying GitHub about the import")
if "GITHUB_PR_NUMBER" in ctx.revision.labels:
pr_number = ctx.revision.labels["GITHUB_PR_NUMBER"][0]
for effect in ctx.effects:
if effect.type == "CREATED":
ctx.origin.post_issue_comment(int(pr_number), "Change synchronized by Copybara")
return
#
# WORKFLOWS
#
core.workflow(
name = "protocol",
origin = git.github_pr_origin(
url = frameworkRepo,
required_labels = ["migrate:protocol"],
),
destination = git.github_pr_destination(
url = protocolHttp,
destination_ref = "main",
title = "🤖 ${GITHUB_PR_TITLE} (PR ${GITHUB_PR_NUMBER})",
update_description = True,
body = (
"""Update `protocol` sources with the latest code from the [framework repository](https://github.com/elide-dev/v3).
Notes from each changed enclosed on the commit. The [original PR](https://github.com/elide-dev/v3/pulls/${GITHUB_PR_NUMBER}) body is enclosed below.
### Changeset info
- PR: elide-dev/v3#${GITHUB_PR_NUMBER}
- Author: `@${GITHUB_PR_USER}`
- Revision: `elide-dev/v3#${GITHUB_PR_HEAD_SHA}`
### Imported change
${GITHUB_PR_BODY}
"""
),
integrates = [],
),
origin_files = glob([
"proto/**/*.proto",
"proto/**/*.yaml",
"proto/README.md",
], exclude = [
# Nothing yet.
]),
destination_files = glob([
"elide/**/*.proto",
"elide/**/*.yaml",
], exclude = [
# Nothing yet.
]),
authoring = authoring.allowed(
default = "Elidebot <[email protected]>",
allowlist = [
],
),
transformations = [
metadata.save_author(),
metadata.restore_author(),
metadata.expose_label("COPYBARA_CONTEXT_REFERENCE"),
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
metadata.expose_label("GITHUB_PR_NUMBER", new_name = "Closes", separator = " #", ignore_label_not_found = True),
metadata.squash_notes(
prefix = "protocol: elide-dev/v3#${GITHUB_PR_NUMBER}\n\n",
max = 100,
compact = True,
show_ref = True,
show_author = True,
show_description = True,
oldest_first = False,
use_merge = True,
),
core.replace(
before = "${x}",
after = "",
multiline = True,
regex_groups = {
"x": "(?m)^.*BEGIN-INTERNAL[\\w\\W]*?END-INTERNAL.*$\\n",
},
),
core.move(before = "proto/", after = ""),
],
after_workflow = [
github_source_status("protocol", "https://github.com/elide-dev/protocol/pulls"),
],
)
core.workflow(
name = "buildtools",
origin = git.github_pr_origin(
url = frameworkRepo,
required_labels = ["migrate:buildtools"],
),
destination = git.github_pr_destination(
url = buildtoolsHttp,
pr_branch = "update/upstream",
destination_ref = "main",
title = "🤖 ${GITHUB_PR_TITLE} (PR ${GITHUB_PR_NUMBER})",
update_description = True,
body = (
"""Update `buildtools` sources with the latest code from the [framework repository](https://github.com/elide-dev/v3).
### Changeset info
- PR: elide-dev/v3#${GITHUB_PR_NUMBER}
- Author: `@${GITHUB_PR_USER}`
- Revision: `elide-dev/v3#${GITHUB_PR_HEAD_SHA}`
### Imported change
${GITHUB_PR_BODY}
"""
),
integrates = [],
),
origin_files = glob([
"tools/plugin/gradle/**/*.*",
], exclude = [
# Nothing yet.
]),
destination_files = glob([
"**/*.*",
], exclude = [
# Nothing yet.
]),
authoring = authoring.allowed(
default = "Elidebot <[email protected]>",
allowlist = [
],
),
transformations = [
metadata.save_author(),
metadata.restore_author(),
metadata.expose_label("COPYBARA_CONTEXT_REFERENCE"),
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
metadata.expose_label("GITHUB_PR_NUMBER", new_name = "Closes", separator = " #", ignore_label_not_found = True),
metadata.squash_notes(
prefix = "buildtools: elide-dev/v3#${GITHUB_PR_NUMBER}\n\n",
max = 100,
compact = True,
show_ref = True,
show_author = True,
show_description = True,
oldest_first = False,
use_merge = True,
),
core.replace(
before = "${x}",
after = "",
multiline = True,
regex_groups = {
"x": "(?m)^.*BEGIN-INTERNAL[\\w\\W]*?END-INTERNAL.*$\\n",
},
),
core.move(before = "tools/plugin/gradle", after = ""),
],
after_workflow = [
github_source_status("buildtools", "https://github.com/elide-dev/buildtools/pulls"),
],
)