mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-12 08:23:48 +02:00
14177635b6
# Summary This PR drops the outdated former swagger.yaml/json and introduced automatic API document generation from Go code. The generated code is also used to generate documentation/markdown for the community page, as well as enable the Woodpecker server to serve a Swagger Web UI for manual tinkering. I did opt-in for gin-swagger, a middleware for the Gin framework, to ease implementation and have a sophisticated output. This middleware only produces Swagger v2 specs. AFAIK the newer OpenApi 3x tooling is not yet that mature, so I guess that's fine for now. ## Implemenation notes - former swagger.json files removed - former // swagger godocs removed - introduced new dependency gin-swagger, which uses godoc annotations on top of Gin Handler functions. - reworked Makefile to automatically generate Go code for the server - introduce new dependency go-swagger, to generate Markdown for documentation purposes - add a Swagger Web UI, incl. capabilities for manual API exploration - consider relative root paths in the implementation - write documentation for all exposed API endpoints - incl. API docs in the community website (auto-generated) - provide developer documentation, for the Woodpecker authors - no other existing logic/code was intentionally changed --------- close #292 --------- Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>
149 lines
3.3 KiB
YAML
149 lines
3.3 KiB
YAML
variables:
|
|
- &golang_image 'golang:1.20.2'
|
|
- &when_path
|
|
# related config files
|
|
- ".woodpecker/test.yml"
|
|
- ".golangci.yml"
|
|
# go source code
|
|
- "**/*.go"
|
|
- "go.*"
|
|
# schema changes
|
|
- "pipeline/schema/**"
|
|
|
|
pipeline:
|
|
vendor:
|
|
image: *golang_image
|
|
group: prepare
|
|
commands:
|
|
- go mod vendor
|
|
when:
|
|
path: *when_path
|
|
|
|
lint-pipeline:
|
|
image: *golang_image
|
|
commands:
|
|
- go run github.com/woodpecker-ci/woodpecker/cmd/cli lint
|
|
when:
|
|
path:
|
|
- ".woodpecker/**"
|
|
- "pipeline/schema/**"
|
|
|
|
dummy-web:
|
|
image: *golang_image
|
|
group: prepare
|
|
commands:
|
|
- mkdir -p web/dist/
|
|
- echo "test" > web/dist/index.html
|
|
when:
|
|
path: *when_path
|
|
|
|
lint:
|
|
image: *golang_image
|
|
group: test
|
|
commands:
|
|
- make lint
|
|
when:
|
|
path: *when_path
|
|
|
|
check_swagger:
|
|
image: *golang_image
|
|
group: test
|
|
commands:
|
|
- "make generate-swagger"
|
|
- "DIFF=$(git diff | head)"
|
|
- "[ -n \"$DIFF\" ] && { echo \"swagger not up to date, exec 'make generate-swagger' and commit\"; exit 1; } || true"
|
|
when:
|
|
path: *when_path
|
|
|
|
lint-editorconfig:
|
|
image: mstruebing/editorconfig-checker
|
|
group: test
|
|
|
|
# Fixed with https://github.com/woodpecker-ci/woodpecker/pull/1753
|
|
# securitycheck:
|
|
# group: test
|
|
# image: aquasec/trivy:latest
|
|
# commands:
|
|
# - 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 .
|
|
# when:
|
|
# path: *when_path
|
|
|
|
test:
|
|
image: *golang_image
|
|
group: test
|
|
commands:
|
|
- make test-agent
|
|
- make test-server
|
|
- make test-cli
|
|
- make test-lib
|
|
when:
|
|
path: *when_path
|
|
|
|
sqlite:
|
|
image: *golang_image
|
|
group: test
|
|
environment:
|
|
- WOODPECKER_DATABASE_DRIVER=sqlite3
|
|
commands:
|
|
- make test-server-datastore-coverage
|
|
when:
|
|
path: *when_path
|
|
|
|
postgres:
|
|
image: *golang_image
|
|
group: test
|
|
environment:
|
|
- WOODPECKER_DATABASE_DRIVER=postgres
|
|
- WOODPECKER_DATABASE_DATASOURCE=host=service-postgres user=postgres dbname=postgres sslmode=disable
|
|
commands:
|
|
- make test-server-datastore
|
|
when:
|
|
path: *when_path
|
|
|
|
mysql:
|
|
image: *golang_image
|
|
group: test
|
|
environment:
|
|
- WOODPECKER_DATABASE_DRIVER=mysql
|
|
- WOODPECKER_DATABASE_DATASOURCE=root@tcp(service-mysql:3306)/test?parseTime=true
|
|
commands:
|
|
- make test-server-datastore
|
|
when:
|
|
path: *when_path
|
|
|
|
codecov:
|
|
pull: true
|
|
image: woodpeckerci/plugin-codecov:next-alpine
|
|
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:
|
|
service-postgres:
|
|
image: postgres:11
|
|
ports: ["5432"]
|
|
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
|