Skip to content

Commit

Permalink
Merge pull request #55 from linuxserver/54-feat-use-release-tag-inste…
Browse files Browse the repository at this point in the history
…ad-of-latest-on-s3-to-split-up-branch-build-results

54 feat use release tag instead of latest on s3 to split up branch build results
  • Loading branch information
GilbN authored Sep 3, 2024
2 parents 15c0000 + a3bcd72 commit 375276d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ci/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(self) -> None:
self.ssl: str = os.environ.get("SSL", "false")
self.region: str = os.environ.get("S3_REGION", "us-east-1")
self.bucket: str = os.environ.get("S3_BUCKET", "ci-tests.linuxserver.io")
self.release_tag: str = os.environ.get("RELEASE_TAG", "latest")

if os.environ.get("DELAY_START"):
self.logger.warning("DELAY_START env is obsolete, and not in use anymore")
Expand All @@ -103,6 +104,7 @@ def __init__(self) -> None:
IMAGE: '{os.environ.get("IMAGE")}'
BASE: '{os.environ.get("BASE")}'
META_TAG: '{os.environ.get("META_TAG")}'
RELEASE_TAG: '{os.environ.get("RELEASE_TAG")}'
TAGS: '{os.environ.get("TAGS")}'
S6_VERBOSITY: '{os.environ.get("S6_VERBOSITY")}'
CI_S6_VERBOSITY '{os.environ.get("CI_S6_VERBOSITY")}'
Expand Down Expand Up @@ -674,18 +676,22 @@ def create_html_ansi_file(self, blob:str, tag:str, name:str, full:bool = True) -

@testing
def upload_file(self, file_path:str, object_name:str, content_type:dict) -> None:
"""Upload a file to an S3 bucket
"""Upload a file to an S3 bucket.
The file is uploaded to two directories in the bucket, one for the meta tag and one for the release tag.
e.g. `https://ci-tests.linuxserver.io/linuxserver/plex/1.40.5.8921-836b34c27-ls233/index.html` and `https://ci-tests.linuxserver.io/linuxserver/plex/latest/index.html`
Args:
file_path (str): File to upload
object_name (str): S3 object name.
content_type (dict): Content type for the file
"""
self.logger.info("Uploading %s to %s bucket",file_path, self.bucket)
destination_dir: str = f"{self.image}/{self.meta_tag}"
latest_dir: str = f"{self.image}/latest"
self.s3_client.upload_file(file_path, self.bucket, f"{destination_dir}/{object_name}", ExtraArgs=content_type)
self.s3_client.upload_file(file_path, self.bucket, f"{latest_dir}/{object_name}", ExtraArgs=content_type)
meta_dir: str = f"{self.image}/{self.meta_tag}"
release_dir: str = f"{self.image}/{self.release_tag}"
self.s3_client.upload_file(file_path, self.bucket, f"{meta_dir}/{object_name}", ExtraArgs=content_type)
self.s3_client.upload_file(file_path, self.bucket, f"{release_dir}/{object_name}", ExtraArgs=content_type)

def log_upload(self) -> None:
"""Upload the ci.log to S3
Expand Down
1 change: 1 addition & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ full_custom_readme: |
-e DOCKER_LOGS_TIMEOUT=<optional, How long to wait in seconds while tailing the container logs before timing out. Defaults to '120'> \
-e DRY_RUN=<optional, Set to 'true' when you don't want to upload files to S3 when testing> \
-e NODE_NAME=<optional, Name of the builder that runs the CI test.> \
-e RELEASE_TAG=<optional, The release tag of the docker image. Used for upload location. Defaults to 'latest'> \
-t lsiodev/ci:latest \
python3 test_build.py
```
Expand Down

0 comments on commit 375276d

Please sign in to comment.