From 7ba042ba2b9826a1db16957732b10189a8ab0e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wysoki=C5=84ski?= Date: Sun, 28 May 2023 16:27:43 +0200 Subject: [PATCH] feat: ci/cd - add notifications & update deps --- .drone.yml | 87 +++++++++++++++++++++++++-- build/docker/sessions/prod/Dockerfile | 6 +- go.mod | 14 ++--- go.sum | 32 +++++----- internal/bundb/bundb_test.go | 2 +- skaffold.yml | 4 +- 6 files changed, 110 insertions(+), 35 deletions(-) diff --git a/.drone.yml b/.drone.yml index a5cf295..e5feb99 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,6 +6,7 @@ name: test steps: - name: test image: golang:1.20 + pull: always environment: TESTS_DB_DSN: postgres://postgres:sessions@database:5432/sessions?sslmode=disable commands: @@ -14,7 +15,7 @@ steps: services: - name: database - image: postgres:14.6 + image: postgres:14.8 environment: POSTGRES_DB: sessions POSTGRES_PASSWORD: sessions @@ -32,8 +33,9 @@ type: docker name: check-go-mod steps: - - name: check go.mod + - name: go.mod image: golang:1.20 + pull: always commands: - make generate - go mod tidy @@ -52,8 +54,9 @@ type: docker name: golangci-lint steps: - - name: run golangci-lint + - name: golangci-lint image: golangci/golangci-lint:v1.52 + pull: always commands: - make generate - golangci-lint run @@ -81,6 +84,26 @@ steps: - 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: @@ -111,6 +134,24 @@ steps: 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: @@ -142,6 +183,24 @@ steps: 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: @@ -166,6 +225,26 @@ steps: - "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: @@ -175,6 +254,6 @@ depends_on: - manifest --- kind: signature -hmac: 1116c45b2bd27a494ce42c26fbbdec48573e9f847ebae77067710c2639a12792 +hmac: 784c4a035ce7fb6e2cb618e3fecdd778ed11d592040a90299f9663268e8d1474 ... diff --git a/build/docker/sessions/prod/Dockerfile b/build/docker/sessions/prod/Dockerfile index 66d4332..29b80f0 100644 --- a/build/docker/sessions/prod/Dockerfile +++ b/build/docker/sessions/prod/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20.4-alpine3.17 as builder +FROM golang:1.20.4-alpine3.18 as builder WORKDIR /sessions @@ -13,7 +13,7 @@ ARG DRONE_TAG="development" RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${DRONE_TAG##v}" -trimpath -o sessions ./cmd/sessions/main.go ######## Start a new stage from scratch ####### -FROM alpine:3.17 +FROM alpine:3.18 RUN apk --no-cache add ca-certificates tzdata @@ -21,4 +21,4 @@ COPY --from=builder /sessions/sessions /usr/bin/ EXPOSE 9234/tcp -ENTRYPOINT ["sessions"] \ No newline at end of file +ENTRYPOINT ["sessions"] diff --git a/go.mod b/go.mod index a3cfdb3..5f8eff7 100644 --- a/go.mod +++ b/go.mod @@ -14,13 +14,13 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/ory/dockertest/v3 v3.10.0 github.com/realclientip/realclientip-go v1.0.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.3 github.com/swaggo/http-swagger v1.3.3 github.com/swaggo/swag v1.8.8 - github.com/uptrace/bun v1.1.13 - github.com/uptrace/bun/dbfixture v1.1.13 - github.com/uptrace/bun/dialect/pgdialect v1.1.13 - github.com/uptrace/bun/driver/pgdriver v1.1.13 + github.com/uptrace/bun v1.1.14 + github.com/uptrace/bun/dbfixture v1.1.14 + github.com/uptrace/bun/dialect/pgdialect v1.1.14 + github.com/uptrace/bun/driver/pgdriver v1.1.14 github.com/urfave/cli/v2 v2.25.3 go.uber.org/zap v1.24.0 ) @@ -66,9 +66,9 @@ require ( github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 // indirect - golang.org/x/crypto v0.8.0 // indirect + golang.org/x/crypto v0.9.0 // indirect golang.org/x/mod v0.9.0 // indirect - golang.org/x/net v0.9.0 // indirect + golang.org/x/net v0.10.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/tools v0.7.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 0ca9359..73393fd 100644 --- a/go.sum +++ b/go.sum @@ -126,16 +126,12 @@ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= github.com/swaggo/http-swagger v1.3.3 h1:Hu5Z0L9ssyBLofaama21iYaF2VbWyA8jdohaaCGpHsc= @@ -145,14 +141,14 @@ github.com/swaggo/swag v1.8.8/go.mod h1:ezQVUUhly8dludpVk+/PuwJWvLLanB13ygV5Pr9e github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= -github.com/uptrace/bun v1.1.13 h1:IrxlIJHzCHFwmIzx66A9vi6qx8rHsHFiiT9LqlafHZw= -github.com/uptrace/bun v1.1.13/go.mod h1:UsZPd0AuHOx2QkkKXnqkHnFBjVp5tKqI7s4A750u9v0= -github.com/uptrace/bun/dbfixture v1.1.13 h1:iXa0XItVC5Wu+eoP8swb9fmzXugukZACiv8YQ2O1ICc= -github.com/uptrace/bun/dbfixture v1.1.13/go.mod h1:+JaFtaNu+nL+i36U6R3JC5Uq9qzb9jbpPt11JQuQPwY= -github.com/uptrace/bun/dialect/pgdialect v1.1.13 h1:j9BecpkRA9SDVBwh6oKhC5rABk4B40s66OCcqBHSQXM= -github.com/uptrace/bun/dialect/pgdialect v1.1.13/go.mod h1:G9h6kk5qfTyACjTja7gqM7SbRc0rqRc9AWDjzxwA7nY= -github.com/uptrace/bun/driver/pgdriver v1.1.13 h1:/Sw8m+f9VnEVE/7OvlqXt4/vScn9gsBI+y15m7XXHJo= -github.com/uptrace/bun/driver/pgdriver v1.1.13/go.mod h1:1QVHEbpxgJFS5W39WB/BVSqF5YaOpuriE+vlK2wf+uw= +github.com/uptrace/bun v1.1.14 h1:S5vvNnjEynJ0CvnrBOD7MIRW7q/WbtvFXrdfy0lddAM= +github.com/uptrace/bun v1.1.14/go.mod h1:RHk6DrIisO62dv10pUOJCz5MphXThuOTpVNYEYv7NI8= +github.com/uptrace/bun/dbfixture v1.1.14 h1:KymZc+vV+kou1hl0HgwaqYo3Ug8IfArf6JsB5C6eW5o= +github.com/uptrace/bun/dbfixture v1.1.14/go.mod h1:RP9sYsJnHoJPjIJX2ACrQd690Z2SSIBtFK2rtcbI3fI= +github.com/uptrace/bun/dialect/pgdialect v1.1.14 h1:b7+V1KDJPQSFYgkG/6YLXCl2uvwEY3kf/GSM7hTHRDY= +github.com/uptrace/bun/dialect/pgdialect v1.1.14/go.mod h1:v6YiaXmnKQ2FlhRD2c0ZfKd+QXH09pYn4H8ojaavkKk= +github.com/uptrace/bun/driver/pgdriver v1.1.14 h1:V2Etm7mLGS3mhx8ddxZcUnwZLX02Jmq9JTlo0sNVDhA= +github.com/uptrace/bun/driver/pgdriver v1.1.14/go.mod h1:D4FjWV9arDYct6sjMJhFoyU71SpllZRHXFRRP2Kd0Kw= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.25.3 h1:VJkt6wvEBOoSjPFQvOkv6iWIrsJyCrKGtCtxXWwmGeY= github.com/urfave/cli/v2 v2.25.3/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= @@ -183,8 +179,8 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= @@ -196,8 +192,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/internal/bundb/bundb_test.go b/internal/bundb/bundb_test.go index 8395001..fcf5142 100644 --- a/internal/bundb/bundb_test.go +++ b/internal/bundb/bundb_test.go @@ -59,7 +59,7 @@ func newDBDockertest(tb testing.TB) *bun.DB { resource, err := pool.RunWithOptions(&dockertest.RunOptions{ Repository: "postgres", - Tag: "14.6", + Tag: "14.8", Env: []string{ fmt.Sprintf("POSTGRES_USER=%s", dsn.User.Username()), fmt.Sprintf("POSTGRES_PASSWORD=%s", pw), diff --git a/skaffold.yml b/skaffold.yml index 22d78ec..f5aad1a 100644 --- a/skaffold.yml +++ b/skaffold.yml @@ -26,8 +26,8 @@ deploy: version: 11.9.13 wait: true setValues: - image.tag: 14.6.0-debian-11-r4 + image.tag: 14.8.0-debian-11-r4 auth.username: sessions auth.password: sessions auth.database: sessions - kubectl: {} \ No newline at end of file + kubectl: {}