feat: migrate from drone to woodpecker (#86)
ci/woodpecker/push/test Pipeline was successful Details

Reviewed-on: #86
This commit is contained in:
Dawid Wysokiński 2023-09-09 04:25:16 +00:00
parent 8dcbab039a
commit 7cb8a6a70c
7 changed files with 52 additions and 265 deletions

View File

@ -1,259 +0,0 @@
---
kind: pipeline
type: docker
name: test
steps:
- name: test
image: golang:1.20
pull: always
environment:
TESTS_DB_DSN: postgres://postgres:sessions@database:5432/sessions?sslmode=disable
commands:
- make generate
- go test -race -coverprofile=coverage.txt -covermode=atomic ./...
services:
- name: database
image: postgres:14.8
environment:
POSTGRES_DB: sessions
POSTGRES_PASSWORD: sessions
trigger:
event:
- push
- pull_request
branch:
- master
---
kind: pipeline
type: docker
name: check-go-mod
steps:
- name: go.mod
image: golang:1.20
pull: always
commands:
- make generate
- go mod tidy
- git diff --exit-code go.mod
trigger:
event:
- push
- pull_request
branch:
- master
---
kind: pipeline
type: docker
name: golangci-lint
steps:
- name: golangci-lint
image: golangci/golangci-lint:v1.53
pull: always
commands:
- make generate
- golangci-lint run
trigger:
event:
- push
- pull_request
branch:
- master
---
kind: pipeline
type: docker
name: govulncheck
platform:
os: linux
arch: amd64
steps:
- name: govulncheck
image: golang:1.20
commands:
- make generate
- go install golang.org/x/vuln/cmd/govulncheck@latest
- govulncheck ./...
- name: notify
image: drillster/drone-email
settings:
from.address:
from_secret: email_from
from.name: Drone
host:
from_secret: email_host
username:
from_secret: email_username
password:
from_secret: email_password
recipients:
- notifications@dwysokinski.me
recipients_only: true
subject: "[govulncheck - {{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ build.branch }} - {{ truncate build.commit 8 }})"
when:
status:
- success
- failure
trigger:
event:
- cron
cron:
- govulncheck
---
kind: pipeline
type: docker
name: linux-amd64
platform:
os: linux
arch: amd64
steps:
- name: publish
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
registry: gitea.dwysokinski.me
repo: gitea.dwysokinski.me/twhelp-packages/sessions
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: ./build/docker/sessions/prod/Dockerfile
build_args_from_env: [DRONE_TAG]
- name: notify
image: drillster/drone-email
settings:
from.address:
from_secret: email_from
from.name: Drone
host:
from_secret: email_host
username:
from_secret: email_username
password:
from_secret: email_password
recipients:
- notifications@dwysokinski.me
recipients_only: true
when:
status:
- failure
trigger:
event:
- tag
---
kind: pipeline
type: docker
name: manifest
steps:
- name: manifest
image: plugins/manifest
settings:
auto_tag: "true"
ignore_missing: "true"
spec: ./build/docker/sessions/prod/manifest.tmpl
username:
from_secret: docker_username
password:
from_secret: docker_password
- name: manifest-latest
image: plugins/manifest
settings:
tags: latest
ignore_missing: "true"
spec: ./build/docker/sessions/prod/manifest.tmpl
username:
from_secret: docker_username
password:
from_secret: docker_password
- name: notify
image: drillster/drone-email
settings:
from.address:
from_secret: email_from
from.name: Drone
host:
from_secret: email_host
username:
from_secret: email_username
password:
from_secret: email_password
recipients:
- notifications@dwysokinski.me
recipients_only: true
when:
status:
- failure
trigger:
event:
- tag
depends_on:
- linux-amd64
---
kind: pipeline
type: docker
name: deploy
steps:
- name: deploy-k8s
image: alpine/k8s:1.26.5
environment:
KUBECONFIG:
from_secret: kubeconfig
commands:
- "mkdir ~/.kube && echo \"$KUBECONFIG\" > ~/.kube/twhelp"
- "cd ./k8s/overlays/prod && kustomize edit set image sessions=gitea.dwysokinski.me/twhelp-packages/sessions:${DRONE_TAG##v} && cd ../../.."
- "kubectl --kubeconfig ~/.kube/twhelp -n twhelp delete jobs.batch sessions-migrations-job || true"
- kustomize build ./k8s/overlays/prod | kubectl --kubeconfig ~/.kube/twhelp apply -n twhelp -f -
- name: notify
image: drillster/drone-email
settings:
from.address:
from_secret: email_from
from.name: Drone
host:
from_secret: email_host
username:
from_secret: email_username
password:
from_secret: email_password
recipients:
- notifications@dwysokinski.me
recipients_only: true
subject: "[deploy - {{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ build.branch }} - {{ truncate build.commit 8 }})"
when:
status:
- success
- failure
trigger:
event:
- tag
depends_on:
- manifest
---
kind: signature
hmac: 7127bccf44d087927144fa4b41ea6416a6c3c5ebce083f6ef387e92ab83a8a90
...

View File

@ -6,6 +6,6 @@ repos:
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/golangci/golangci-lint
rev: v1.53.2
rev: v1.54.2
hooks:
- id: golangci-lint

46
.woodpecker/test.yml Normal file
View File

@ -0,0 +1,46 @@
when:
- event: [pull_request]
- event: push
branch:
- ${CI_REPO_DEFAULT_BRANCH}
variables:
- &go_image 'golang:1.21'
services:
database:
image: postgres:14.8
environment:
POSTGRES_DB: sessions
POSTGRES_PASSWORD: sessions
steps:
generate:
image: *go_image
pull: true
commands:
- make generate
test:
image: *go_image
group: test
pull: true
environment:
TESTS_DB_DSN: postgres://postgres:sessions@database:5432/sessions?sslmode=disable
commands:
- go test -race -coverprofile=coverage.txt -covermode=atomic ./...
lint:
image: golangci/golangci-lint:v1.54
pull: true
group: test
commands:
- golangci-lint run
check-go-mod:
image: *go_image
group: test
pull: true
commands:
- go mod tidy
- git diff --exit-code go.mod

View File

@ -27,7 +27,7 @@ install-swag:
.PHONY: install-golangci-lint
install-golangci-lint:
@echo "Installing github.com/golangci/golangci-lint..."
@test -f $(GOLANGCI_LINT_PATH) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.53.2
@test -f $(GOLANGCI_LINT_PATH) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.54.2
.PHONY: install-tools
install-tools: install-golangci-lint install-counterfeiter install-swag

View File

@ -1,4 +1,4 @@
FROM golang:1.20 as builder
FROM golang:1.21 as builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
@ -15,4 +15,4 @@ ENV GOTRACEBACK=single
RUN apt update
RUN apt install -y ca-certificates tzdata
COPY --from=builder /app/sessions .
ENTRYPOINT ["./sessions"]
ENTRYPOINT ["./sessions"]

View File

@ -1,4 +1,4 @@
FROM golang:1.20.7-alpine3.18 as builder
FROM golang:1.21.1-alpine3.18 as builder
WORKDIR /sessions

2
go.mod
View File

@ -1,6 +1,6 @@
module gitea.dwysokinski.me/twhelp/sessions
go 1.20
go 1.21
require (
gitea.dwysokinski.me/Kichiyaki/chiclientip v0.1.0