gitlab-ci: refactor to rules: and ditch old only: syntax

Adding workflow: is required, otherwise there would be duplicate
pipelines for all users in the @fdroid group.  There would be "branch
pipelines" and "merge request pipelines".  Confusingly, only jobs with
rules: get duplicated.
This commit is contained in:
Hans-Christoph Steiner 2025-03-12 17:53:05 +01:00
parent 07d499ce1f
commit aa9cc14991

View File

@ -1,5 +1,16 @@
--- ---
# Use merge request pipelines when a merge request is open for the branch.
# Use branch pipelines when a merge request is not open for the branch.
# https://docs.gitlab.com/ci/yaml/workflow/#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
variables: variables:
pip: pip3 --timeout 100 --retries 10 pip: pip3 --timeout 100 --retries 10
# speed up git checkout phase # speed up git checkout phase
@ -94,8 +105,8 @@ metadata_v0:
debian_testing: debian_testing:
image: debian:testing image: debian:testing
<<: *apt-template <<: *apt-template
only: rules:
- master@fdroid/fdroidserver - if: $CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "fdroid/fdroidserver"
script: script:
- apt-get install - apt-get install
aapt aapt
@ -123,8 +134,8 @@ debian_testing:
ubuntu_lts_ppa: ubuntu_lts_ppa:
image: ubuntu:latest image: ubuntu:latest
<<: *apt-template <<: *apt-template
only: rules:
- master@fdroid/fdroidserver - if: $CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "fdroid/fdroidserver"
script: script:
- export ANDROID_HOME=/usr/lib/android-sdk - export ANDROID_HOME=/usr/lib/android-sdk
- apt-get install gnupg - apt-get install gnupg
@ -188,11 +199,11 @@ ubuntu_jammy_pip:
gradlew-fdroid: gradlew-fdroid:
image: debian:bookworm-slim image: debian:bookworm-slim
<<: *apt-template <<: *apt-template
only: rules:
changes: - changes:
- .gitlab-ci.yml - .gitlab-ci.yml
- gradlew-fdroid - gradlew-fdroid
- tests/test_gradlew-fdroid - tests/test_gradlew-fdroid
script: script:
- apt-get install ca-certificates curl default-jdk-headless shellcheck unzip - apt-get install ca-certificates curl default-jdk-headless shellcheck unzip
- shellcheck --severity=error --color gradlew-fdroid tests/test_gradlew-fdroid - shellcheck --severity=error --color gradlew-fdroid tests/test_gradlew-fdroid
@ -255,10 +266,7 @@ lint_format_bandit_checks:
safety: safety:
image: debian:bookworm-slim image: debian:bookworm-slim
rules: rules:
# once only:/changes: are ported to rules:, this could be removed: - if: $SAFETY_API_KEY
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_PIPELINE_SOURCE == "push" && $SAFETY_API_KEY
changes: changes:
- .gitlab-ci.yml - .gitlab-ci.yml
- .safety-policy.yml - .safety-policy.yml
@ -283,11 +291,7 @@ safety:
yamllint: yamllint:
image: debian:bookworm-slim image: debian:bookworm-slim
rules: rules:
# once only:/changes: are ported to rules:, this could be removed: - changes:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_PIPELINE_SOURCE == "push"
changes:
- .gitlab-ci.yml - .gitlab-ci.yml
- .safety-policy.yml - .safety-policy.yml
- .yamllint - .yamllint
@ -308,7 +312,6 @@ yamllint:
tests/*/*/.*.yml tests/*/*/.*.yml
# Run all the various linters and static analysis tools.
locales: locales:
image: debian:bookworm-slim image: debian:bookworm-slim
variables: variables:
@ -380,8 +383,8 @@ fedora_latest:
macOS: macOS:
tags: tags:
- saas-macos-medium-m1 - saas-macos-medium-m1
only: rules:
- master@fdroid/fdroidserver - if: $CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "fdroid/fdroidserver"
script: script:
- export HOMEBREW_CURL_RETRIES=10 - export HOMEBREW_CURL_RETRIES=10
- brew update > /dev/null - brew update > /dev/null
@ -446,16 +449,16 @@ gradle:
# Run an actual build in a simple, faked version of the buildserver guest VM. # Run an actual build in a simple, faked version of the buildserver guest VM.
fdroid build: fdroid build:
image: registry.gitlab.com/fdroid/fdroidserver:buildserver image: registry.gitlab.com/fdroid/fdroidserver:buildserver
only: rules:
changes: - changes:
- .gitlab-ci.yml - .gitlab-ci.yml
- fdroidserver/build.py - fdroidserver/build.py
- fdroidserver/common.py - fdroidserver/common.py
- fdroidserver/exception.py - fdroidserver/exception.py
- fdroidserver/metadata.py - fdroidserver/metadata.py
- fdroidserver/net.py - fdroidserver/net.py
- fdroidserver/scanner.py - fdroidserver/scanner.py
- fdroidserver/vmtools.py - fdroidserver/vmtools.py
cache: cache:
key: "$CI_JOB_NAME" key: "$CI_JOB_NAME"
paths: paths:
@ -516,11 +519,11 @@ fdroid build:
plugin_fetchsrclibs: plugin_fetchsrclibs:
image: debian:bookworm-slim image: debian:bookworm-slim
<<: *apt-template <<: *apt-template
only: rules:
changes: - changes:
- .gitlab-ci.yml - .gitlab-ci.yml
- examples/fdroid_fetchsrclibs.py - examples/fdroid_fetchsrclibs.py
- fdroidserver/__main__.py - fdroidserver/__main__.py
script: script:
- apt-get install - apt-get install
curl curl
@ -560,8 +563,8 @@ plugin_fetchsrclibs:
servergitmirrors: servergitmirrors:
image: debian:bookworm-slim image: debian:bookworm-slim
<<: *apt-template <<: *apt-template
only: rules:
- master@fdroid/fdroidserver - if: $CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "fdroid/fdroidserver"
script: script:
- apt-get install - apt-get install
default-jdk-headless default-jdk-headless
@ -622,8 +625,8 @@ Build documentation:
Windows: Windows:
tags: tags:
- windows - windows
only: rules:
- windows - if: $CI_COMMIT_BRANCH == "windows"
script: script:
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
- choco install --no-progress -y git --force --params "/GitAndUnixToolsOnPath" - choco install --no-progress -y git --force --params "/GitAndUnixToolsOnPath"
@ -686,13 +689,12 @@ pages:
docker: docker:
dependencies: dependencies:
- fdroid build - fdroid build
only: rules:
changes: - if: $CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "fdroid/fdroidserver"
- .gitlab-ci.yml changes:
- makebuildserver - .gitlab-ci.yml
- buildserver/* - makebuildserver
variables: - buildserver/*
- $CI_COMMIT_BRANCH == "master" || $CI_PROJECT_NAMESPACE != "fdroid"
image: docker:dind image: docker:dind
services: services:
- docker:dind - docker:dind