cypress-io / cypress-docker-images

Docker images with Cypress dependencies and browsers
https://on.cypress.io/continuous-integration
MIT License
1.02k stars 380 forks source link

ci: check image exists with Docker Hub API #1151

Closed MikeMcC399 closed 1 month ago

MikeMcC399 commented 1 month ago

Issue

When used in the CircleCI workflow workflow, the npm module docker-image-not-found outputs an error message "unsupported schema version 2" when attempting to check the existence of a Docker image on Docker Hub, if the image has been published with an oci type manifest instead of a docker type manifest.

Change

In the CircleCI workflow workflow, replace the npm module docker-image-not-found using a Docker HUB API call.

For example, the following command returns 0 if Docker Hub reports that the image is not found (HTTP 404), otherwise it returns 1. This works for docker and oci type manifests:

curl -s https://hub.docker.com/v2/namespaces/cypress/repositories/factory/tags/4.5.6 | grep -iq 'httperror 404'

Apart from the different parameter passing, the Docker HUB API) call is a drop-in replacement for docker-image-not-found.

cypress-app-bot commented 1 month ago
MikeMcC399 commented 1 month ago

The following test workflow log demonstrates that the changed workflow is able to recognize published images on Docker Hub corresponding to the following tags. The workflow correctly halts in this case to prevent an attempt to republish:

FACTORY_VERSION=4.0.2
BASE_IMAGE_TAG=20.14.0
BROWSERS_IMAGE_TAG=node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1
INCLUDED_IMAGE_TAG=cypress-13.13.0-node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1

Log

jennifer-shehane commented 1 month ago

Archived that repo as I didn't see it used elsewhere

MikeMcC399 commented 1 month ago

@jennifer-shehane

I like this. I think I can archive the docker-image-not-found repo with this update.

That is a good move! The repo was a long way behind and even updating all dependencies would not solve the issue.