mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-29 15:01:59 +00:00
test
This commit is contained in:
parent
d494b6a959
commit
54de4e6515
9 changed files with 43 additions and 200 deletions
|
@ -96,7 +96,7 @@ steps:
|
||||||
- apt install -y tree
|
- apt install -y tree
|
||||||
- make cross-compile-server
|
- make cross-compile-server
|
||||||
environment:
|
environment:
|
||||||
PLATFORMS: linux|amd64
|
PLATFORMS: linux|arm64
|
||||||
TAGS: bindata sqlite sqlite_unlock_notify netgo
|
TAGS: bindata sqlite sqlite_unlock_notify netgo
|
||||||
XGO_VERSION: *xgo_version
|
XGO_VERSION: *xgo_version
|
||||||
when:
|
when:
|
||||||
|
@ -135,24 +135,24 @@ steps:
|
||||||
settings:
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-server
|
repo: woodpeckerci/woodpecker-server
|
||||||
dockerfile: docker/Dockerfile.server.multiarch
|
dockerfile: docker/Dockerfile.server.multiarch
|
||||||
platforms: *platforms_preview
|
platforms: linux/arm64
|
||||||
tag: pull_${CI_COMMIT_PULL_REQUEST}
|
tag: pull_${CI_COMMIT_PULL_REQUEST}
|
||||||
logins: *publish_logins
|
logins: *publish_logins
|
||||||
when: &when-preview
|
when: &when-preview
|
||||||
evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_images"'
|
evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_images"'
|
||||||
event: pull_request
|
event: pull_request
|
||||||
|
|
||||||
publish-server-alpine-preview:
|
# publish-server-alpine-preview:
|
||||||
depends_on:
|
# depends_on:
|
||||||
- cross-compile-server-preview
|
# - cross-compile-server-preview
|
||||||
image: *buildx_plugin
|
# image: *buildx_plugin
|
||||||
settings:
|
# settings:
|
||||||
repo: woodpeckerci/woodpecker-server
|
# repo: woodpeckerci/woodpecker-server
|
||||||
dockerfile: docker/Dockerfile.server.alpine.multiarch
|
# dockerfile: docker/Dockerfile.server.alpine.multiarch
|
||||||
platforms: *platforms_preview
|
# platforms: linux/arm64
|
||||||
tag: pull_${CI_COMMIT_PULL_REQUEST}-alpine
|
# tag: pull_${CI_COMMIT_PULL_REQUEST}-alpine
|
||||||
logins: *publish_logins
|
# logins: *publish_logins
|
||||||
when: *when-preview
|
# when: *when-preview
|
||||||
|
|
||||||
build-server-dryrun:
|
build-server-dryrun:
|
||||||
depends_on:
|
depends_on:
|
||||||
|
@ -239,7 +239,7 @@ steps:
|
||||||
settings:
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-agent
|
repo: woodpeckerci/woodpecker-agent
|
||||||
dockerfile: docker/Dockerfile.agent.multiarch
|
dockerfile: docker/Dockerfile.agent.multiarch
|
||||||
platforms: *platforms_preview
|
platforms: linux/arm64
|
||||||
tag: pull_${CI_COMMIT_PULL_REQUEST}
|
tag: pull_${CI_COMMIT_PULL_REQUEST}
|
||||||
build_args: *build_args
|
build_args: *build_args
|
||||||
logins: *publish_logins
|
logins: *publish_logins
|
||||||
|
@ -331,18 +331,18 @@ steps:
|
||||||
# C L I #
|
# C L I #
|
||||||
#########
|
#########
|
||||||
|
|
||||||
publish-cli-preview:
|
# publish-cli-preview:
|
||||||
depends_on:
|
# depends_on:
|
||||||
- vendor
|
# - vendor
|
||||||
image: *buildx_plugin
|
# image: *buildx_plugin
|
||||||
settings:
|
# settings:
|
||||||
repo: woodpeckerci/woodpecker-cli
|
# repo: woodpeckerci/woodpecker-cli
|
||||||
dockerfile: docker/Dockerfile.cli.multiarch
|
# dockerfile: docker/Dockerfile.cli.multiarch
|
||||||
platforms: *platforms_preview
|
# platforms: *platforms_preview
|
||||||
tag: pull_${CI_COMMIT_PULL_REQUEST}
|
# tag: pull_${CI_COMMIT_PULL_REQUEST}
|
||||||
build_args: *build_args
|
# build_args: *build_args
|
||||||
logins: *publish_logins
|
# logins: *publish_logins
|
||||||
when: *when-preview
|
# when: *when-preview
|
||||||
|
|
||||||
build-cli-dryrun:
|
build-cli-dryrun:
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -1,160 +0,0 @@
|
||||||
variables:
|
|
||||||
- &golang_image 'docker.io/golang:1.21.5'
|
|
||||||
- &when
|
|
||||||
- path: &when_path # related config files
|
|
||||||
- '.woodpecker/test.yaml'
|
|
||||||
- '.golangci.yaml'
|
|
||||||
# go source code
|
|
||||||
- '**/*.go'
|
|
||||||
- 'go.*'
|
|
||||||
# schema changes
|
|
||||||
- 'pipeline/schema/**'
|
|
||||||
event: pull_request
|
|
||||||
- event: push
|
|
||||||
branch: renovate/*
|
|
||||||
path: *when_path
|
|
||||||
|
|
||||||
when:
|
|
||||||
- event: pull_request
|
|
||||||
- event: push
|
|
||||||
branch: renovate/*
|
|
||||||
- event: push
|
|
||||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
|
||||||
path: *when_path
|
|
||||||
|
|
||||||
steps:
|
|
||||||
vendor:
|
|
||||||
image: *golang_image
|
|
||||||
commands:
|
|
||||||
- go mod vendor
|
|
||||||
when:
|
|
||||||
path:
|
|
||||||
- <<: *when_path
|
|
||||||
- '.woodpecker/**'
|
|
||||||
|
|
||||||
lint-pipeline:
|
|
||||||
depends_on:
|
|
||||||
- vendor
|
|
||||||
image: *golang_image
|
|
||||||
commands:
|
|
||||||
- go run go.woodpecker-ci.org/woodpecker/v2/cmd/cli lint
|
|
||||||
environment:
|
|
||||||
WOODPECKER_DISABLE_UPDATE_CHECK: true
|
|
||||||
when:
|
|
||||||
- event: pull_request
|
|
||||||
path:
|
|
||||||
- '.woodpecker/**'
|
|
||||||
|
|
||||||
dummy-web:
|
|
||||||
image: *golang_image
|
|
||||||
commands:
|
|
||||||
- mkdir -p web/dist/
|
|
||||||
- echo "test" > web/dist/index.html
|
|
||||||
when:
|
|
||||||
- path: *when_path
|
|
||||||
|
|
||||||
lint:
|
|
||||||
depends_on:
|
|
||||||
- vendor
|
|
||||||
image: *golang_image
|
|
||||||
commands:
|
|
||||||
- make lint
|
|
||||||
when: *when
|
|
||||||
|
|
||||||
check-swagger:
|
|
||||||
depends_on:
|
|
||||||
- vendor
|
|
||||||
image: *golang_image
|
|
||||||
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: *when
|
|
||||||
|
|
||||||
lint-license-header:
|
|
||||||
image: *golang_image
|
|
||||||
commands:
|
|
||||||
- go install github.com/google/addlicense@latest
|
|
||||||
- 'addlicense -check -ignore "vendor/**" **/*.go'
|
|
||||||
when: *when
|
|
||||||
|
|
||||||
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
|
|
||||||
WOODPECKER_DATABASE_DATASOURCE: 'host=postgres user=postgres dbname=postgres sslmode=disable'
|
|
||||||
commands:
|
|
||||||
- make test-server-datastore
|
|
||||||
when: *when
|
|
||||||
|
|
||||||
mysql:
|
|
||||||
depends_on:
|
|
||||||
- vendor
|
|
||||||
image: *golang_image
|
|
||||||
environment:
|
|
||||||
WOODPECKER_DATABASE_DRIVER: mysql
|
|
||||||
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.2
|
|
||||||
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:
|
|
||||||
postgres:
|
|
||||||
image: docker.io/postgres:16
|
|
||||||
ports: ['5432']
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
|
||||||
when: *when
|
|
||||||
|
|
||||||
mysql:
|
|
||||||
image: docker.io/mysql:8.2.0
|
|
||||||
ports: ['3306']
|
|
||||||
environment:
|
|
||||||
MYSQL_DATABASE: test
|
|
||||||
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
|
||||||
when: *when
|
|
|
@ -106,20 +106,11 @@ func toHostConfig(step *types.Step) *container.HostConfig {
|
||||||
if len(step.Devices) != 0 {
|
if len(step.Devices) != 0 {
|
||||||
config.Devices = toDev(step.Devices)
|
config.Devices = toDev(step.Devices)
|
||||||
}
|
}
|
||||||
if len(step.Volumes) != 0 {
|
|
||||||
|
if !step.UseTmpfs {
|
||||||
config.Binds = step.Volumes
|
config.Binds = step.Volumes
|
||||||
}
|
} else {
|
||||||
config.Tmpfs = map[string]string{}
|
config.Tmpfs = map[string]string{"/woodpecker": ""}
|
||||||
for _, path := range step.Tmpfs {
|
|
||||||
if !strings.Contains(path, ":") {
|
|
||||||
config.Tmpfs[path] = ""
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
parts, err := splitVolumeParts(path)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
config.Tmpfs[parts[0]] = parts[1]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -154,6 +154,7 @@ func TestToConfigFull(t *testing.T) {
|
||||||
AuthConfig: backend.Auth{Username: "user", Password: "123456"},
|
AuthConfig: backend.Auth{Username: "user", Password: "123456"},
|
||||||
NetworkMode: "bridge",
|
NetworkMode: "bridge",
|
||||||
Ports: []backend.Port{{Number: 21}, {Number: 22}},
|
Ports: []backend.Port{{Number: 21}, {Number: 22}},
|
||||||
|
UseTmpfs: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.NotNil(t, conf)
|
assert.NotNil(t, conf)
|
||||||
|
|
|
@ -213,7 +213,11 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str
|
||||||
}
|
}
|
||||||
|
|
||||||
// add default volumes to the host configuration
|
// add default volumes to the host configuration
|
||||||
hostConfig.Binds = utils.DeduplicateStrings(append(hostConfig.Binds, e.volumes...))
|
if step.UseTmpfs {
|
||||||
|
hostConfig.Binds = e.volumes
|
||||||
|
} else {
|
||||||
|
hostConfig.Binds = utils.DeduplicateStrings(append(hostConfig.Binds, e.volumes...))
|
||||||
|
}
|
||||||
|
|
||||||
_, err := e.client.ContainerCreate(ctx, config, hostConfig, nil, nil, containerName)
|
_, err := e.client.ContainerCreate(ctx, config, hostConfig, nil, nil, containerName)
|
||||||
if client.IsErrNotFound(err) {
|
if client.IsErrNotFound(err) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ type Step struct {
|
||||||
NetworkMode string `json:"network_mode,omitempty"`
|
NetworkMode string `json:"network_mode,omitempty"`
|
||||||
Ports []Port `json:"ports,omitempty"`
|
Ports []Port `json:"ports,omitempty"`
|
||||||
BackendOptions map[string]any `json:"backend_options,omitempty"`
|
BackendOptions map[string]any `json:"backend_options,omitempty"`
|
||||||
|
UseTmpfs bool `json:"use_tmpfs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StepType identifies the type of step
|
// StepType identifies the type of step
|
||||||
|
|
|
@ -215,6 +215,7 @@ func (c *Compiler) createProcess(container *yaml_types.Container, stepType backe
|
||||||
NetworkMode: networkMode,
|
NetworkMode: networkMode,
|
||||||
Ports: ports,
|
Ports: ports,
|
||||||
BackendOptions: container.BackendOptions,
|
BackendOptions: container.BackendOptions,
|
||||||
|
UseTmpfs: container.UseTmpfs,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -371,6 +371,10 @@
|
||||||
},
|
},
|
||||||
"backend_options": {
|
"backend_options": {
|
||||||
"$ref": "#/definitions/step_backend_options"
|
"$ref": "#/definitions/step_backend_options"
|
||||||
|
},
|
||||||
|
"use_tmpfs": {
|
||||||
|
"description": "Use a tmpfs volume instead of a local volume for the working directory mount",
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -71,6 +71,7 @@ type (
|
||||||
Networks Networks `yaml:"networks,omitempty"`
|
Networks Networks `yaml:"networks,omitempty"`
|
||||||
ShmSize base.MemStringOrInt `yaml:"shm_size,omitempty"`
|
ShmSize base.MemStringOrInt `yaml:"shm_size,omitempty"`
|
||||||
Tmpfs []string `yaml:"tmpfs,omitempty"`
|
Tmpfs []string `yaml:"tmpfs,omitempty"`
|
||||||
|
UseTmpfs bool `yaml:"use_tmpfs,omitempty"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue