gitlab-ci: automatically hash build scripts into tag for ci-templates container

ci-templates builds and caches the test containers. When the build
scripts, the ci-template or "config.yml" changes, we need to bump
the tag so that the containers get rebuild.

Partly automate this. The tag now gets generated by the template and
contains a checksum of certain build files. Thus, if you change
any build files, then `ci-fairy generate-template` would generate a
different tag. You can not miss that, because we have tests that ensure
that our ".gitlab-ci.yml" is up to date. Also, you no longer need to
manually bump the tag when a build script changes, just regenerate
".gitlab-ci.yml" with `ci-fairy generate-template`.

See also: https://gitlab.freedesktop.org/freedesktop/ci-templates/-/merge_requests/54
This commit is contained in:
Thomas Haller 2020-11-17 09:21:12 +01:00
parent 71c3291296
commit 539c00a8a1
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 17 additions and 8 deletions

View file

@ -7,7 +7,7 @@
######################################## ########################################
.templates_sha: &template_sha d303fafa66bbca44cc5bdb337d5773b5f019b70d # see https://docs.gitlab.com/ee/ci/yaml/#includefile .templates_sha: &template_sha 766e3d77c647e404b349e398427e8965a1769b64 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
include: include:
# Centos container builder template # Centos container builder template
@ -41,10 +41,10 @@ variables:
# changing these will force rebuilding the associated image # changing these will force rebuilding the associated image
# Note: these tags have no meaning and are not tied to a particular # Note: these tags have no meaning and are not tied to a particular
# libinput version # libinput version
FEDORA_TAG: '2020-11-10.0' FEDORA_TAG: '2020-11-17.0-13e145ea4f89'
UBUNTU_TAG: '2020-11-10.0' UBUNTU_TAG: '2020-11-17.0-a7a0eae3a046'
DEBIAN_TAG: '2020-11-10.0' DEBIAN_TAG: '2020-11-17.0-f3fdbff29bf1'
CENTOS_TAG: '2020-11-10.0' CENTOS_TAG: '2020-11-17.0-5ab38b9bd66e'
FEDORA_EXEC: 'bash .gitlab-ci/fedora-install.sh' FEDORA_EXEC: 'bash .gitlab-ci/fedora-install.sh'
UBUNTU_EXEC: 'bash .gitlab-ci/ubuntu-install.sh' UBUNTU_EXEC: 'bash .gitlab-ci/ubuntu-install.sh'

View file

@ -9,7 +9,7 @@
######################################## ########################################
.templates_sha: &template_sha d303fafa66bbca44cc5bdb337d5773b5f019b70d # see https://docs.gitlab.com/ee/ci/yaml/#includefile .templates_sha: &template_sha 766e3d77c647e404b349e398427e8965a1769b64 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
include: include:
{% for distro in distributions|sort(attribute="name") %} {% for distro in distributions|sort(attribute="name") %}
@ -34,7 +34,12 @@ variables:
# Note: these tags have no meaning and are not tied to a particular # Note: these tags have no meaning and are not tied to a particular
# libinput version # libinput version
{% for distro in distributions %} {% for distro in distributions %}
{{"%-13s"| format(distro.name.upper() + '_TAG:')}}'{{distro.tag}}' {{"%-13s"| format(distro.name.upper() + '_TAG:')}}'{{distro.tag}}-{{
(ci_fairy.hashfiles('./.gitlab-ci/config.yml',
'./.gitlab-ci/ci.template',
'./.gitlab-ci/' + distro.name + '-install.sh',
'./contrib/' + distro.base_type + '/REQUIRED_PACKAGES'))[0:12]
}}'
{% endfor %} {% endfor %}
{% for distro in distributions %} {% for distro in distributions %}

View file

@ -8,7 +8,7 @@
# #
# We're happy to rebuild all containers when one changes. # We're happy to rebuild all containers when one changes.
.default_tag: &default_tag '2020-11-10.0' .default_tag: &default_tag '2020-11-17.0'
# The list of all distributions we want to create job for. # The list of all distributions we want to create job for.
@ -16,6 +16,7 @@
distributions: distributions:
- name: fedora - name: fedora
tag: *default_tag tag: *default_tag
base_type: fedora
versions: versions:
- '28' - '28'
- '29' - '29'
@ -28,6 +29,7 @@ distributions:
- '33' - '33'
- name: ubuntu - name: ubuntu
tag: *default_tag tag: *default_tag
base_type: debian
versions: versions:
- '16.04' - '16.04'
- '18.04' - '18.04'
@ -36,6 +38,7 @@ distributions:
- 'rolling' - 'rolling'
- name: debian - name: debian
tag: *default_tag tag: *default_tag
base_type: debian
versions: versions:
- '9' - '9'
- '10' - '10'
@ -43,6 +46,7 @@ distributions:
- 'sid' - 'sid'
- name: centos - name: centos
tag: *default_tag tag: *default_tag
base_type: fedora
versions: versions:
- '7.5.1804' - '7.5.1804'
- '7.6.1810' - '7.6.1810'