diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 988a216..866e7d9 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -7,31 +7,6 @@ on: - main jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install black mypy types-requests types-boto3 - - - name: Run mypy - run: | - mypy ./publish_artifacts.py - - - name: Run black - run: | - black --check --diff ./publish_artifacts.py - - unit-test: runs-on: ubuntu-latest steps: diff --git a/action.yml b/action.yml index b97bfc2..fd09da7 100644 --- a/action.yml +++ b/action.yml @@ -15,27 +15,26 @@ inputs: runs: using: "composite" steps: - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.13' - - - name: Cache Python dependencies - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('${{ github.action_path }}/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + - name: Ensure AWS CLI is available + shell: bash + run: | + if ! command -v aws &> /dev/null; then + echo "Installing AWS CLI..." + apt-get update && apt-get install -y awscli + else + echo "AWS CLI is already available." + fi - - name: Install dependencies + - name: Check AWS credentials shell: bash - run: pip install -r ${{ github.action_path }}/requirements.txt + run: | + if ! aws sts get-caller-identity &> /dev/null; then + echo "AWS credentials are missing or invalid." + exit 1 + fi - name: Upload artifacts shell: bash run: | - python ${{ github.action_path }}/publish_artifacts.py \ - --path "${{ inputs.path }}" \ - --destination "${{ inputs.destination }}" \ - --s3-bucket "${{ inputs.s3_bucket }}" + aws s3 cp "${{ inputs.path }}" "s3://${{ inputs.s3_bucket }}/${{ inputs.destination }}" --recursive + diff --git a/publish_artifacts.py b/publish_artifacts.py deleted file mode 100755 index 54b7e62..0000000 --- a/publish_artifacts.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. -# SPDX-License-Identifier: BSD-3-Clause - -import argparse -import boto3 -import os - - -class S3Uploader: - def __init__(self, bucket_name: str): - self.bucket_name = bucket_name - self.client = boto3.client("s3") - - def _upload_file(self, file_path: str, destination: str) -> None: - self.client.upload_file(file_path, self.bucket_name, destination) - print(f"Uploaded to S3: s3://{self.bucket_name}/{destination}") - - def upload(self, dir_path: str, destination: str) -> None: - for root, _, files in os.walk(dir_path): - for file in files: - local_path = os.path.join(root, file) - relative_path = os.path.relpath(local_path, dir_path) - s3_path = os.path.join(destination, relative_path).replace("\\", "/") - self._upload_file(local_path, s3_path) - - -def main(): - parser = argparse.ArgumentParser( - description="Upload folders to a target destination" - ) - parser.add_argument("--path", required=True, help="Path to folder to upload") - parser.add_argument( - "--destination", required=True, help="Destination path in target storage" - ) - parser.add_argument("--s3-bucket", required=True, help="S3 bucket name") - args = parser.parse_args() - - uploader = S3Uploader(bucket_name=args.s3_bucket) - uploader.upload(args.path, args.destination) - - -if __name__ == "__main__": - main() diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 42e0190..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -boto3==1.40.5 \ No newline at end of file