Speedup pipeline (#1966)

- only build preview images for x86
- do not run `test` and `web` on default branch
This commit is contained in:
6543 2023-07-10 14:46:55 +02:00 committed by GitHub
parent 2c1fc4b500
commit a6d2c78916
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 56 deletions

View file

@ -9,7 +9,7 @@ variables:
- &xgo_version 'go-1.20.2' - &xgo_version 'go-1.20.2'
- &platforms_release 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386,linux/amd64,linux/ppc64le,linux/riscv64,linux/s390x,windows/amd64,freebsd/arm64,freebsd/amd64,openbsd/arm64,openbsd/amd64' - &platforms_release 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386,linux/amd64,linux/ppc64le,linux/riscv64,linux/s390x,windows/amd64,freebsd/arm64,freebsd/amd64,openbsd/arm64,openbsd/amd64'
- &platforms_server 'linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,linux/riscv64' - &platforms_server 'linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,linux/riscv64'
- &platforms_preview 'linux/arm/v6,linux/arm64/v8,linux/amd64,linux/riscv64,windows/amd64' - &platforms_preview 'linux/amd64'
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le' - &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'
steps: steps:
@ -30,7 +30,7 @@ steps:
- pnpm install --frozen-lockfile - pnpm install --frozen-lockfile
- pnpm build - pnpm build
cross-compile-server: cross-compile-server-preview:
image: *xgo_image image: *xgo_image
pull: true pull: true
commands: commands:
@ -38,9 +38,11 @@ steps:
- apt install -y tree - apt install -y tree
- make cross-compile-server - make cross-compile-server
environment: environment:
PLATFORMS: linux|arm/v7;linux|arm64/v8;linux|amd64;linux|ppc64le;linux|riscv64 PLATFORMS: linux|amd64
TAGS: bindata sqlite sqlite_unlock_notify netgo TAGS: bindata sqlite sqlite_unlock_notify netgo
XGO_VERSION: *xgo_version XGO_VERSION: *xgo_version
when:
event: pull_request
publish-server-preview: publish-server-preview:
image: woodpeckerci/plugin-docker-buildx image: woodpeckerci/plugin-docker-buildx
@ -49,7 +51,7 @@ steps:
settings: settings:
repo: woodpeckerci/woodpecker-server repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server.multiarch dockerfile: docker/Dockerfile.server.multiarch
platforms: *platforms_server platforms: *platforms_preview
tag: pull_${CI_COMMIT_PULL_REQUEST} tag: pull_${CI_COMMIT_PULL_REQUEST}
when: when:
event: pull_request event: pull_request
@ -61,11 +63,26 @@ steps:
settings: settings:
repo: woodpeckerci/woodpecker-server repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server.alpine.multiarch dockerfile: docker/Dockerfile.server.alpine.multiarch
platforms: *platforms_alpine platforms: *platforms_preview
tag: pull_${CI_COMMIT_PULL_REQUEST}-alpine tag: pull_${CI_COMMIT_PULL_REQUEST}-alpine
when: when:
event: pull_request event: pull_request
cross-compile-server:
image: *xgo_image
pull: true
commands:
- apt update
- apt install -y tree
- make cross-compile-server
environment:
PLATFORMS: linux|arm/v7;linux|arm64/v8;linux|amd64;linux|ppc64le;linux|riscv64
TAGS: bindata sqlite sqlite_unlock_notify netgo
XGO_VERSION: *xgo_version
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push
publish-next-server: publish-next-server:
image: woodpeckerci/plugin-docker-buildx image: woodpeckerci/plugin-docker-buildx
group: docker group: docker

View file

@ -1,14 +1,20 @@
variables: variables:
- &golang_image 'golang:1.20.2' - &golang_image 'golang:1.20.2'
- &when_path - &when
# related config files - path: &when_path
- ".woodpecker/test.yml" # related config files
- ".golangci.yml" - ".woodpecker/test.yml"
# go source code - ".golangci.yml"
- "**/*.go" # go source code
- "go.*" - "**/*.go"
# schema changes - "go.*"
- "pipeline/schema/**" # schema changes
- "pipeline/schema/**"
branch:
exclude: ${CI_REPO_DEFAULT_BRANCH}
event: push
- path: *when_path
event: [pull_request, tag, deployment]
steps: steps:
vendor: vendor:
@ -16,15 +22,15 @@ steps:
group: prepare group: prepare
commands: commands:
- go mod vendor - go mod vendor
when: when: *when
path: *when_path
lint-pipeline: lint-pipeline:
image: *golang_image image: *golang_image
commands: commands:
- go run github.com/woodpecker-ci/woodpecker/cmd/cli lint - go run github.com/woodpecker-ci/woodpecker/cmd/cli lint
when: when:
path: - <<: *when
- path:
- ".woodpecker/**" - ".woodpecker/**"
- "pipeline/schema/**" - "pipeline/schema/**"
@ -34,16 +40,14 @@ steps:
commands: commands:
- mkdir -p web/dist/ - mkdir -p web/dist/
- echo "test" > web/dist/index.html - echo "test" > web/dist/index.html
when: when: *when
path: *when_path
lint: lint:
image: *golang_image image: *golang_image
group: test group: test
commands: commands:
- make lint - make lint
when: when: *when
path: *when_path
check_swagger: check_swagger:
image: *golang_image image: *golang_image
@ -52,8 +56,7 @@ steps:
- "make generate-swagger" - "make generate-swagger"
- "DIFF=$(git diff | head)" - "DIFF=$(git diff | head)"
- "[ -n \"$DIFF\" ] && { echo \"swagger not up to date, exec 'make generate-swagger' and commit\"; exit 1; } || true" - "[ -n \"$DIFF\" ] && { echo \"swagger not up to date, exec 'make generate-swagger' and commit\"; exit 1; } || true"
when: when: *when
path: *when_path
lint-editorconfig: lint-editorconfig:
image: mstruebing/editorconfig-checker image: mstruebing/editorconfig-checker
@ -66,8 +69,7 @@ steps:
# commands: # commands:
# - trivy fs --exit-code 0 --skip-dirs web/ --skip-dirs docs/ --severity UNKNOWN,LOW . # - trivy fs --exit-code 0 --skip-dirs web/ --skip-dirs docs/ --severity UNKNOWN,LOW .
# - trivy fs --exit-code 1 --skip-dirs web/ --skip-dirs docs/ --severity MEDIUM,HIGH,CRITICAL . # - trivy fs --exit-code 1 --skip-dirs web/ --skip-dirs docs/ --severity MEDIUM,HIGH,CRITICAL .
# when: # when: *when
# path: *when_path
test: test:
image: *golang_image image: *golang_image
@ -77,8 +79,7 @@ steps:
- make test-server - make test-server
- make test-cli - make test-cli
- make test-lib - make test-lib
when: when: *when
path: *when_path
sqlite: sqlite:
image: *golang_image image: *golang_image
@ -87,8 +88,7 @@ steps:
- WOODPECKER_DATABASE_DRIVER=sqlite3 - WOODPECKER_DATABASE_DRIVER=sqlite3
commands: commands:
- make test-server-datastore-coverage - make test-server-datastore-coverage
when: when: *when
path: *when_path
postgres: postgres:
image: *golang_image image: *golang_image
@ -98,8 +98,7 @@ steps:
- WOODPECKER_DATABASE_DATASOURCE=host=service-postgres user=postgres dbname=postgres sslmode=disable - WOODPECKER_DATABASE_DATASOURCE=host=service-postgres user=postgres dbname=postgres sslmode=disable
commands: commands:
- make test-server-datastore - make test-server-datastore
when: when: *when
path: *when_path
mysql: mysql:
image: *golang_image image: *golang_image
@ -109,8 +108,7 @@ steps:
- WOODPECKER_DATABASE_DATASOURCE=root@tcp(service-mysql:3306)/test?parseTime=true - WOODPECKER_DATABASE_DATASOURCE=root@tcp(service-mysql:3306)/test?parseTime=true
commands: commands:
- make test-server-datastore - make test-server-datastore
when: when: *when
path: *when_path
codecov: codecov:
pull: true pull: true
@ -124,8 +122,7 @@ steps:
- datastore-coverage.out - datastore-coverage.out
token: token:
from_secret: codecov_token from_secret: codecov_token
when: when: *when
path: *when_path
failure: ignore failure: ignore
services: services:
@ -135,8 +132,7 @@ services:
environment: environment:
- POSTGRES_USER=postgres - POSTGRES_USER=postgres
- POSTGRES_HOST_AUTH_METHOD=trust - POSTGRES_HOST_AUTH_METHOD=trust
when: when: *when
path: *when_path
service-mysql: service-mysql:
image: mysql:5.6.27 image: mysql:5.6.27
@ -144,5 +140,4 @@ services:
environment: environment:
- MYSQL_DATABASE=test - MYSQL_DATABASE=test
- MYSQL_ALLOW_EMPTY_PASSWORD=yes - MYSQL_ALLOW_EMPTY_PASSWORD=yes
when: when: *when
path: *when_path

View file

@ -1,10 +1,16 @@
variables: variables:
- &node_image 'node:18-alpine' - &node_image 'node:18-alpine'
- &when_path - &when
# related config files - path: &when_path
- ".woodpecker/web.yml" # related config files
# web source code - ".woodpecker/web.yml"
- "web/**" # web source code
- "web/**"
branch:
exclude: ${CI_REPO_DEFAULT_BRANCH}
event: push
- path: *when_path
event: [pull_request, tag, deployment]
steps: steps:
deps: deps:
@ -13,8 +19,7 @@ steps:
commands: commands:
- corepack enable - corepack enable
- pnpm install --frozen-lockfile - pnpm install --frozen-lockfile
when: when: *when
path: *when_path
lint: lint:
group: test group: test
@ -23,8 +28,7 @@ steps:
commands: commands:
- corepack enable - corepack enable
- pnpm lint - pnpm lint
when: when: *when
path: *when_path
formatcheck: formatcheck:
group: test group: test
@ -33,8 +37,7 @@ steps:
commands: commands:
- corepack enable - corepack enable
- pnpm formatcheck - pnpm formatcheck
when: when: *when
path: *when_path
typecheck: typecheck:
group: test group: test
@ -43,8 +46,7 @@ steps:
commands: commands:
- corepack enable - corepack enable
- pnpm typecheck - pnpm typecheck
when: when: *when
path: *when_path
securitycheck: securitycheck:
group: test group: test
@ -52,8 +54,7 @@ steps:
commands: commands:
- trivy fs --exit-code 0 --skip-dirs node_modules/ --severity UNKNOWN,LOW web/ - 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/ - trivy fs --exit-code 1 --skip-dirs node_modules/ --severity MEDIUM,HIGH,CRITICAL web/
when: when: *when
path: *when_path
test: test:
group: test group: test
@ -62,5 +63,4 @@ steps:
commands: commands:
- corepack enable - corepack enable
- pnpm test - pnpm test
when: when: *when
path: *when_path