Skip to content

Commit

Permalink
ci: Test published container images
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Aug 17, 2024
1 parent 0d551d4 commit b351118
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ jobs:
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
quay_api_token: ${{ secrets.QUAY_API_TOKEN }}

docker-test:
needs: [docker]
uses: ./.github/workflows/step_tests-remote-images.yml
# Since workflow_dispatch inputs are only available on manual triggers
# we need to set default values to the context vars here
with:
registry: ${{ inputs.docker_hub_registry || 'docker.io' }}
organization: ${{ inputs.docker_hub_organization || 'mahendrapaipuri' }}
registry_provider: ${{ inputs.docker_hub_registry_provider || 'dockerhub' }}

quay:
needs: [build]
uses: ./.github/workflows/step_images.yml
Expand All @@ -104,3 +114,13 @@ jobs:
login: ${{ secrets.QUAY_LOGIN }}
password: ${{ secrets.QUAY_PASSWORD }}
quay_api_token: ${{ secrets.QUAY_API_TOKEN }}

quay-test:
needs: [quay]
uses: ./.github/workflows/step_tests-remote-images.yml
# Since workflow_dispatch inputs are only available on manual triggers
# we need to set default values to the context vars here
with:
registry: ${{ inputs.quay_registry || 'quay.io' }}
organization: ${{ inputs.quay_organization || 'mahendrapaipuri' }}
registry_provider: ${{ inputs.quay_registry_provider || 'quay' }}
52 changes: 52 additions & 0 deletions .github/workflows/step_tests-remote-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: test-remote-images
run-name: Test remote container images

on:
workflow_call:
inputs:
registry:
type: string
description: Registry
organization:
type: string
description: Organization
registry_provider:
type: string
description: Registry Provider

jobs:
images:
name: images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get step vars
id: vars
env:
REGISTRY_PROVIDER: ${{ inputs.registry_provider }}
run: |
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
echo "branch_name=$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
echo "branch_name=$(echo $GITHUB_BASE_REF)" >> $GITHUB_OUTPUT
else
echo "branch_name=nightly" >> $GITHUB_OUTPUT
fi
# Repo name for container registries
if [[ "${REGISTRY_PROVIDER}" == "dockerhub" ]]; then
echo "repo_name=$(make docker-repo-name)" >> $GITHUB_OUTPUT
else
export DOCKER_REPO="$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')"
echo "repo_name=$(make docker-repo-name)" >> $GITHUB_OUTPUT
fi
- name: Pull remote container images
run: |
make docker-pull DOCKER_IMAGE_TAG=${{ steps.vars.outputs.branch_name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
docker images
- name: Test remote container images
run: make test-docker DOCKER_IMAGE_TAG=${{ steps.vars.outputs.branch_name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
6 changes: 6 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ DOCKER_ARCHS ?= amd64
BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS))
PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS))
TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS))
PULL_DOCKER_ARCHS = $(addprefix common-docker-pull-,$(DOCKER_ARCHS))

SANITIZED_DOCKER_IMAGE_TAG := $(subst +,-,$(DOCKER_IMAGE_TAG))

Expand Down Expand Up @@ -226,6 +227,11 @@ $(TAG_DOCKER_ARCHS): common-docker-tag-latest-%:
docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest"
docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)"

.PHONY: common-docker-pull $(PULL_DOCKER_ARCHS)
common-docker-pull: $(PULL_DOCKER_ARCHS)
$(PULL_DOCKER_ARCHS): common-docker-pull-%:
docker pull "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)"

.PHONY: common-docker-manifest
common-docker-manifest:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(SANITIZED_DOCKER_IMAGE_TAG))
Expand Down

0 comments on commit b351118

Please sign in to comment.