-
Notifications
You must be signed in to change notification settings - Fork 0
DM-33936: Create GHAs to build containers and run unit tests. #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6df23be
Remove null workflow.
ktlim 3865b2e
Add base container build GHA.
ktlim ba3281e
Add Google Artifact Registry.
ktlim aae20e3
Rebuild only if source modified.
ktlim 4696e98
Add service build workflow.
ktlim 8aa18d9
Reorder to get GAR credentials.
ktlim 381bd12
Use scons to test in separate job.
ktlim 4209622
Document push destination.
ktlim 864f9d6
Use GitHub as source rather than Google.
ktlim 81c84b3
Use branch name for PRs instead of merge.
ktlim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
name: "Build base" | ||
on: | ||
push: | ||
paths: | ||
- '.github/workflows/build-base.yml' | ||
- 'python/base/**' | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- '.github/workflows/build-base.yml' | ||
- 'python/base/**' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
update-base-image: | ||
name: Update base image | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_NAME: prompt-proto-base | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Build image | ||
run: docker build python/base --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Push image to GitHub Container Registry | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "merge" ] && VERSION=$(echo "${{ github.head_ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
- name: Login to Google Artifact Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: us-central1-docker.pkg.dev | ||
username: _json_key_base64 | ||
password: ${{ secrets.GAR_JSON_B64 }} | ||
- name: Push image to Google Artifact Registry | ||
run: | | ||
IMAGE_ID=us-central1-docker.pkg.dev/prompt-proto/prompt/$IMAGE_NAME | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "merge" ] && VERSION=$(echo "${{ github.head_ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
name: "Build and test service" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/build-service.yml' | ||
- 'python/activator/**' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/build-service.yml' | ||
- 'python/activator/**' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
test-service: | ||
name: Test service | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Fix permissions | ||
run: chmod -R a+rwX $GITHUB_WORKSPACE | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Run tests | ||
run: | | ||
docker run \ | ||
-v $GITHUB_WORKSPACE:/home/lsst/prompt_prototype \ | ||
ghcr.io/${{ github.repository_owner }}/prompt-proto-base:latest \ | ||
bash -c ' | ||
cd /home/lsst/prompt_prototype | ||
source /opt/lsst/software/stack/loadLSST.bash | ||
setup -r . | ||
scons' | ||
|
||
update-service-image: | ||
name: Update service image | ||
needs: test-service | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_NAME: prompt-proto-service | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build image | ||
run: docker build python/activator --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | ||
- name: Push image to GitHub Container Registry | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "merge" ] && VERSION=$(echo "${{ github.head_ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
- name: Login to Google Artifact Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: us-central1-docker.pkg.dev | ||
username: _json_key_base64 | ||
password: ${{ secrets.GAR_JSON_B64 }} | ||
- name: Push image to Google Artifact Registry | ||
run: | | ||
IMAGE_ID=us-central1-docker.pkg.dev/prompt-proto/prompt/$IMAGE_NAME | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "merge" ] && VERSION=$(echo "${{ github.head_ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.