woodpecker/.woodpecker/test.yaml

158 lines
3.4 KiB
YAML
Raw Normal View History

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