Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fb8e05f
Rebase
erman-gurses May 16, 2025
2913a73
Test parametarized upload_logs_to_s3.py fir linux
erman-gurses May 15, 2025
d809137
Black
erman-gurses May 15, 2025
6e9aa8d
Add script usage for Windows Upload Logs
erman-gurses May 15, 2025
b61b4a3
Temporary disable build and add fake log for faster iter
erman-gurses May 15, 2025
2e0c17d
Update the commands for fake logs
erman-gurses May 15, 2025
b286cfc
Revert back for cmake original
erman-gurses May 15, 2025
3966f7f
Revert back for cmake original for linux
erman-gurses May 15, 2025
da15453
Update create log index for windows
erman-gurses May 15, 2025
6fb5913
Update Add Links to Job Summary
erman-gurses May 15, 2025
0ff4a6d
Convert script type from Windows to Linux on the workflow
erman-gurses May 16, 2025
69378cf
Add correct path for windows artifacts
erman-gurses May 16, 2025
41a3b90
Temporary add always for Artifacts uploading
erman-gurses May 16, 2025
eacea5b
Revert always for Artifacts uploading
erman-gurses May 16, 2025
b5f5e92
Remove local comments
erman-gurses May 16, 2025
82f1c48
Update If statement
erman-gurses May 16, 2025
dd62589
Update parameter types and logic based on that
erman-gurses May 16, 2025
2d3efa4
Keep s3_destination as string
erman-gurses May 16, 2025
1df6f36
Add more informative log message with parameter
erman-gurses May 16, 2025
1365e59
Add root dir to avoid confusion
erman-gurses May 16, 2025
82c574d
Update variable name that fits with logic
erman-gurses May 16, 2025
98f645e
Add TODO for indexer.py
erman-gurses May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions .github/workflows/build_linux_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ on:
expect_failure:
type: boolean

# See the details regarding permissions from the link:
# https://github.com/aws-actions/configure-aws-credentials?tab=readme-ov-file#oidc
permissions:
contents: read

Expand Down Expand Up @@ -122,20 +124,23 @@ jobs:
key: linux-build-packages-manylinux-v2-${{ github.sha }}

- name: Configure AWS Credentials
if: always()
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-artifacts

# TODO: Move to script
- name: Create Index Files
if: always()
Comment thread
marbre marked this conversation as resolved.
Outdated
run: |
curl --silent --fail --show-error --location \
https://raw.githubusercontent.com/joshbrunty/Indexer/6d8cbfd15d3853b482e6a49f2d875ded9188b721/indexer.py \
--output build/indexer.py
python build/indexer.py -f '*.tar.xz*' build/artifacts/
python build/indexer.py -f '*.log' build/logs/
sed -i 's,a href="..",a href="../../index-${{env.AMDGPU_FAMILIES}}.html",g' build/logs/index.html
python3 build_tools/create_log_index.py \
--build-dir=build \
--amdgpu-family=${{ env.AMDGPU_FAMILIES }}

# TODO: Move to script
- name: Upload Artifacts
Expand All @@ -146,17 +151,24 @@ jobs:
--include "*.tar.xz*"
aws s3 cp build/artifacts/index.html s3://therock-artifacts/${{github.run_id}}-linux/index-${{env.AMDGPU_FAMILIES}}.html

# TODO: Move to script
- name: Upload Logs
if: always()
run: |
aws s3 cp build/logs/ s3://therock-artifacts/${{github.run_id}}-linux/logs/${{env.AMDGPU_FAMILIES}}/ \
--recursive \
--content-type="text/plain" \
--exclude "*" \
--include "*.log"
aws s3 cp build/logs/index.html s3://therock-artifacts/${{github.run_id}}-linux/logs/${{env.AMDGPU_FAMILIES}}/
python3 build_tools/upload_logs_to_s3.py \
--build-dir=build \
--s3-base-path="s3://therock-artifacts/${{github.run_id}}-linux/logs/${{env.AMDGPU_FAMILIES}}"

- name: Add Links to Job Summary
Comment thread
marbre marked this conversation as resolved.
Outdated
if: always()
run: |
echo '* [Artifacts](https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-linux/index-${{env.AMDGPU_FAMILIES}}.html)' >> $GITHUB_STEP_SUMMARY
echo '* [Build logs](https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-linux/logs/${{env.AMDGPU_FAMILIES}}/index.html)' >> $GITHUB_STEP_SUMMARY
LOG_URL="https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-linux/logs/${{env.AMDGPU_FAMILIES}}/index.html"
echo "[Build Logs](${LOG_URL})" >> $GITHUB_STEP_SUMMARY

ARTIFACT_INDEX=build/artifacts/index.html
if [ -f "${ARTIFACT_INDEX}" ]; then
ARTIFACT_URL="https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-linux/index-${{env.AMDGPU_FAMILIES}}.html"

echo "[Artifacts](${ARTIFACT_URL})" >> $GITHUB_STEP_SUMMARY
else
echo "[INFO] No artifacts index found. Skipping artifact link."
fi
32 changes: 21 additions & 11 deletions .github/workflows/build_windows_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,23 @@ jobs:
get-disk | Select-object @{Name="Size(GB)";Expression={$_.Size/1GB}} | Write-Host

- name: Configure AWS Credentials
if: always()
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-artifacts

# TODO: Move to script
- name: Create Index Files
if: always()
run: |
curl --silent --fail --show-error --location \
https://raw.githubusercontent.com/joshbrunty/Indexer/6d8cbfd15d3853b482e6a49f2d875ded9188b721/indexer.py \
--output ${{ env.BUILD_DIR_BASH }}/indexer.py
python ${{ env.BUILD_DIR_BASH }}/indexer.py -f '*.tar.xz*' ${{ env.BUILD_DIR_BASH }}/artifacts/
python ${{ env.BUILD_DIR_BASH }}/indexer.py -f '*.log' ${{ env.BUILD_DIR_BASH }}/logs/
sed -i 's,a href="..",a href="../../index-${{env.AMDGPU_FAMILIES}}.html",g' ${{ env.BUILD_DIR_BASH }}/logs/index.html
python build_tools/create_log_index.py \
--build-dir=${{ env.BUILD_DIR_BASH }} \
--amdgpu-family=${{ env.AMDGPU_FAMILIES }}

# TODO: Move to script
- name: Upload Artifacts
Expand All @@ -223,19 +226,26 @@ jobs:
--include "*.tar.xz*"
aws s3 cp ${{ env.BASE_BUILD_DIR_POWERSHELL }}\artifacts\index.html s3://therock-artifacts/${{github.run_id}}-windows/index-${{env.AMDGPU_FAMILIES}}.html

# TODO: Move to script
- name: Upload Logs
if: always()
shell: powershell
run: |
$Env:PATH += ";C:\Program Files\Amazon\AWSCLIV2"
aws s3 cp ${{ env.BASE_BUILD_DIR_POWERSHELL }}\logs s3://therock-artifacts/${{github.run_id}}-windows/logs/${{env.AMDGPU_FAMILIES}}/ `
--recursive `
--content-type="text/plain" `
--exclude "*" `
--include "*.log"
aws s3 cp ${{ env.BASE_BUILD_DIR_POWERSHELL }}\logs\index.html s3://therock-artifacts/${{github.run_id}}-windows/logs/${{env.AMDGPU_FAMILIES}}/
python3 build_tools/upload_logs_to_s3.py `
--build-dir=${{ env.BASE_BUILD_DIR_POWERSHELL }} `
--s3-base-path="s3://therock-artifacts/${{github.run_id}}-windows/logs/${{env.AMDGPU_FAMILIES}}"

- name: Add Links to Job Summary
if: always()
run: |
echo '* [Artifacts](https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-windows/index-${{env.AMDGPU_FAMILIES}}.html)' >> $GITHUB_STEP_SUMMARY
echo '* [Build logs](https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-windows/logs/${{env.AMDGPU_FAMILIES}}/index.html)' >> $GITHUB_STEP_SUMMARY
LOG_URL="https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-windows/logs/${{env.AMDGPU_FAMILIES}}/index.html"
echo "[Build Logs](${LOG_URL})" >> $GITHUB_STEP_SUMMARY

ARTIFACT_INDEX="${{ env.BASE_BUILD_DIR_POWERSHELL }}/artifacts/index.html"
if [ -f "${ARTIFACT_INDEX}" ]; then
ARTIFACT_URL="https://therock-artifacts.s3.us-east-2.amazonaws.com/${{github.run_id}}-windows/index-${{env.AMDGPU_FAMILIES}}.html"

echo "[Artifacts](${ARTIFACT_URL})" >> $GITHUB_STEP_SUMMARY
else
echo "[INFO] No artifacts index found. Skipping artifact link."
fi
75 changes: 75 additions & 0 deletions build_tools/create_log_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python3

import os
import subprocess
from pathlib import Path
import sys
import platform
import argparse


def log(*args):
print(*args)
sys.stdout.flush()


def is_windows():
return platform.system().lower() == "windows"


def normalize_path(p: Path) -> str:
return str(p).replace("\\", "/") if is_windows() else str(p)
Comment on lines +20 to +21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably use as_posix() here instead of defining a new helper function, if the indexer script really needs a unix style path. Fine as-is for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh - did not know that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of forking indexer.py I propose to rather implement a solution based on boto3 which can then be used in an AWS Lambda.



def index_log_files(build_dir: Path, amdgpu_family: str):
log_dir = build_dir / "logs"
index_file = log_dir / "index.html"

# TODO: Fork indexer.py locally to avoid relying on an external GitHub source at runtime.
indexer_path = build_dir / "indexer.py"
Comment thread
erman-gurses marked this conversation as resolved.

if log_dir.is_dir():
log(f"[INFO] Found '{log_dir}' directory. Indexing '*.log' files...")
subprocess.run(
["python", str(indexer_path), "-f", "*.log", normalize_path(log_dir)],
check=True,
)
else:
log(f"[WARN] Log directory '{log_dir}' not found. Skipping indexing.")
return

if index_file.exists():
log(
f"[INFO] Rewriting links in '{index_file}' with AMDGPU_FAMILIES={amdgpu_family}..."
)
content = index_file.read_text()
updated = content.replace(
'a href=".."', f'a href="../../index-{amdgpu_family}.html"'
)
Comment thread
erman-gurses marked this conversation as resolved.
Outdated
index_file.write_text(updated)
log("[INFO] Log index links updated.")
else:
log(f"[WARN] '{index_file}' not found. Skipping link rewrite.")


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create HTML index for log files.")
parser.add_argument(
"--build-dir",
type=Path,
default=Path(os.getenv("BUILD_DIR", "build")),
help="Build directory containing logs (default: 'build' or $BUILD_DIR)",
)
parser.add_argument(
"--amdgpu-family",
type=str,
default=os.getenv("AMDGPU_FAMILIES"),
help="AMDGPU family name (default: $AMDGPU_FAMILIES)",
)
args = parser.parse_args()

if not args.amdgpu_family:
log("[ERROR] --amdgpu-family not provided and AMDGPU_FAMILIES env var not set")
sys.exit(1)

index_log_files(args.build_dir, args.amdgpu_family)
92 changes: 92 additions & 0 deletions build_tools/upload_logs_to_s3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
"""
upload_logs_to_s3.py

Uploads log files and index.html to an S3 bucket using the AWS CLI.
"""

import os
Comment thread
marbre marked this conversation as resolved.
Outdated
import sys
import glob
import shutil
import argparse
import subprocess
from pathlib import Path


def log(*args, **kwargs):
print(*args, **kwargs)
sys.stdout.flush()


def check_aws_cli_available():
if not shutil.which("aws"):
log("[ERROR] AWS CLI not found in PATH.")
sys.exit(1)


def run_aws_cp(source_path: Path, s3_destination: str, content_type: str = None):
if source_path.is_dir():
cmd = ["aws", "s3", "cp", str(source_path), s3_destination, "--recursive"]
else:
cmd = ["aws", "s3", "cp", str(source_path), s3_destination]

if content_type:
cmd += ["--content-type", content_type]
try:
log(f"[INFO] Running: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
log(f"[ERROR] Failed to upload {source_path} to {s3_destination}: {e}")


def upload_logs_to_s3(s3_base_path: str, build_dir: Path):
log_dir = build_dir / "logs"

if not log_dir.is_dir():
log(f"[INFO] Log directory {log_dir} not found. Skipping upload.")
return

# Upload .log files
log_files = list(log_dir.glob("*.log"))
if not log_files:
log("[WARN] No .log files found. Skipping log upload.")
else:
run_aws_cp(log_dir, s3_base_path, content_type="text/plain")

# Upload index.html
index_path = log_dir / "index.html"
if index_path.is_file():
index_s3_dest = f"{s3_base_path}/index.html"
run_aws_cp(index_path, index_s3_dest, content_type="text/html")
log(f"[INFO] Uploaded {index_path} to {index_s3_dest}")
else:
log(f"[INFO] No index.html found at {log_dir}. Skipping index upload.")


def main():
check_aws_cli_available()

repo_root = Path(__file__).resolve().parent.parent
default_build_dir = repo_root / "build"

parser = argparse.ArgumentParser(description="Upload logs to S3.")
parser.add_argument(
"--build-dir",
type=Path,
default=default_build_dir,
help="Path to the build directory (default: <repo_root>/build)",
)
parser.add_argument(
"--s3-base-path",
type=str,
required=True,
help="Base S3 path to upload logs to, e.g. s3://bucket/run-id-platform/logs/family",
)
args = parser.parse_args()

upload_logs_to_s3(args.s3_base_path, args.build_dir)


if __name__ == "__main__":
main()
Loading