2022-07-17 18:25:56 +02:00
|
|
|
variables:
|
2024-10-05 11:32:30 +02:00
|
|
|
- &golang_image 'docker.io/golang:1.23'
|
2023-07-10 14:46:55 +02:00
|
|
|
- &when
|
2023-10-24 14:42:05 +02:00
|
|
|
- path: &when_path # related config files
|
2024-01-11 19:43:54 +02:00
|
|
|
- '.woodpecker/test.yaml'
|
2024-01-10 16:10:56 +02:00
|
|
|
- '.golangci.yaml'
|
2023-07-10 14:46:55 +02:00
|
|
|
# go source code
|
2023-10-24 14:42:05 +02:00
|
|
|
- '**/*.go'
|
|
|
|
- 'go.*'
|
2023-07-10 14:46:55 +02:00
|
|
|
# schema changes
|
2023-10-24 14:42:05 +02:00
|
|
|
- 'pipeline/schema/**'
|
2024-01-10 16:10:56 +02:00
|
|
|
event: pull_request
|
2022-07-17 18:25:56 +02:00
|
|
|
|
2024-02-23 07:05:25 +02:00
|
|
|
when:
|
|
|
|
- event: pull_request
|
|
|
|
- event: push
|
|
|
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
|
|
|
path: *when_path
|
|
|
|
|
2023-06-30 13:32:17 +02:00
|
|
|
steps:
|
2022-08-14 19:04:19 +02:00
|
|
|
vendor:
|
|
|
|
image: *golang_image
|
|
|
|
commands:
|
|
|
|
- go mod vendor
|
2023-10-14 13:04:46 +02:00
|
|
|
when:
|
2024-01-10 16:10:56 +02:00
|
|
|
path:
|
|
|
|
- <<: *when_path
|
|
|
|
- '.woodpecker/**'
|
2022-08-14 19:04:19 +02:00
|
|
|
|
2022-05-17 17:59:51 +02:00
|
|
|
lint-pipeline:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- vendor
|
2022-07-17 18:25:56 +02:00
|
|
|
image: *golang_image
|
2022-05-17 17:59:51 +02:00
|
|
|
commands:
|
2023-12-08 09:15:08 +02:00
|
|
|
- go run go.woodpecker-ci.org/woodpecker/v2/cmd/cli lint
|
2024-03-18 15:21:53 +02:00
|
|
|
environment:
|
|
|
|
WOODPECKER_DISABLE_UPDATE_CHECK: true
|
2024-11-13 17:28:02 +02:00
|
|
|
WOODPECKER_LINT_STRICT: true
|
2024-10-09 15:15:24 +02:00
|
|
|
WOODPECKER_PLUGINS_PRIVILEGED: 'docker.io/woodpeckerci/plugin-docker-buildx:5.0.0'
|
2022-05-20 05:31:19 +02:00
|
|
|
when:
|
2024-01-10 16:10:56 +02:00
|
|
|
- event: pull_request
|
|
|
|
path:
|
2023-10-24 14:42:05 +02:00
|
|
|
- '.woodpecker/**'
|
2022-05-17 17:59:51 +02:00
|
|
|
|
2021-11-30 18:46:19 +02:00
|
|
|
dummy-web:
|
2022-07-17 18:25:56 +02:00
|
|
|
image: *golang_image
|
2021-11-30 18:46:19 +02:00
|
|
|
commands:
|
|
|
|
- mkdir -p web/dist/
|
|
|
|
- echo "test" > web/dist/index.html
|
2023-10-14 14:07:46 +02:00
|
|
|
when:
|
|
|
|
- path: *when_path
|
2021-11-30 18:46:19 +02:00
|
|
|
|
|
|
|
lint:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- vendor
|
2022-07-17 18:25:56 +02:00
|
|
|
image: *golang_image
|
2021-11-30 18:46:19 +02:00
|
|
|
commands:
|
|
|
|
- make lint
|
2023-07-10 14:46:55 +02:00
|
|
|
when: *when
|
2021-11-30 18:46:19 +02:00
|
|
|
|
2024-11-23 10:17:19 +02:00
|
|
|
check-openapi:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- vendor
|
2023-06-03 21:38:36 +02:00
|
|
|
image: *golang_image
|
|
|
|
commands:
|
2024-11-23 10:17:19 +02:00
|
|
|
- 'make generate-openapi'
|
2023-10-24 14:42:05 +02:00
|
|
|
- 'DIFF=$(git diff | head)'
|
2024-11-23 10:17:19 +02:00
|
|
|
- '[ -n "$DIFF" ] && { echo "openapi not up to date, exec `make generate-openapi` and commit"; exit 1; } || true'
|
2023-07-10 14:46:55 +02:00
|
|
|
when: *when
|
2023-06-03 21:38:36 +02:00
|
|
|
|
2023-08-10 11:06:00 +02:00
|
|
|
lint-license-header:
|
|
|
|
image: *golang_image
|
|
|
|
commands:
|
2024-05-24 22:35:04 +02:00
|
|
|
- go install github.com/google/addlicense@latest # cspell:words addlicense
|
2023-10-24 14:42:05 +02:00
|
|
|
- 'addlicense -check -ignore "vendor/**" **/*.go'
|
|
|
|
when: *when
|
|
|
|
|
2021-12-07 02:13:31 +02:00
|
|
|
test:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- vendor
|
2022-07-17 18:25:56 +02:00
|
|
|
image: *golang_image
|
2021-11-30 18:46:19 +02:00
|
|
|
commands:
|
|
|
|
- make test-agent
|
|
|
|
- make test-server
|
|
|
|
- make test-cli
|
|
|
|
- make test-lib
|
2023-10-14 13:04:46 +02:00
|
|
|
when:
|
|
|
|
- path: *when_path
|
2021-11-30 18:46:19 +02:00
|
|
|
|
|
|
|
sqlite:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- vendor
|
2022-07-17 18:25:56 +02:00
|
|
|
image: *golang_image
|
2021-11-30 18:46:19 +02:00
|
|
|
environment:
|
2024-03-18 15:21:53 +02:00
|
|
|
WOODPECKER_DATABASE_DRIVER: sqlite3
|
2021-11-30 18:46:19 +02:00
|
|
|
commands:
|
2022-02-01 20:34:56 +02:00
|
|
|
- make test-server-datastore-coverage
|
2023-10-14 13:04:46 +02:00
|
|
|
when:
|
|
|
|
- path: *when_path
|
2021-11-30 18:46:19 +02:00
|
|
|
|
|
|
|
postgres:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- vendor
|
2022-07-17 18:25:56 +02:00
|
|
|
image: *golang_image
|
2021-11-30 18:46:19 +02:00
|
|
|
environment:
|
2024-03-18 15:21:53 +02:00
|
|
|
WOODPECKER_DATABASE_DRIVER: postgres
|
2024-05-24 22:35:04 +02:00
|
|
|
WOODPECKER_DATABASE_DATASOURCE: 'host=postgres user=postgres dbname=postgres sslmode=disable' # cspell:disable-line
|
2021-11-30 18:46:19 +02:00
|
|
|
commands:
|
|
|
|
- make test-server-datastore
|
2023-07-10 14:46:55 +02:00
|
|
|
when: *when
|
2021-11-30 18:46:19 +02:00
|
|
|
|
|
|
|
mysql:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- vendor
|
2022-07-17 18:25:56 +02:00
|
|
|
image: *golang_image
|
2021-11-30 18:46:19 +02:00
|
|
|
environment:
|
2024-03-18 15:21:53 +02:00
|
|
|
WOODPECKER_DATABASE_DRIVER: mysql
|
2024-03-18 21:41:00 +02:00
|
|
|
WOODPECKER_DATABASE_DATASOURCE: root@tcp(mysql:3306)/test?parseTime=true
|
2021-11-30 18:46:19 +02:00
|
|
|
commands:
|
|
|
|
- make test-server-datastore
|
2023-07-10 14:46:55 +02:00
|
|
|
when: *when
|
2021-11-30 18:46:19 +02:00
|
|
|
|
2022-02-01 20:34:56 +02:00
|
|
|
codecov:
|
2023-12-28 17:39:14 +02:00
|
|
|
depends_on:
|
|
|
|
- test
|
|
|
|
- sqlite
|
2022-02-01 20:34:56 +02:00
|
|
|
pull: true
|
2024-10-05 14:52:14 +02:00
|
|
|
image: docker.io/woodpeckerci/plugin-codecov:2.1.5
|
2022-02-01 20:34:56 +02:00
|
|
|
settings:
|
|
|
|
files:
|
|
|
|
- agent-coverage.out
|
|
|
|
- cli-coverage.out
|
2022-10-01 11:51:04 +02:00
|
|
|
- coverage.out
|
2022-02-01 20:34:56 +02:00
|
|
|
- server-coverage.out
|
|
|
|
- datastore-coverage.out
|
|
|
|
token:
|
|
|
|
from_secret: codecov_token
|
2023-10-14 13:04:46 +02:00
|
|
|
when:
|
|
|
|
- path: *when_path
|
2023-03-21 21:00:45 +02:00
|
|
|
failure: ignore
|
2022-02-01 20:34:56 +02:00
|
|
|
|
2021-11-30 18:46:19 +02:00
|
|
|
services:
|
2024-03-18 21:41:00 +02:00
|
|
|
postgres:
|
2024-10-05 15:23:53 +02:00
|
|
|
image: docker.io/postgres:17
|
2023-10-24 14:42:05 +02:00
|
|
|
ports: ['5432']
|
2021-11-30 18:46:19 +02:00
|
|
|
environment:
|
2024-03-18 15:21:53 +02:00
|
|
|
POSTGRES_USER: postgres
|
|
|
|
POSTGRES_HOST_AUTH_METHOD: trust
|
2023-07-10 14:46:55 +02:00
|
|
|
when: *when
|
2022-01-29 14:58:55 +02:00
|
|
|
|
2024-03-18 21:41:00 +02:00
|
|
|
mysql:
|
2024-10-20 10:59:46 +02:00
|
|
|
image: docker.io/mysql:9.1.0
|
2023-10-24 14:42:05 +02:00
|
|
|
ports: ['3306']
|
2021-11-30 18:46:19 +02:00
|
|
|
environment:
|
2024-03-18 15:21:53 +02:00
|
|
|
MYSQL_DATABASE: test
|
|
|
|
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
2023-07-10 14:46:55 +02:00
|
|
|
when: *when
|