From bf10ca0203e9abcd6a022ee444c8815a3d66899a Mon Sep 17 00:00:00 2001 From: tobi Date: Fri, 2 May 2025 20:26:09 +0000 Subject: [PATCH] [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 Co-committed-by: tobi --- .woodpecker/pr.yaml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.woodpecker/pr.yaml b/.woodpecker/pr.yaml index 18b96708d..e116d3e20 100644 --- a/.woodpecker/pr.yaml +++ b/.woodpecker/pr.yaml @@ -3,8 +3,14 @@ when: - event: pull_request steps: - # Lint the Go code. + # Lint the Go code only if + # some Go files have changed. 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. # See: https://golangci-lint.run/ image: golangci/golangci-lint:v1.62.0 @@ -29,8 +35,14 @@ steps: commands: - golangci-lint run - # Test the Go code. + # Test the Go code only if + # some Go files have changed. 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 pull: true @@ -66,8 +78,14 @@ steps: # https://woodpecker-ci.org/docs/usage/workflow-syntax#depends_on depends_on: [lint] - # Validate the web code. + # Validate the web code only + # if web source has changed. 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 pull: true @@ -93,6 +111,3 @@ steps: # Ensure build works. - yarn --cwd ./web/source build - - # https://woodpecker-ci.org/docs/usage/workflow-syntax#depends_on - depends_on: [test]