Skip to content

Commit

Permalink
build and test prior to pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphall committed Oct 2, 2024
1 parent d449e98 commit fe796b1
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 95 deletions.
22 changes: 18 additions & 4 deletions .github/actions/build-container-local/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,36 @@ runs:

- name: Build and push Docker images
id: build-and-push
if: success()
if: success() && fromJSON(inputs.push_image)
uses: docker/build-push-action@v6
with:
#load: ${{ ! fromJSon(inputs.push_image) }}
#push: ${{ fromJSon(inputs.push_image) }}
context: ${{ inputs.context }}
platforms: ${{ inputs.platform }}
build-args: |
BASE_YUM_REPO=${{ inputs.osg_repo }}
BASE_OS=${{ inputs.base_os }}
BASE_OSG_SERIES=${{ inputs.osg_series }}
TIMESTAMP_IMAGE=${{ steps.generate-tags.outputs.ts_image }}
#tags: ${{ steps.generate-tags.outputs.tag_list }}
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
outputs: type=image,name=${{ steps.generate-tags.outputs.base_image }},push-by-digest=true,name-canonical=true,push=true

- name: Build Docker images
id: build
if: success() && !fromJSON(inputs.push_image)
uses: docker/build-push-action@v6
with:
load: true
push: false
context: ${{ inputs.context }}
platforms: ${{ inputs.platform }}
build-args: |
BASE_YUM_REPO=${{ inputs.osg_repo }}
BASE_OS=${{ inputs.base_os }}
BASE_OSG_SERIES=${{ inputs.osg_series }}
TIMESTAMP_IMAGE=${{ steps.generate-tags.outputs.ts_image }}
tags: ${{ steps.generate-tags.outputs.tag_list }}
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max

- name: Cache Docker images
if: success() && fromJSON(inputs.cache_image)
uses: actions/cache@v3
Expand Down
155 changes: 64 additions & 91 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ jobs:
platform=${{ matrix.platform }}
echo "platform=${platform//\//-}" >> ${GITHUB_OUTPUT}
- name: Harbor login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
uses: docker/login-action@v2
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}

- id: build-image
uses: ./.github/actions/build-container-local
with:
Expand All @@ -66,34 +55,9 @@ jobs:
osg_repo: ${{ matrix.repo }}
base_os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
push: false
output_image: ${{ steps.custom-image-name.outputs.output_image }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build-image.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

- name: Export tags
run: |
mkdir -p /tmp/tags
echo ${{ steps.build-image.outputs.image-list }} > /tmp/tags/${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
- name: Upload tags
uses: actions/upload-artifact@v4
with:
name: tags-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/tags/*
if-no-files-found: error
retention-days: 1

- name: Prepare CVMFS
# if: ${{ matrix.platform == 'linux/amd64' }}
Expand All @@ -104,7 +68,7 @@ jobs:
# if: ${{ matrix.platform == 'linux/amd64' }}
id: test-docker-cvmfs
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}@${{ steps.build-image.outputs.digest }}
CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}:latest
run: |
sudo ./tests/test_inside_gha.sh docker \
bindmount \
Expand All @@ -114,37 +78,37 @@ jobs:
# if: ${{ matrix.platform == 'linux/amd64' }}
id: test-docker-cvmfsexec
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}@${{ steps.build-image.outputs.digest }}
CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}:latest
run: |
sudo ./tests/test_inside_gha.sh docker \
cvmfsexec \
"$CONTAINER_IMAGE"
# - name: Singularity + CVMFS bindmount
# if: ${{ matrix.platform == 'linux/amd64' }}
# id: test-singularity-cvmfs
# env:
# CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}@${{ steps.build-image.outputs.digest }}
# run: |
# if [[ $CONTAINER_IMAGE == *cuda* ]]; then
# echo >&2 "Skipping test: \$APPTAINER_TMPDIR (${APPTAINER_TMPDIR:-/tmp}) too small for cuda-based images"
# exit 0
# else
# sudo ./tests/test_inside_gha.sh singularity \
# bindmount \
# "$CONTAINER_IMAGE"
# fi
- name: Singularity + CVMFS bindmount
if: ${{ matrix.platform == 'linux/amd64' }}
id: test-singularity-cvmfs
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}:latest
run: |
if [[ $CONTAINER_IMAGE == *cuda* ]]; then
echo >&2 "Skipping test: \$APPTAINER_TMPDIR (${APPTAINER_TMPDIR:-/tmp}) too small for cuda-based images"
exit 0
else
sudo ./tests/test_inside_gha.sh singularity \
bindmount \
"$CONTAINER_IMAGE"
fi
# - name: Harbor login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
# uses: docker/login-action@v2
# with:
# registry: hub.opensciencegrid.org
# username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
# password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
- name: Harbor login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
uses: docker/login-action@v2
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}

# - name: Docker login
# if: >-
Expand All @@ -157,35 +121,44 @@ jobs:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Push to OSG Harbor
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
# env:
# IMAGE_LIST: ${{ steps.build-image.outputs.image-list}}
# OSG_SERIES: ${{ matrix.osg_series }}
# run: |
# case $OSG_SERIES in
# '23' ) DEFAULT_OS=el9 ;;
# * ) exit ;;
# esac
# for registry in hub.opensciencegrid.org docker.io; do
# for image in ${IMAGE_LIST}; do
# fqin=${registry}/${image}
# docker tag ${image} ${fqin}
# docker push ${fqin}

# # Also tag the image for the default OS as the OS-less tag
# # (i.e. 23-el9-release -> 23-release)
# image2=${image/-${DEFAULT_OS}-/-} # bash syntax for search-and-replace
# if [[ $image2 != $image ]]; then
# fqin2=${registry}/${image2}
# docker tag ${image} ${fqin2}
# docker push ${fqin2}
# fi
# done
# done
- id: upload-image
uses: ./.github/actions/build-container-local
with:
registry_url: hub.opensciencegrid.org
osg_series: ${{ matrix.osg_series }}
osg_repo: ${{ matrix.repo }}
base_os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
push: true
output_image: ${{ steps.custom-image-name.outputs.output_image }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.upload-image.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

- name: Export tags
run: |
mkdir -p /tmp/tags
echo ${{ steps.upload-image.outputs.image-list }} > /tmp/tags/${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
- name: Upload tags
uses: actions/upload-artifact@v4
with:
name: tags-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/tags/*
if-no-files-found: error
retention-days: 1

merge-manifests:
runs-on: ubuntu-latest
Expand Down

0 comments on commit fe796b1

Please sign in to comment.