From c5115d43222c7347f7c11bb27b118d9d4d28f2c6 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Sun, 14 Aug 2022 18:22:39 +0000 Subject: [PATCH] use new multi when --- .woodpecker/binaries.yml | 54 +++++++++++++++---- .woodpecker/docker.yml | 8 +++ .woodpecker/helm.yml | 20 +++---- .woodpecker/test.yml | 113 +++++++++++++++++++++++++++++++++------ .woodpecker/web.yml | 23 ++++---- 5 files changed, 171 insertions(+), 47 deletions(-) diff --git a/.woodpecker/binaries.yml b/.woodpecker/binaries.yml index f451e66126..8b8d9a83ca 100644 --- a/.woodpecker/binaries.yml +++ b/.woodpecker/binaries.yml @@ -24,7 +24,11 @@ pipeline: - yarn install --frozen-lockfile - yarn build when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path vendor: group: prepare @@ -32,7 +36,11 @@ pipeline: commands: - go mod vendor when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path build-server: group: build @@ -40,7 +48,11 @@ pipeline: commands: - make release-server when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path build-agent: group: build @@ -48,7 +60,11 @@ pipeline: commands: - make release-agent when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path build-cli: group: build @@ -56,7 +72,11 @@ pipeline: commands: - make release-cli when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path build-deb-rpm: group: bundle @@ -64,7 +84,11 @@ pipeline: commands: - make bundle when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path build-tarball: group: bundle @@ -72,14 +96,22 @@ pipeline: commands: - make release-tarball when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path checksums: image: *golang_image commands: - make release-checksums when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path # TODO: upload build artifacts for pushes to ${CI_REPO_DEFAULT_BRANCH} @@ -89,7 +121,11 @@ pipeline: - ls -la dist/*.* - cat dist/checksums.txt when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path release: image: plugins/github-release diff --git a/.woodpecker/docker.yml b/.woodpecker/docker.yml index 4a2e26ece9..96d5ba2857 100644 --- a/.woodpecker/docker.yml +++ b/.woodpecker/docker.yml @@ -23,6 +23,10 @@ pipeline: - cd web/ - yarn install --frozen-lockfile - yarn build + when: + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + - event: [tag, pull_request] cross-compile-server: image: *xgo_image @@ -34,6 +38,10 @@ pipeline: PLATFORMS: linux|arm/v7;linux|arm64/v8;linux|amd64;linux|ppc64le TAGS: bindata sqlite sqlite_unlock_notify XGO_VERSION: *xgo_version + when: + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + - event: [tag, pull_request] publish-server-preview: image: woodpeckerci/plugin-docker-buildx diff --git a/.woodpecker/helm.yml b/.woodpecker/helm.yml index b8211f1b86..74ac735a21 100644 --- a/.woodpecker/helm.yml +++ b/.woodpecker/helm.yml @@ -1,3 +1,8 @@ +variables: + - &when_path + - "charts/**" + - ".woodpecker/helm.yml" + pipeline: set-version: image: alpine/helm:3.5.3 @@ -11,10 +16,7 @@ pipeline: - cat charts/woodpecker-agent/Chart.yaml - cat charts/woodpecker-server/Chart.yaml when: - path: - include: - - "charts/**" - - ".woodpecker/helm.yml" + path: *when_path lint: image: alpine/helm:3.5.3 @@ -22,10 +24,7 @@ pipeline: - helm lint charts/woodpecker-agent/ - helm lint charts/woodpecker-server/ when: - path: - include: - - "charts/**" - - ".woodpecker/helm.yml" + path: *when_path release: image: quay.io/helmpack/chart-releaser:v1.4.0 @@ -43,7 +42,4 @@ pipeline: - cd woodpecker-ci.github.io/ && cr index --owner woodpecker-ci --git-repo woodpecker-ci.github.io --pages-branch master --package-path ../.cr-release-packages --index-path ../.cr-index/index.yaml --charts-repo https://woodpecker-ci.org --push --release-name-template "helm-{{ .Name }}-{{ .Version }}" when: event: tag - path: - include: - - "charts/**" - - ".woodpecker/helm.yml" + path: *when_path diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml index fcbd9a6565..98da2677e3 100644 --- a/.woodpecker/test.yml +++ b/.woodpecker/test.yml @@ -18,16 +18,26 @@ pipeline: commands: - go mod vendor when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path lint-pipeline: image: *golang_image commands: - go run github.com/woodpecker-ci/woodpecker/cmd/cli lint when: - path: - - ".woodpecker/**" - - "pipeline/schema/**" + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: + - ".woodpecker/**" + - "pipeline/schema/**" + - event: [tag, pull_request] + path: + - ".woodpecker/**" + - "pipeline/schema/**" dummy-web: image: *golang_image @@ -36,7 +46,11 @@ pipeline: - mkdir -p web/dist/ - echo "test" > web/dist/index.html when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path lint: image: *golang_image @@ -44,22 +58,67 @@ pipeline: commands: - make lint when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path lint-editorconfig: image: mstruebing/editorconfig-checker group: test + when: + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + - event: [tag, pull_request] - test: + test-agent: image: *golang_image group: test commands: - make test-agent + when: + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path + + test-server: + image: *golang_image + group: test + commands: - make test-server - - make test-cli + when: + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path + + test-cli: + image: *golang_image + group: test + commands: + - make test-server + when: + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path + + test-lib: + image: *golang_image + group: test + commands: - make test-lib when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path sqlite: image: *golang_image @@ -69,7 +128,11 @@ pipeline: commands: - make test-server-datastore-coverage when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path postgres: image: *golang_image @@ -80,7 +143,11 @@ pipeline: commands: - make test-server-datastore when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path mysql: image: *golang_image @@ -91,7 +158,11 @@ pipeline: commands: - make test-server-datastore when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path codecov: pull: true @@ -105,7 +176,11 @@ pipeline: token: from_secret: codecov_token when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path services: service-postgres: @@ -115,7 +190,11 @@ services: - POSTGRES_USER=postgres - POSTGRES_HOST_AUTH_METHOD=trust when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path service-mysql: image: mysql:5.6.27 @@ -124,4 +203,8 @@ services: - MYSQL_DATABASE=test - MYSQL_ALLOW_EMPTY_PASSWORD=yes when: - path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path + - event: [tag, pull_request] + path: *when_path diff --git a/.woodpecker/web.yml b/.woodpecker/web.yml index 2a56c53643..4f5899135b 100644 --- a/.woodpecker/web.yml +++ b/.woodpecker/web.yml @@ -3,6 +3,13 @@ variables: - &when_path # web source code - "web/**" + - &when + - event: tag + - event: pull_request + path: *when_path + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + path: *when_path pipeline: deps: @@ -10,8 +17,7 @@ pipeline: commands: - cd web/ - yarn install --frozen-lockfile - when: - path: *when_path + when: *when lint: group: test @@ -19,8 +25,7 @@ pipeline: commands: - cd web/ - yarn lint - when: - path: *when_path + when: *when formatcheck: group: test @@ -28,8 +33,7 @@ pipeline: commands: - cd web/ - yarn formatcheck - when: - path: *when_path + when: *when typecheck: group: test @@ -37,8 +41,7 @@ pipeline: commands: - cd web/ - yarn typecheck - when: - path: *when_path + when: *when test: group: test @@ -46,6 +49,4 @@ pipeline: commands: - cd web/ - yarn test - when: - path: *when_path - + when: *when