[chore/cicd] Account for force pushes in conditional runs (#4121)

CI_PIPELINE_FILES seems to be empty on force pushes to an open pull request, so this PR just accounts for that and runs all steps if it's the case, as we can't tell then what's actually changed.

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4121
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
tobi 2025-05-04 07:58:17 +00:00
commit 2f88039d57
2 changed files with 50 additions and 4 deletions

View file

@ -5,11 +5,23 @@ when:
steps:
# Lint the Go code only if
# some Go files have changed.
#
# CI_PIPELINE_FILES is undefined if
# files changed > 500, and empty on
# force pushes, so account for this
# and run step to be safe.
lint:
when:
# https://woodpecker-ci.org/docs/usage/workflow-syntax#evaluate
# https://woodpecker-ci.org/docs/usage/environment#built-in-environment-variables
- evaluate: '(not ("CI_PIPELINE_FILES" in $env)) || any(fromJSON(CI_PIPELINE_FILES), { # startsWith "internal/" || # startsWith "cmd/" || # startsWith "testrig/" || # startsWith "vendor/" })'
- evaluate: >-
(not ("CI_PIPELINE_FILES" in $env)) ||
len(CI_PIPELINE_FILES) == 0 ||
any(fromJSON(CI_PIPELINE_FILES), {
# startsWith "internal/" ||
# startsWith "cmd/" ||
# startsWith "testrig/"
})
# We use golangci-lint for linting.
# See: https://golangci-lint.run/
@ -37,11 +49,24 @@ steps:
# Test the Go code only if
# some Go files have changed.
#
# CI_PIPELINE_FILES is undefined if
# files changed > 500, and empty on
# force pushes, so account for this
# and run step to be safe.
test:
when:
# https://woodpecker-ci.org/docs/usage/workflow-syntax#evaluate
# https://woodpecker-ci.org/docs/usage/environment#built-in-environment-variables
- evaluate: '(not ("CI_PIPELINE_FILES" in $env)) || any(fromJSON(CI_PIPELINE_FILES), { # startsWith "internal/" || # startsWith "cmd/" || # startsWith "testrig/" || # startsWith "vendor/" })'
- evaluate: >-
(not ("CI_PIPELINE_FILES" in $env)) ||
len(CI_PIPELINE_FILES) == 0 ||
any(fromJSON(CI_PIPELINE_FILES), {
# startsWith "internal/" ||
# startsWith "cmd/" ||
# startsWith "testrig/" ||
# startsWith "vendor/"
})
image: golang:1.23-alpine
pull: true
@ -80,11 +105,19 @@ steps:
# Validate the web code only
# if web source has changed.
#
# CI_PIPELINE_FILES is undefined if
# files changed > 500, and empty on
# force pushes, so account for this
# and run step to be safe.
web:
when:
# https://woodpecker-ci.org/docs/usage/workflow-syntax#evaluate
# https://woodpecker-ci.org/docs/usage/environment#built-in-environment-variables
- evaluate: '(not ("CI_PIPELINE_FILES" in $env)) || any(fromJSON(CI_PIPELINE_FILES), { # startsWith "web/source/" })'
- evaluate: >-
(not ("CI_PIPELINE_FILES" in $env)) ||
len(CI_PIPELINE_FILES) == 0 ||
any(fromJSON(CI_PIPELINE_FILES), { # startsWith "web/source/" })
image: node:lts-alpine
pull: true

View file

@ -15,10 +15,23 @@ steps:
snapshot:
# Snapshot only if some interesting
# source code files have changed.
#
# CI_PIPELINE_FILES is undefined if
# files changed > 500, so account for
# this and snapshot anyway if so.
when:
# https://woodpecker-ci.org/docs/usage/workflow-syntax#evaluate
# https://woodpecker-ci.org/docs/usage/environment#built-in-environment-variables
- evaluate: '(not ("CI_PIPELINE_FILES" in $env)) || any(fromJSON(CI_PIPELINE_FILES), { # startsWith "internal/" || # startsWith "cmd/" || # startsWith "testrig/" || # startsWith "vendor/" || # startsWith "web/" || # == "Dockerfile" })'
- evaluate: >-
(not ("CI_PIPELINE_FILES" in $env)) ||
any(fromJSON(CI_PIPELINE_FILES), {
# startsWith "internal/" ||
# startsWith "cmd/" ||
# startsWith "testrig/" ||
# startsWith "vendor/" ||
# startsWith "web/" ||
# == "Dockerfile"
})
# https://codeberg.org/superseriousbusiness/gotosocial-woodpecker-build
image: superseriousbusiness/gotosocial-woodpecker-build:0.10.0