-
Notifications
You must be signed in to change notification settings - Fork 245
Optional S3 artifacts features #3663
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
Changes from all commits
2d5bd64
d1d858d
440cb88
9e50dda
0fceb67
9c69a35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script is only used by "CI", not "Multi-arch CI", and thus is scheduled for deletion (#3340). New feature work should be in https://github.com/ROCm/TheRock/blob/main/build_tools/github_actions/post_stage_upload.py
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless NPI pipelines are changed to work with multi-arch CI, such scripts that the older CI used cannot be deleted. A discussion on how multi-arch CI can intersect NPI pipelines is overdue. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,23 @@ | |
| [--run-id RUN_ID] | ||
| [--output-dir OUTPUT_DIR] | ||
| [--dry-run] | ||
| [--artifacts-bucket BUCKET] | ||
| [--path-prefix PREFIX] | ||
| [--summary-base-url URL] [--summary-path PREFIX] | ||
| [--skip-manifest] | ||
|
|
||
| Path/URL arguments (--path-prefix, --summary-base-url, --summary-path): | ||
| --path-prefix is the S3 key prefix for all outputs; --summary-path is the | ||
| corresponding prefix in the CDN URL used for job summary links. These let | ||
| private workflows place artifacts under a versioned subdirectory while | ||
| surfacing links through a CDN that maps a different path prefix. | ||
|
|
||
| Example: | ||
| --path-prefix v3/artifacts | ||
| --summary-base-url https://artifacts.example.com | ||
| --summary-path artifacts | ||
| # S3 key: s3://bucket/v3/artifacts/{run_id}-linux/... | ||
| # Summary: https://artifacts.example.com/artifacts/{run_id}-linux/... | ||
|
|
||
| This script runs after building TheRock, where this script does: | ||
| 1. Create log archives | ||
|
|
@@ -200,26 +217,39 @@ def write_gha_build_summary( | |
| build_dir: Path, | ||
| output_root: WorkflowOutputRoot, | ||
| job_status: str, | ||
| skip_manifest: bool = False, | ||
| summary_base_url: str = "", | ||
| summary_path: str = "", | ||
| ): | ||
| log(f"Adding links to job summary for {output_root.prefix}") | ||
|
|
||
| log_index_url = output_root.log_index(artifact_group).https_url | ||
| def _url(loc) -> str: | ||
| if summary_base_url: | ||
| return loc.cdn_url( | ||
| base_url=summary_base_url, | ||
| strip_prefix=output_root.path_prefix, | ||
| cdn_prefix=summary_path, | ||
| ) | ||
| return loc.https_url | ||
|
|
||
| log_index_url = _url(output_root.log_index(artifact_group)) | ||
| gha_append_step_summary(f"[Build Logs]({log_index_url})") | ||
|
|
||
| observability_path = build_dir / "logs" / "build_observability.html" | ||
| if observability_path.is_file(): | ||
| analysis_url = output_root.build_observability(artifact_group).https_url | ||
| analysis_url = _url(output_root.build_observability(artifact_group)) | ||
| gha_append_step_summary(f"[Build Observability]({analysis_url})") | ||
| else: | ||
| log("[INFO] Build Observability: Not generated") | ||
|
|
||
| # Only add artifact links if the job not failed | ||
| if not job_status or job_status == "success": | ||
| artifact_url = output_root.artifact_index(artifact_group).https_url | ||
| artifact_url = _url(output_root.artifact_index(artifact_group)) | ||
| gha_append_step_summary(f"[Artifacts]({artifact_url})") | ||
|
|
||
| manifest_url = output_root.manifest(artifact_group).https_url | ||
| gha_append_step_summary(f"[TheRock Manifest]({manifest_url})") | ||
| if not skip_manifest: | ||
| manifest_url = _url(output_root.manifest(artifact_group)) | ||
| gha_append_step_summary(f"[TheRock Manifest]({manifest_url})") | ||
|
|
||
|
|
||
| def run(args): | ||
|
|
@@ -235,7 +265,10 @@ def run(args): | |
| return | ||
|
|
||
| output_root = WorkflowOutputRoot.from_workflow_run( | ||
| run_id=args.run_id, platform=PLATFORM | ||
| run_id=args.run_id, | ||
| platform=PLATFORM, | ||
| bucket_override=args.artifacts_bucket or None, | ||
| path_prefix=args.path_prefix, | ||
| ) | ||
| backend = create_storage_backend(staging_dir=args.output_dir, dry_run=args.dry_run) | ||
|
|
||
|
|
@@ -249,14 +282,21 @@ def run(args): | |
| log("----------") | ||
| upload_logs(args.artifact_group, args.build_dir, output_root, backend) | ||
|
|
||
| log("Upload manifest") | ||
| log("----------------") | ||
| upload_manifest(args.artifact_group, args.build_dir, output_root, backend) | ||
| if not args.skip_manifest: | ||
| log("Upload manifest") | ||
| log("----------------") | ||
| upload_manifest(args.artifact_group, args.build_dir, output_root, backend) | ||
|
|
||
| log("Write github actions build summary") | ||
| log("--------------------") | ||
| write_gha_build_summary( | ||
| args.artifact_group, args.build_dir, output_root, args.job_status | ||
| args.artifact_group, | ||
| args.build_dir, | ||
| output_root, | ||
| args.job_status, | ||
| skip_manifest=args.skip_manifest, | ||
| summary_base_url=args.summary_base_url, | ||
| summary_path=args.summary_path, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -297,10 +337,44 @@ def run(args): | |
| action="store_true", | ||
| help="Print what would be uploaded without actually uploading", | ||
| ) | ||
| parser.add_argument( | ||
| "--artifacts-bucket", | ||
| type=str, | ||
| default="", | ||
| help="Override the S3 bucket for artifacts. If unset, the bucket is determined from repository/fork/release_type. Bucket permissions are enforced by AWS IAM.", | ||
| ) | ||
| parser.add_argument( | ||
| "--path-prefix", | ||
| type=str, | ||
| default="", | ||
| help="S3 key prefix for all outputs (e.g. 'v3/artifacts').", | ||
| ) | ||
| parser.add_argument( | ||
| "--summary-base-url", | ||
| type=str, | ||
| default="", | ||
| help="CDN base URL for job summary links (e.g. 'https://artifacts.example.com'). When set, summary links use this instead of the raw S3 URL.", | ||
| ) | ||
| parser.add_argument( | ||
| "--summary-path", | ||
| type=str, | ||
| default="", | ||
| help="CDN path prefix for summary links, corresponding to --path-prefix in storage (e.g. 'artifacts').", | ||
| ) | ||
|
Comment on lines
+358
to
+363
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either strip trailing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing |
||
| parser.add_argument( | ||
| "--skip-manifest", | ||
| action=argparse.BooleanOptionalAction, | ||
| default=False, | ||
| help="Skip manifest upload and omit the manifest link from the job summary.", | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| # Check preconditions for provided arguments before proceeding. | ||
|
|
||
| args.path_prefix = args.path_prefix.rstrip("/") | ||
| args.summary_base_url = args.summary_base_url.rstrip("/") | ||
| args.summary_path = args.summary_path.rstrip("/") | ||
|
|
||
| if args.upload: | ||
| if not args.run_id: | ||
| parser.error("when --upload is true, --run_id must also be set") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes overlap with more recent proposals: