NetworkManager/.gitlab-ci/ci.template
Thomas Haller e721907472
gitlab-ci: rework extends: for "check-{patch,tree}" jobs
The "check-{patch,tree}" jobs use the same container as the default
test on Fedora ("pages_build", which also builds our documentation).

Previously, we thus extended "t_fedora:35". But that way we also
got things that we didn't want (.nm_artifacts and .build@template).

Solve this differently, by letting the jobs directly define what they
need. It's not much more, than extending "t_fedora:35" and workaround
to drop stuff we don't want.
2022-03-21 17:19:47 +01:00

250 lines
8.1 KiB
YAML

# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
{# You're looking at the template here, so you can ignore the below
warning. This is the right file to edit #}
########################################
# #
# THIS FILE IS GENERATED, DO NOT EDIT #
# #
########################################
.templates_sha: &template_sha 3e66ea37e5672bb8f48e3056ba92915b5fc5b888 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
include:
{% for distro in distributions|sort(attribute="name") %}
# {{ distro.name.capitalize() }} container builder template
- project: 'freedesktop/ci-templates'
ref: *template_sha
file: '/templates/{{distro.name}}.yml'
{% endfor %}
stages:
- prep
- test
- deploy
- triage
- container_clean
variables:
FDO_UPSTREAM_REPO: NetworkManager/NetworkManager
GIT_DEPTH: 1
# These tags should be updated each time the list of packages is updated
# changing these will force rebuilding the associated image
# Note: these tags have no meaning and are not tied to a particular NM version
#
# This is done by running `ci-fairy generate-template` and possibly bump
# ".default_tag".
{% for distro in distributions %}
{{"%-13s"| format(distro.name.upper() + '_TAG:')}}'{{distro.tag}}-{{
(ci_fairy.hashfiles('./.gitlab-ci/config.yml',
'./.gitlab-ci/ci.template',
'./.gitlab-ci/' + distro.base_type + '-install.sh',
'./contrib/' + distro.base_type + '/REQUIRED_PACKAGES'))[0:12]
}}'
{% endfor %}
{% for distro in distributions %}
{{"%-13s"| format(distro.name.upper() + '_EXEC:')}}'bash .gitlab-ci/{{distro.base_type}}-install.sh'
{% endfor %}
.nm_artifacts:
variables:
NM_BUILD_TARBALL: 1
artifacts:
expire_in: 5 days
when: always
paths:
- docs-html
- NetworkManager-1*.tar.xz
- NetworkManager-1*.src.rpm
- nm-test.log
.nm_artifacts_debug:
artifacts:
expire_in: 5 days
when: always
paths:
- nm-test.log
#################################################################
# #
# containers stage #
# #
#################################################################
# Build a container for each distribution + version. The ci-templates
# will re-use the containers if the tag doesn't change.
{% for distro in distributions %}
{% for version in distro.versions %}
{{distro.name}}:{{version}}@container-prep:
extends:
- .fdo.container-build@{{distro.name}}
stage: prep
variables:
GIT_STRATEGY: none
FDO_DISTRIBUTION_VERSION: '{{version}}'
FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
FDO_DISTRIBUTION_EXEC: ${{distro.name.upper()}}_EXEC
{% endfor %}
{% endfor %}
#################################################################
# #
# container clean stage #
# run during the clean stage #
# #
#################################################################
#
# This stage will look for the container images we currently have in
# the registry and will remove any that are not tagged with the provided
# $container_image:$tag
#
# This job only runs for a scheduled pipeline.
#
# Go to your Profile, Settings, Access Tokens
# Create a personal token with 'api' scope, copy the value.
# Go to CI/CD, Schedules, schedule a monthly job.
# Define a variable of type File named AUTHFILE. Content is that token
# value.
.container-clean:
stage: container_clean
image: golang:alpine
before_script:
- apk add python3 py-pip git
- pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
script:
- ci-fairy -v --authfile $AUTHFILE delete-image
--repository $FDO_DISTRIBUTION_NAME/$FDO_DISTRIBUTION_VERSION
--exclude-tag $FDO_DISTRIBUTION_TAG
dependencies: []
allow_failure: true
only:
- schedules
{% for distro in distributions %}
{% for version in distro.versions %}
{{distro.name}}:{{version}}@container-clean:
extends:
- .container-clean
variables:
GIT_STRATEGY: none
CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/{{distro.name}}/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
FDO_DISTRIBUTION_VERSION: '{{version}}'
FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
{% endfor %}
{% endfor %}
#################################################################
# #
# build stage #
# #
#################################################################
.build@template:
stage: test
script:
- env
- .gitlab-ci/run-test.sh 2>&1 | tee /tmp/nm-test.log
after_script:
- mv /tmp/nm-test.log .
dependencies: []
#################################################################
# #
# test stage #
# #
#################################################################
{% for distro in distributions %}
{% for version in distro.versions %}
t_{{distro.name}}:{{version}}:
extends:
- .build@template
- .fdo.distribution-image@{{distro.name}}
{% if distro.name == pages_build.name and
version == pages_build.version %}
- .nm_artifacts
{% else %}
- .nm_artifacts_debug
{% endif %}
variables:
FDO_DISTRIBUTION_VERSION: '{{version}}'
FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
{# Where we have extra_variables defined, add them to the list #}
{% if distro.build is defined and distro.build.extra_variables is defined %}
{% for var in distro.build.extra_variables %}
{{var}}
{% endfor %}
{% endif %}
needs:
- "{{distro.name}}:{{version}}@container-prep"
{% if not version in distro.get('always', []) and (distro.name != pages_build.name or version != pages_build.version) %}
when: manual
{% endif %}
{% endfor %}
{% endfor %}
#################################################################
# #
# specific jobs #
# #
#################################################################
check-patch:
extends:
- .fdo.distribution-image@{{pages_build.name}}
variables:
FDO_DISTRIBUTION_VERSION: '{{pages_build.version}}'
FDO_DISTRIBUTION_TAG: ${{pages_build.name.upper()}}_TAG
needs:
- "{{pages_build.name}}:{{pages_build.version}}@container-prep"
stage: test
script:
- date '+%Y%m%d-%H%M%S'; NM_CHECKPATCH_FETCH_UPSTREAM=1 contrib/scripts/checkpatch-feature-branch.sh
allow_failure: true
check-tree:
extends:
- .fdo.distribution-image@{{pages_build.name}}
variables:
FDO_DISTRIBUTION_VERSION: '{{pages_build.version}}'
FDO_DISTRIBUTION_TAG: ${{pages_build.name.upper()}}_TAG
needs:
- "{{pages_build.name}}:{{pages_build.version}}@container-prep"
stage: test
script:
- date '+%Y%m%d-%H%M%S'; black --check . examples/python/gi/nm-wg-set
- date '+%Y%m%d-%H%M%S'; git ls-files -z -- 'po/*.po' | xargs -0 -n1 msgfmt -vc
- date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-code-format.sh -n
- date '+%Y%m%d-%H%M%S'; ci-fairy generate-template && git diff --exit-code
pages:
stage: deploy
script:
- mv docs-html public
artifacts:
expire_in: 20 days
paths:
- public
only:
- main
dependencies:
- t_{{pages_build.name}}:{{pages_build.version}}
needs:
- t_{{pages_build.name}}:{{pages_build.version}}
triage:issues:
stage: triage
image: ruby:2.7
script:
- gem install gitlab-triage
- gitlab-triage -d --token $API_TOKEN --source-id $SOURCE_ID
only:
- schedules