Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add branches filter #1130

Merged
merged 9 commits into from
Oct 10, 2022
27 changes: 8 additions & 19 deletions .woodpecker/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ variables:
# web source code
- "web/**"

when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request # TODO: Do we need this :thinking:?
path: *when_path

pipeline:
build-web:
group: prepare
Expand All @@ -24,63 +32,47 @@ pipeline:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
when:
path: *when_path

vendor:
group: prepare
image: *golang_image
commands:
- go mod vendor
when:
path: *when_path

build-server:
group: build
image: *golang_image
commands:
- make release-server
when:
path: *when_path

build-agent:
group: build
image: *golang_image
commands:
- make release-agent
when:
path: *when_path

build-cli:
group: build
image: *golang_image
commands:
- make release-cli
when:
path: *when_path

build-deb-rpm:
group: bundle
image: *golang_image
commands:
- make bundle
when:
path: *when_path

build-tarball:
group: bundle
image: *golang_image
commands:
- make release-tarball
when:
path: *when_path

checksums:
image: *golang_image
commands:
- make release-checksums
when:
path: *when_path

# TODO: upload build artifacts for pushes to ${CI_REPO_DEFAULT_BRANCH}

Expand All @@ -89,8 +81,6 @@ pipeline:
commands:
- ls -la dist/*.*
- cat dist/checksums.txt
when:
path: *when_path

release:
image: plugins/github-release
Expand All @@ -106,4 +96,3 @@ pipeline:
title: ${CI_COMMIT_TAG##v}
when:
event: tag
# path conditions are ignored for tag events
6 changes: 6 additions & 0 deletions .woodpecker/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ variables:
- &platforms_preview 'linux/arm/v6,linux/arm64/v8,linux/amd64,linux/riscv64,windows/amd64'
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'

when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
- event: tag
- event: pull_request

pipeline:
vendor:
image: *golang_image
Expand Down
16 changes: 8 additions & 8 deletions .woodpecker/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ variables:
- "cli/**"
- "cmd/cli/**"

when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request
path: *when_path

pipeline:
build-cli:
image: *golang_image
commands:
- make docs
when:
path: *when_path

build:
image: *node_image
Expand All @@ -23,17 +29,13 @@ pipeline:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
when:
path: *when_path

securitycheck:
image: aquasec/trivy:latest
commands:
- trivy fs --exit-code 0 --skip-dirs node_modules/ --skip-dirs plugins/woodpecker-plugins/node_modules --severity UNKNOWN,LOW docs/
# TODO currently it is not fixable so just do not block currently
- trivy fs --exit-code 0 --skip-dirs node_modules/ --skip-dirs plugins/woodpecker-plugins/node_modules --severity MEDIUM,HIGH,CRITICAL docs/
when:
path: *when_path

deploy-preview:
image: woodpeckerci/plugin-surge-preview:next
Expand All @@ -47,7 +49,6 @@ pipeline:
from_secret: GITHUB_TOKEN_SURGE
when:
event: pull_request
path: *when_path

# TODO: add step to remove preview again after PR is closed (waiting for #286)

Expand Down Expand Up @@ -75,4 +76,3 @@ pipeline:
when:
event: push
branch: ${CI_REPO_DEFAULT_BRANCH}
path: *when_path
27 changes: 13 additions & 14 deletions .woodpecker/helm.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
variables:
- &when_path
- "charts/**"
- ".woodpecker/helm.yml"

when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request
path: *when_path

pipeline:
set-version:
image: alpine/helm:3.5.3
Expand All @@ -10,22 +23,12 @@ pipeline:
- sed -i "s/<version>/$CHART_VERSION/g" charts/woodpecker-server/Chart.yaml
- cat charts/woodpecker-agent/Chart.yaml
- cat charts/woodpecker-server/Chart.yaml
when:
path:
include:
- "charts/**"
- ".woodpecker/helm.yml"

lint:
image: alpine/helm:3.5.3
commands:
- helm lint charts/woodpecker-agent/
- helm lint charts/woodpecker-server/
when:
path:
include:
- "charts/**"
- ".woodpecker/helm.yml"

release:
image: quay.io/helmpack/chart-releaser:v1.4.0
Expand All @@ -43,7 +46,3 @@ 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"
10 changes: 6 additions & 4 deletions .woodpecker/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ variables:
# schema changes
- "pipeline/schema/**"

when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
- event: tag
- event: pull_request

pipeline:
vendor:
image: *golang_image
Expand Down Expand Up @@ -124,14 +130,10 @@ services:
environment:
- POSTGRES_USER=postgres
- POSTGRES_HOST_AUTH_METHOD=trust
when:
path: *when_path

service-mysql:
image: mysql:5.6.27
ports: ["3306"]
environment:
- MYSQL_DATABASE=test
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
when:
path: *when_path
20 changes: 8 additions & 12 deletions .woodpecker/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ variables:
# web source code
- "web/**"

when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request
path: *when_path

pipeline:
deps:
image: *node_image
commands:
- cd web/
- corepack enable
- pnpm install --frozen-lockfile
when:
path: *when_path

lint:
group: test
Expand All @@ -23,8 +29,6 @@ pipeline:
- cd web/
- corepack enable
- pnpm lint
when:
path: *when_path

formatcheck:
group: test
Expand All @@ -33,8 +37,6 @@ pipeline:
- cd web/
- corepack enable
- pnpm formatcheck
when:
path: *when_path

typecheck:
group: test
Expand All @@ -43,17 +45,13 @@ pipeline:
- cd web/
- corepack enable
- pnpm typecheck
when:
path: *when_path

securitycheck:
group: test
image: aquasec/trivy:latest
commands:
- trivy fs --exit-code 0 --skip-dirs node_modules/ --severity UNKNOWN,LOW web/
- trivy fs --exit-code 1 --skip-dirs node_modules/ --severity MEDIUM,HIGH,CRITICAL web/
when:
path: *when_path

test:
group: test
Expand All @@ -62,5 +60,3 @@ pipeline:
- cd web/
- corepack enable
- pnpm test
when:
path: *when_path
5 changes: 3 additions & 2 deletions pipeline/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"description": "Use yaml aliases to define variables. Read more: https://woodpecker-ci.org/docs/usage/advanced-yaml-syntax"
},
"clone": { "$ref": "#/definitions/clone" },
"skip_clone": { "type": "boolean" },
"branches": { "$ref": "#/definitions/branches" },
"when": { "$ref": "#/definitions/pipeline_when" },
"pipeline": { "$ref": "#/definitions/pipeline" },
"services": { "$ref": "#/definitions/services" },
"workspace": { "$ref": "#/definitions/workspace" },
"matrix": { "$ref": "#/definitions/matrix" },
"platform": { "$ref": "#/definitions/platform" },
"labels": { "$ref": "#/definitions/labels" },
"skip_clone": { "type": "boolean" },
"depends_on": {
"type": "array",
"minLength": 1,
Expand Down Expand Up @@ -99,7 +100,7 @@
]
},
"pipeline_when": {
"description": "Whole pipelines can be skipped based on conditions. Read more: TODO",
"description": "Whole pipelines can be skipped based on conditions. Read more: https://woodpecker-ci.org/docs/next/usage/pipeline-syntax#when---global-pipeline-conditions",
"oneOf": [
{
"type": "array",
Expand Down