Skip to content

Commit d3fe57a

Browse files
Publish refs from spack-packages. clone_spack handle split repo
1 parent aeea58f commit d3fe57a

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

images/protected-publish/pkg/common.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
SPACK_REPO = "https://github.com/spack/spack"
18+
PACKAGES_REPO = "https://github.com/spack/spack-packages"
1819

1920
TIMESTAMP_AND_SIZE = r"^[\d]{4}-[\d]{2}-[\d]{2}\s[\d]{2}:[\d]{2}:[\d]{2}\s+\d+\s+"
2021
TIMESTAMP_PATTERN = "%Y-%m-%d %H:%M:%S"
@@ -188,12 +189,16 @@ def extract_json_from_clearsig(file_path):
188189
# clone the matching version of spack.
189190
#
190191
# Clones the version of spack specified by ref to the root of the file system
191-
def clone_spack(ref: str = "develop", repo: str = SPACK_REPO, clone_dir: str = "/"):
192+
def clone_spack(spack_ref: str = "develop", packages_ref: str = "develop", spack_repo: str = SPACK_REPO, packages_repo: str = PACKAGES_REPO, clone_dir: str = "/"):
192193
spack_path = f"{clone_dir}/spack"
194+
packages_path = f"{clone_dir}/spack-packages"
193195

194196
if os.path.isdir(spack_path):
195197
shutil.rmtree(spack_path)
196198

199+
if os.path.isdir(packages_path):
200+
shutil.rmtree(packages_path)
201+
197202
owd = os.getcwd()
198203

199204
try:
@@ -206,8 +211,35 @@ def clone_spack(ref: str = "develop", repo: str = SPACK_REPO, clone_dir: str = "
206211
"1",
207212
"--single-branch",
208213
"--branch",
209-
f"{ref}",
210-
f"{repo}",
214+
f"{spack_ref}",
215+
f"{spack_repo}",
216+
spack_path,
217+
],
218+
check=True,
219+
)
220+
subprocess.run(
221+
[
222+
"git",
223+
"clone",
224+
"--depth",
225+
"1",
226+
"--single-branch",
227+
"--branch",
228+
f"{packages_ref}",
229+
f"{packages_repo}",
230+
packages_path,
231+
],
232+
check=True,
233+
)
234+
# Configure the repo destination
235+
subprocess.run(
236+
[
237+
"spack/bin/spack",
238+
"repo",
239+
"set",
240+
"builtin",
241+
"--destination",
242+
packages_path,
211243
],
212244
check=True,
213245
)

images/protected-publish/pkg/publish.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,14 @@ def publish(
280280
print("Publishing complete")
281281

282282
# Clone spack version appropriate to what we're publishing
283-
clone_spack(ref, clone_dir=workdir)
283+
clone_spack(packages_ref=ref, clone_dir=workdir)
284284
spack_exe = f"{workdir}/spack/bin/spack"
285285

286286
# Can be useful for testing to clone a custom spack to somewhere other than "/"
287287
# clone_spack(
288-
# ref="content-addressable-tarballs-2",
289-
# repo="https://github.com/scottwittenburg/spack.git",
288+
# packages_ref=ref,
289+
# spack_ref="content-addressable-tarballs-2",
290+
# spack_repo="https://github.com/scottwittenburg/spack.git",
290291
# clone_dir=workdir,
291292
# )
292293
# spack_exe = f"{workdir}/spack/bin/spack"
@@ -641,7 +642,7 @@ def main():
641642
parser.add_argument(
642643
"-r",
643644
"--ref",
644-
default="develop",
645+
action="append",
645646
help=(
646647
"A single protected ref to publish, or else 'recent', to "
647648
"publish any protected refs that had a pipeline recently"
@@ -690,10 +691,18 @@ def main():
690691

691692
args = parser.parse_args()
692693

693-
if args.ref == "recent":
694+
refs = []
695+
if not args.ref:
696+
refs = ["develop"]
697+
698+
if "recent" in args.ref:
694699
refs = get_recently_run_protected_refs(args.days)
695-
else:
696-
refs = [args.ref]
700+
args.ref.remove("recent")
701+
702+
if args.ref:
703+
refs.extend(list(args.ref))
704+
print(args.ref)
705+
print(refs)
697706

698707
exceptions = []
699708

0 commit comments

Comments
 (0)