Skip to content

Commit

Permalink
chore(IDX): simplify upload rule (#4003)
Browse files Browse the repository at this point in the history
This simplifies the `upload_artifact` rule implementation. This is
preparatory work before turning the build rule into a `bazel run`
command.
  • Loading branch information
nmattia authored Feb 21, 2025
1 parent 6878684 commit 5a20302
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
18 changes: 2 additions & 16 deletions ci/src/artifacts/upload.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def _upload_artifact_impl(ctx):
outputs = [checksum],
)

fileurl = []
allinputs = ctx.files.inputs + [checksum] if s3_upload else [checksum]
for f in allinputs:
filename = ctx.label.name + "_" + f.basename
Expand All @@ -54,25 +53,12 @@ def _upload_artifact_impl(ctx):
outputs = [url],
tools = [ctx.file._rclone],
)
fileurl.extend([url])
out.append(url)

urls = ctx.actions.declare_file(ctx.label.name + ".urls")
ctx.actions.run_shell(
command = "cat " + " ".join([url.path for url in fileurl]) + " >" + urls.path,
inputs = fileurl,
outputs = [urls],
)
out.append(urls)
out.extend(fileurl)

executable = ctx.actions.declare_file(ctx.label.name + ".bin")
ctx.actions.write(output = executable, content = "#!/bin/sh\necho;exec cat " + urls.short_path, is_executable = True)

return [DefaultInfo(files = depset(out), runfiles = ctx.runfiles(files = out), executable = executable)]
return [DefaultInfo(files = depset(out), runfiles = ctx.runfiles(files = out))]

_upload_artifacts = rule(
implementation = _upload_artifact_impl,
executable = True,
attrs = {
"inputs": attr.label_list(allow_files = True),
"remote_subdir": attr.string(mandatory = True),
Expand Down
1 change: 0 additions & 1 deletion ci/src/artifacts/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ AWS_PROFILE=cf "$RCLONE" \
--stats-one-line \
--checksum \
--immutable \
--s3-upload-cutoff=5G \
copy \
"$f" \
"public-s3-cf:dfinity-download-public/ic/${VERSION}/$REMOTE_SUBDIR/"
Expand Down

0 comments on commit 5a20302

Please sign in to comment.