Skip to content
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

WIP: packager #4304

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
78 changes: 39 additions & 39 deletions .github/workflows/deploy-lambdas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Deploy lambdas to S3 and ECR

on:
push:
branches:
- master
# branches:
# - master
paths:
- '.github/workflows/deploy-lambdas.yaml'
- 'lambdas/**'
Expand All @@ -13,15 +13,15 @@ jobs:
strategy:
matrix:
path:
- access_counts
- indexer
- pkgevents
# - access_counts
# - indexer
# - pkgevents
- pkgpush
- preview
- s3hash
- status_reports
- tabular_preview
- transcode
# - preview
# - s3hash
# - status_reports
# - tabular_preview
# - transcode
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
Expand Down Expand Up @@ -60,32 +60,32 @@ jobs:
s3_key="${{ matrix.path }}/${{ github.sha }}.zip"
./lambdas/scripts/upload_zip.sh ./out.zip "$AWS_REGION" "$s3_key"

deploy-lambda-ecr:
strategy:
matrix:
path:
- thumbnail
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Build Docker image
working-directory: ./lambdas/${{ matrix.path }}
run: docker buildx build -t "quiltdata/lambdas/${{ matrix.path }}:${{ github.sha }}" -f Dockerfile .
- name: Configure AWS credentials from Prod account
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::730278974607:role/github/GitHub-Quilt
aws-region: us-east-1
- name: Push Docker image to Prod ECR
run: ./lambdas/scripts/upload_ecr.sh 730278974607 "quiltdata/lambdas/${{ matrix.path }}:${{ github.sha }}"
- name: Configure AWS credentials from GovCloud account
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws-us-gov:iam::313325871032:role/github/GitHub-Quilt
aws-region: us-gov-east-1
- name: Push Docker image to GovCloud ECR
run: ./lambdas/scripts/upload_ecr.sh 313325871032 "quiltdata/lambdas/${{ matrix.path }}:${{ github.sha }}"
# deploy-lambda-ecr:
# strategy:
# matrix:
# path:
# - thumbnail
# runs-on: ubuntu-latest
# # These permissions are needed to interact with GitHub's OIDC Token endpoint.
# permissions:
# id-token: write
# contents: read
# steps:
# - uses: actions/checkout@v4
# - name: Build Docker image
# working-directory: ./lambdas/${{ matrix.path }}
# run: docker buildx build -t "quiltdata/lambdas/${{ matrix.path }}:${{ github.sha }}" -f Dockerfile .
# - name: Configure AWS credentials from Prod account
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: arn:aws:iam::730278974607:role/github/GitHub-Quilt
# aws-region: us-east-1
# - name: Push Docker image to Prod ECR
# run: ./lambdas/scripts/upload_ecr.sh 730278974607 "quiltdata/lambdas/${{ matrix.path }}:${{ github.sha }}"
# - name: Configure AWS credentials from GovCloud account
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: arn:aws-us-gov:iam::313325871032:role/github/GitHub-Quilt
# aws-region: us-gov-east-1
# - name: Push Docker image to GovCloud ECR
# run: ./lambdas/scripts/upload_ecr.sh 313325871032 "quiltdata/lambdas/${{ matrix.path }}:${{ github.sha }}"
19 changes: 19 additions & 0 deletions lambdas/pkgpush/src/t4_lambda_pkgpush/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
PackageConstructEntry,
PackageConstructParams,
PackagePromoteParams,
PackagePushParams,
PackagePushResult,
S3CopyLambdaParams,
S3HashLambdaParams,
Expand Down Expand Up @@ -527,3 +528,21 @@ def create_package(req_file: T.IO[bytes]) -> PackagePushResult:

# XXX: return mtime?
return PackagePushResult(top_hash=TopHash(top_hash))


class PackagePrefixParams(PackagePushParams):
prefix: str # XXX: validate with regex?


def package_prefix_sqs(event, context):
with setup_user_boto_session(boto3.Session()):
for record in event["Records"]:
params = PackagePrefixParams.parse_raw(record["body"])
pkg = quilt3.Package()
pkg.set_meta(params.user_meta or {})
pkg.set_dir(".", params.prefix)
pkg._build(
name=params.name,
registry=f"s3://{params.bucket}",
message=params.message,
)