mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-27 10:20:07 +01:00
CI: simplify the logic for rebuilding the containers
right now the check_if_older_than_a_week rule does (in pseudo-code):
- get timestamp of current image or 0
- get timestamp of upstream image or 0
- if upstream image is newer than current image
copy upstream image into current
- if we are in a scheduled pipeline, or if there is no current image
(timestamp of 0), rebuild the current image
The ci-templates if-not-exists rule does:
- if there is a current image, exit
- if there is an upstream image, copy it to current and exit
- rebuild
Having the following is equivalent to the current behaviour and
can be used instead of check_if_older_than_a_week:
- if there is an upstream image, copy it to current and exit
- if there is a current image, exit
- rebuild
Because what matters is:
forks should be running the upstream image if available
forks should be running the latest upstream image in the libinput case
forks should be able to rebuild the images if there is no upstream
(change of the image tag)
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
(cherry picked from commit 6d96d417a0)
This commit is contained in:
parent
6e7a52b87f
commit
0ae355ad59
1 changed files with 16 additions and 30 deletions
|
|
@ -117,7 +117,7 @@ variables:
|
|||
# is too old or if it is missing some dependencies.
|
||||
#
|
||||
|
||||
.check_if_older_than_a_week: &check_if_older_than_a_week
|
||||
.pull_upstream_or_rebuild: &pull_upstream_or_rebuild
|
||||
before_script:
|
||||
# log in to the registry
|
||||
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
|
|
@ -125,32 +125,18 @@ variables:
|
|||
# get the full container image name (DISTRIB_VERSION still has indirections)
|
||||
- IMAGE=$(eval echo "$DISTRIB_FLAVOR/$DISTRIB_VERSION:$TAG")
|
||||
|
||||
# check if our image is already in the current registry and get its date
|
||||
- LOCAL_IMG_DATE=$(skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE | jq -r '.Created' | cut -dT -f1 ||
|
||||
echo 1970-01-01)
|
||||
|
||||
# get the date of the upstream image
|
||||
- UPSTREAM_IMG_DATE=$(skopeo inspect docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE | jq -r '.Created' | cut -dT -f1 ||
|
||||
echo 1970-01-01)
|
||||
|
||||
- TODAY_SECS=$(date -u +%s)
|
||||
- LOCAL_IMG_SECS=$(date -u --date="$LOCAL_IMG_DATE" +%s)
|
||||
- UPSTREAM_IMG_SECS=$(date -u --date="$UPSTREAM_IMG_DATE" +%s)
|
||||
- echo "today $TODAY_SECS, local image $LOCAL_IMG_SECS, upstream image $UPSTREAM_IMG_SECS"
|
||||
- echo "image ages $(($TODAY_SECS - $LOCAL_IMG_SECS))s and $(($TODAY_SECS - $UPSTREAM_IMG_SECS))s"
|
||||
|
||||
# if the upstream image is more recent, use it
|
||||
- if [[ $UPSTREAM_IMG_SECS -gt $LOCAL_IMG_SECS ]] ;
|
||||
- |
|
||||
# force rebuild if schedule, reuse otherwise
|
||||
if [[ $CI_PIPELINE_SOURCE != "schedule" ]] ;
|
||||
then
|
||||
skopeo copy docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE
|
||||
docker://$CI_REGISTRY_IMAGE/$IMAGE ;
|
||||
LOCAL_IMG_SECS=UPSTREAM_IMG_SECS ;
|
||||
# pull the latest upstream image if it exists
|
||||
skopeo copy docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE \
|
||||
docker://$CI_REGISTRY_IMAGE/$IMAGE && exit 0 || true ;
|
||||
|
||||
# check if our image is already in the current registry
|
||||
skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
|
||||
fi
|
||||
|
||||
# if the image exists and we are not in the scheduled pipeline, exit
|
||||
- test $LOCAL_IMG_SECS -gt 0 -a $CI_PIPELINE_SOURCE != "schedule" && exit 0
|
||||
|
||||
|
||||
fedora:28@container-prep:
|
||||
extends: .fedora@container-build
|
||||
stage: container_prep
|
||||
|
|
@ -160,7 +146,7 @@ fedora:28@container-prep:
|
|||
DISTRIB_FLAVOR: fedora
|
||||
DISTRIB_VERSION: $FEDORA_VERSION
|
||||
TAG: $FEDORA_TAG
|
||||
<<: *check_if_older_than_a_week
|
||||
<<: *pull_upstream_or_rebuild
|
||||
|
||||
fedora:29@container-prep:
|
||||
extends: .fedora@container-build
|
||||
|
|
@ -171,7 +157,7 @@ fedora:29@container-prep:
|
|||
DISTRIB_FLAVOR: fedora
|
||||
DISTRIB_VERSION: $FEDORA_VERSION
|
||||
TAG: $FEDORA_TAG
|
||||
<<: *check_if_older_than_a_week
|
||||
<<: *pull_upstream_or_rebuild
|
||||
|
||||
|
||||
ubuntu:18.10@container-prep:
|
||||
|
|
@ -183,7 +169,7 @@ ubuntu:18.10@container-prep:
|
|||
DISTRIB_FLAVOR: ubuntu
|
||||
DISTRIB_VERSION: $UBUNTU_VERSION
|
||||
TAG: $UBUNTU_TAG
|
||||
<<: *check_if_older_than_a_week
|
||||
<<: *pull_upstream_or_rebuild
|
||||
|
||||
ubuntu:18.04@container-prep:
|
||||
extends: .ubuntu@container-build
|
||||
|
|
@ -194,7 +180,7 @@ ubuntu:18.04@container-prep:
|
|||
DISTRIB_FLAVOR: ubuntu
|
||||
DISTRIB_VERSION: $UBUNTU_VERSION
|
||||
TAG: $UBUNTU_TAG
|
||||
<<: *check_if_older_than_a_week
|
||||
<<: *pull_upstream_or_rebuild
|
||||
|
||||
|
||||
arch:rolling@container-prep:
|
||||
|
|
@ -206,12 +192,12 @@ arch:rolling@container-prep:
|
|||
DISTRIB_FLAVOR: archlinux
|
||||
DISTRIB_VERSION: $ARCH_VERSION
|
||||
TAG: $ARCH_TAG
|
||||
<<: *check_if_older_than_a_week
|
||||
<<: *pull_upstream_or_rebuild
|
||||
|
||||
.freebsd@container-prep:
|
||||
stage: container_prep
|
||||
image: $BUILDAH_IMAGE
|
||||
<<: *check_if_older_than_a_week
|
||||
<<: *pull_upstream_or_rebuild
|
||||
script:
|
||||
- buildcntr=$(buildah from --quiet myfreeweb/freebsd-cross:latest)
|
||||
- buildah run $buildcntr apk add --no-cache $FREEBSD_BUILD_PKGS
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue