Skip to content

SOFTWARE-6027: Add osg 24 to build matrix #412

SOFTWARE-6027: Add osg 24 to build matrix

SOFTWARE-6027: Add osg 24 to build matrix #412

---
name: Build release series tagged images
on:
push:
branches:
- master
pull_request:
branches:
- '**'
repository_dispatch:
types:
- dispatch-build
workflow_dispatch:
jobs:
base-image-build:
name: xcache:${{ matrix.osg_series.name }}-${{ matrix.repo }} image build
runs-on: ubuntu-latest
strategy:
fail-fast: False
matrix:
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
- name: '24'
os: 'el9'
steps:
- uses: actions/checkout@v3
- name: Cache base image
uses: actions/cache@v3
with:
path: /tmp/.base-buildx-cache
key: base-${{ matrix.osg_series.name }}-${{ matrix.repo }}-buildx-${{ github.sha }}-${{ github.run_id }}
# allow cache hits from previous runs of the current branch,
# parent branch, then upstream branches, in that order
restore-keys: |
base-${{ matrix.osg_series.name }}-${{ matrix.repo }}-buildx-
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
pull: True
target: xcache
cache-to: type=local,dest=/tmp/.base-buildx-cache,mode=max
xcache-image-builds:
name: ${{ matrix.image }}:${{ matrix.osg_series.name }}-${{ matrix.repo }} image build
needs: [base-image-build]
strategy:
fail-fast: False
matrix:
image: [atlas-xcache, cms-xcache, stash-cache, stash-origin]
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load cached base image
uses: actions/cache@v3
with:
path: /tmp/.base-buildx-cache
key: base-${{ matrix.osg_series.name }}-${{ matrix.repo }}-buildx-${{ github.sha }}-${{ github.run_id }}
- name: Cache child image
uses: actions/cache@v3
with:
path: /tmp/.${{ matrix.image }}-buildx-cache
key: ${{ matrix.image}}-${{matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
target: ${{ matrix.image }}
cache-from: type=local,src=/tmp/.base-buildx-cache
cache-to: type=local,dest=/tmp/.${{ matrix.image }}-buildx-cache,mode=max
test-stash-cache:
name: Test Stash Cache and Origin
needs: [xcache-image-builds]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.repo == 'development' }}
strategy:
fail-fast: False
matrix:
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
steps:
- uses: actions/checkout@v3
- name: Load stash-cache build cache
uses: actions/cache@v3
with:
path: /tmp/.stash-cache-buildx-cache
key: stash-cache-${{ matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Load stash-origin build cache
uses: actions/cache@v3
with:
path: /tmp/.stash-origin-buildx-cache
key: stash-origin-${{ matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Load stash-cache image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
load: True # allow access to built images through the Docker CLI
tags: stash-cache:latest
target: stash-cache
cache-from: type=local,src=/tmp/.stash-cache-buildx-cache
- name: Load stash-origin image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
load: True # allow access to built images through the Docker CLI
tags: stash-origin:latest
target: stash-origin
cache-from: type=local,src=/tmp/.stash-origin-buildx-cache
- run: ./tests/test_stashcache_origin.sh "stash-origin:latest"
- run: ./tests/test_stashcache.sh "stash-cache:latest"
make-date-tag:
runs-on: ubuntu-latest
if: contains(fromJson('["push", "repository_dispatch", "workflow_dispatch"]'), github.event_name) && startsWith(github.repository, 'opensciencegrid/')
outputs:
dtag: ${{ steps.mkdatetag.outputs.dtag }}
steps:
- name: make date tag
id: mkdatetag
run: echo "dtag=$(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT
push-images:
name: Push ${{ matrix.image }}:${{ matrix.osg_series.name }}-${{ matrix.repo }} image
if: contains(fromJson('["push", "repository_dispatch", "workflow_dispatch"]'), github.event_name) && startsWith(github.repository, 'opensciencegrid/')
strategy:
fail-fast: False
matrix:
image: [atlas-xcache, cms-xcache, stash-cache, stash-origin, xcache]
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
needs: [make-date-tag, test-stash-cache]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load cached child image
uses: actions/cache@v3
with:
path: /tmp/.${{ matrix.image }}-buildx-cache
key: ${{ matrix.image}}-${{ matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Generate tag list
id: generate-tag-list
env:
REPO: ${{ matrix.repo }}
SERIES: ${{ matrix.osg_series.name }}
IMAGE: ${{ matrix.image }}
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }}
run: |
docker_repo=opensciencegrid/$IMAGE
tag_list=()
for registry in hub.opensciencegrid.org docker.io; do
for image_tag in "$SERIES-$REPO" "$SERIES-$REPO-$TIMESTAMP"; do
tag_list+=("$registry/$docker_repo":"$image_tag")
done
done
# This causes the tag_list array to be comma-separated below,
# which is required for build-push-action
IFS=,
echo "taglist=${tag_list[*]}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to OSG Harbor
uses: docker/[email protected]
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
- name: Build ${{ matrix.image}} image
uses: docker/build-push-action@v4
with:
context: .
push: True
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
tags: "${{ steps.generate-tag-list.outputs.taglist }}"
target: ${{ matrix.image }}
cache-from: type=local,src=/tmp/.${{ matrix.image }}-buildx-cache