[chore/cicd] conditional tests + linting for pull requests (#4114)

Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4113

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4114
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
tobi
2025-05-02 20:26:09 +00:00
committed by tobi
parent 1480f22aea
commit bf10ca0203

View File

@@ -3,8 +3,14 @@ when:
- event: pull_request - event: pull_request
steps: steps:
# Lint the Go code. # Lint the Go code only if
# some Go files have changed.
lint: 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/" })'
# We use golangci-lint for linting. # We use golangci-lint for linting.
# See: https://golangci-lint.run/ # See: https://golangci-lint.run/
image: golangci/golangci-lint:v1.62.0 image: golangci/golangci-lint:v1.62.0
@@ -29,8 +35,14 @@ steps:
commands: commands:
- golangci-lint run - golangci-lint run
# Test the Go code. # Test the Go code only if
# some Go files have changed.
test: 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/" })'
image: golang:1.23-alpine image: golang:1.23-alpine
pull: true pull: true
@@ -66,8 +78,14 @@ steps:
# https://woodpecker-ci.org/docs/usage/workflow-syntax#depends_on # https://woodpecker-ci.org/docs/usage/workflow-syntax#depends_on
depends_on: [lint] depends_on: [lint]
# Validate the web code. # Validate the web code only
# if web source has changed.
web: 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/" })'
image: node:lts-alpine image: node:lts-alpine
pull: true pull: true
@@ -93,6 +111,3 @@ steps:
# Ensure build works. # Ensure build works.
- yarn --cwd ./web/source build - yarn --cwd ./web/source build
# https://woodpecker-ci.org/docs/usage/workflow-syntax#depends_on
depends_on: [test]