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

Run only docs workflow #2203

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 40 additions & 18 deletions .woodpecker/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,23 @@ variables:
- &platforms_server 'linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,linux/riscv64'
- &platforms_preview 'linux/amd64'
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'
- &when
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is unused, so we only need path as variable.

- path: &when_path
# related config files
- ".woodpecker/docker.yml"
# go source code
- 'agent/**'
- 'cli/**'
- 'cmd/**'
- 'docker/**'
- 'server/**'
- 'shared/**'
- 'web/**'
- 'woodpecker-go/**'
pat-s marked this conversation as resolved.
Show resolved Hide resolved
event: [pull_request, tag, deployment]

# vars used on push / tag events only
- publish_logins: &publish_logins
# Default DockerHub login
- publish_logins: &publish_logins # Default DockerHub login
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publish_logins is not default dockerhub login ... the next entry is

- registry: https://index.docker.io/v1/
username:
from_secret: docker_username
Expand All @@ -43,6 +56,8 @@ steps:
pull: true
commands:
- go mod vendor
when:
path: *when_path

###############
# S e r v e r #
Expand All @@ -54,6 +69,8 @@ steps:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
when:
path: *when_path

cross-compile-server-preview:
image: *xgo_image
Expand All @@ -68,10 +85,11 @@ steps:
XGO_VERSION: *xgo_version
when:
event: pull_request
path: *when_path

publish-server-preview:
image: woodpeckerci/plugin-docker-buildx
secrets: [ docker_username, docker_password ]
secrets: [docker_username, docker_password]
group: docker
settings:
repo: woodpeckerci/woodpecker-server
Expand All @@ -80,10 +98,11 @@ steps:
tag: pull_${CI_COMMIT_PULL_REQUEST}
when:
event: pull_request
path: *when_path

publish-server-alpine-preview:
image: woodpeckerci/plugin-docker-buildx
secrets: [ docker_username, docker_password ]
secrets: [docker_username, docker_password]
group: docker
settings:
repo: woodpeckerci/woodpecker-server
Expand All @@ -92,6 +111,7 @@ steps:
tag: pull_${CI_COMMIT_PULL_REQUEST}-alpine
when:
event: pull_request
path: *when_path

cross-compile-server:
image: *xgo_image
Expand All @@ -117,7 +137,7 @@ steps:
repo: *publish_repos_server
dockerfile: docker/Dockerfile.server.multiarch
platforms: *platforms_server
tag: [next, "next-${CI_COMMIT_SHA:0:10}"]
tag: [next, 'next-${CI_COMMIT_SHA:0:10}']
logins: *publish_logins
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
Expand All @@ -130,7 +150,7 @@ steps:
repo: *publish_repos_server
dockerfile: docker/Dockerfile.server.alpine.multiarch
platforms: *platforms_alpine
tag: [next-alpine, "next-${CI_COMMIT_SHA:0:10}-alpine"]
tag: [next-alpine, 'next-${CI_COMMIT_SHA:0:10}-alpine']
logins: *publish_logins
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
Expand Down Expand Up @@ -170,7 +190,7 @@ steps:
dockerfile: docker/Dockerfile.server.multiarch
platforms: *platforms_server
# remove 'latest' on older version branches to avoid accidental downgrade
tag: [latest, "${CI_COMMIT_TAG}"]
tag: [latest, '${CI_COMMIT_TAG}']
logins: *publish_logins
when:
event: tag
Expand All @@ -183,7 +203,7 @@ steps:
dockerfile: docker/Dockerfile.server.alpine.multiarch
platforms: *platforms_alpine
# remove 'latest-alpine' on older version branches to avoid accidental downgrade
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
tag: [latest-alpine, '${CI_COMMIT_TAG}-alpine']
logins: *publish_logins
when:
event: tag
Expand All @@ -195,14 +215,15 @@ steps:
publish-agent-preview:
group: docker
image: woodpeckerci/plugin-docker-buildx
secrets: [ docker_username, docker_password ]
secrets: [docker_username, docker_password]
settings:
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent.multiarch
platforms: *platforms_preview
tag: pull_${CI_COMMIT_PULL_REQUEST}
when:
event: pull_request
path: *when_path

publish-next-agent:
group: docker
Expand All @@ -211,7 +232,7 @@ steps:
repo: *publish_repos_agent
dockerfile: docker/Dockerfile.agent.multiarch
platforms: *platforms_release
tag: [next, "next-${CI_COMMIT_SHA:0:10}"]
tag: [next, 'next-${CI_COMMIT_SHA:0:10}']
logins: *publish_logins
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
Expand All @@ -224,7 +245,7 @@ steps:
repo: *publish_repos_agent
dockerfile: docker/Dockerfile.agent.alpine.multiarch
platforms: *platforms_alpine
tag: [next-alpine, "next-${CI_COMMIT_SHA:0:10}-alpine"]
tag: [next-alpine, 'next-${CI_COMMIT_SHA:0:10}-alpine']
logins: *publish_logins
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
Expand Down Expand Up @@ -264,7 +285,7 @@ steps:
dockerfile: docker/Dockerfile.agent.multiarch
platforms: *platforms_release
# remove 'latest' on older version branches to avoid accidental downgrade
tag: [latest, "${CI_COMMIT_TAG}"]
tag: [latest, '${CI_COMMIT_TAG}']
logins: *publish_logins
when:
event: tag
Expand All @@ -277,7 +298,7 @@ steps:
dockerfile: docker/Dockerfile.agent.alpine.multiarch
platforms: *platforms_alpine
# remove 'latest-alpine' on older version branches to avoid accidental downgrade
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
tag: [latest-alpine, '${CI_COMMIT_TAG}-alpine']
logins: *publish_logins
when:
event: tag
Expand All @@ -289,14 +310,15 @@ steps:
publish-cli-preview:
group: docker
image: woodpeckerci/plugin-docker-buildx
secrets: [ docker_username, docker_password ]
secrets: [docker_username, docker_password]
settings:
repo: woodpeckerci/woodpecker-cli
dockerfile: docker/Dockerfile.cli.multiarch
platforms: *platforms_preview
tag: pull_${CI_COMMIT_PULL_REQUEST}
when:
event: pull_request
path: *when_path

publish-next-cli:
group: docker
Expand All @@ -305,7 +327,7 @@ steps:
repo: *publish_repos_cli
dockerfile: docker/Dockerfile.cli.multiarch
platforms: *platforms_release
tag: [next, "next-${CI_COMMIT_SHA:0:10}"]
tag: [next, 'next-${CI_COMMIT_SHA:0:10}']
logins: *publish_logins
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
Expand All @@ -318,7 +340,7 @@ steps:
repo: *publish_repos_cli
dockerfile: docker/Dockerfile.cli.alpine.multiarch
platforms: *platforms_alpine
tag: [next-alpine, "next-${CI_COMMIT_SHA:0:10}-alpine"]
tag: [next-alpine, 'next-${CI_COMMIT_SHA:0:10}-alpine']
logins: *publish_logins
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
Expand Down Expand Up @@ -358,7 +380,7 @@ steps:
dockerfile: docker/Dockerfile.cli.multiarch
platforms: *platforms_release
# remove 'latest' on older version branches to avoid accidental downgrade
tag: [latest, "${CI_COMMIT_TAG}"]
tag: [latest, '${CI_COMMIT_TAG}']
logins: *publish_logins
when:
event: tag
Expand All @@ -371,7 +393,7 @@ steps:
dockerfile: docker/Dockerfile.cli.alpine.multiarch
platforms: *platforms_alpine
# remove 'latest-alpine' on older version branches to avoid accidental downgrade
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
tag: [latest-alpine, '${CI_COMMIT_TAG}-alpine']
logins: *publish_logins
when:
event: tag
39 changes: 26 additions & 13 deletions .woodpecker/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ steps:
group: prepare
commands:
- go mod vendor
when: *when
when:
path: *when_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this?
It is currently skipped on builds on main completely, so I'd keep it as it is (same for everything else in this file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I am confused with the different use of *when and *when_path across files. Trying to harmonize...


lint-pipeline:
image: *golang_image
Expand All @@ -34,7 +35,6 @@ steps:
when:
- <<: *when
- path:
- ".woodpecker/**"
qwerty287 marked this conversation as resolved.
Show resolved Hide resolved
- "pipeline/schema/**"

dummy-web:
Expand All @@ -43,14 +43,16 @@ steps:
commands:
- mkdir -p web/dist/
- echo "test" > web/dist/index.html
when: *when
when:
path: *when_path

lint:
image: *golang_image
group: test
commands:
- make lint
when: *when
when:
path: *when_path

check_swagger:
image: *golang_image
Expand All @@ -59,18 +61,22 @@ steps:
- "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: *when
when:
path: *when_path

lint-editorconfig:
image: mstruebing/editorconfig-checker
group: test
when:
path: *when_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a event: pull_request here too? Just noticed that this also runs on pushes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it to a few more instances. Probably even more refinement possible across all pipelines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm it's actually missing for everything because you changed the when var to only use path filters. Actually every step should have this filter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pat-s see 55134ad for what I mean - and yes, this changes almost nothing from main because the test workflow is already pretty optimized

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it throughout the day.

Overall I think it's important to reduce/avoid unneeded runs to save resources and time - even if it is a bit of tedious small-scale optimization work.


lint-license-header:
image: *golang_image
commands:
- go install github.com/google/addlicense@latest
- "addlicense -check -ignore \"vendor/**\" **/*.go"
when: *when
when:
path: *when_path

test:
image: *golang_image
Expand All @@ -80,7 +86,8 @@ steps:
- make test-server
- make test-cli
- make test-lib
when: *when
when:
path: *when_path

sqlite:
image: *golang_image
Expand All @@ -89,7 +96,8 @@ steps:
- WOODPECKER_DATABASE_DRIVER=sqlite3
commands:
- make test-server-datastore-coverage
when: *when
when:
path: *when_path

postgres:
image: *golang_image
Expand All @@ -99,7 +107,8 @@ steps:
- WOODPECKER_DATABASE_DATASOURCE=host=service-postgres user=postgres dbname=postgres sslmode=disable
commands:
- make test-server-datastore
when: *when
when:
path: *when_path

mysql:
image: *golang_image
Expand All @@ -109,7 +118,8 @@ steps:
- WOODPECKER_DATABASE_DATASOURCE=root@tcp(service-mysql:3306)/test?parseTime=true
commands:
- make test-server-datastore
when: *when
when:
path: *when_path

codecov:
pull: true
Expand All @@ -123,7 +133,8 @@ steps:
- datastore-coverage.out
token:
from_secret: codecov_token
when: *when
when:
path: *when_path
failure: ignore

services:
Expand All @@ -133,12 +144,14 @@ services:
environment:
- POSTGRES_USER=postgres
- POSTGRES_HOST_AUTH_METHOD=trust
when: *when
when:
path: *when_path

service-mysql:
image: mysql:5.6.27
ports: ["3306"]
environment:
- MYSQL_DATABASE=test
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
when: *when
when:
path: *when_path
Loading