From 66ecc8c2271359171cbbb7ca880f7705292fb4e9 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 31 Mar 2022 01:10:20 +0300 Subject: [PATCH 1/2] Migrate to go modules + Improve GitHub actions workflows --- .github/dependabot.yml | 30 +++++++++++++++++++++ .github/workflows/ci.yml | 32 +++++++++++++++++++--- .gitignore | 2 ++ Makefile | 26 +++++++++++------- api/api.go | 2 +- common/updown-badge-server.spec | 11 +++++--- daemon/daemon.go | 30 ++++++++++----------- daemon/server.go | 14 +++++----- go.mod | 18 +++++++++++++ go.sum | 48 +++++++++++++++++++++++++++++++++ updown-badge-server.go | 2 +- 11 files changed, 174 insertions(+), 41 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .gitignore create mode 100644 go.mod create mode 100644 go.sum diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fc51337 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,30 @@ +version: 2 + +updates: + - package-ecosystem: "gomod" + directory: "/" + target-branch: "develop" + schedule: + interval: "daily" + timezone: "Europe/London" + time: "03:00" + labels: + - "PR • MAINTENANCE" + assignees: + - "andyone" + reviewers: + - "andyone" + + - package-ecosystem: "github-actions" + directory: "/" + target-branch: "develop" + schedule: + interval: "daily" + timezone: "Europe/London" + time: "04:00" + labels: + - "PR • MAINTENANCE" + assignees: + - "andyone" + reviewers: + - "andyone" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bc31c0..93e75dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - go: [ '1.16.x', '1.17.x' ] + go: [ '1.17.x', '1.18.x' ] steps: - name: Set up Go @@ -33,7 +33,7 @@ jobs: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: ${{env.SRC_DIR}} @@ -59,7 +59,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: '1.16.x' + go-version: '1.17.x' id: go - name: Setup PATH @@ -69,7 +69,7 @@ jobs: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: ${{env.SRC_DIR}} @@ -82,3 +82,27 @@ jobs: with: path: ${{env.SRC_DIR}} files: ./... + + Perfecto: + name: Perfecto + runs-on: ubuntu-latest + + needs: Go + + steps: + - name: Code checkout + uses: actions/checkout@v3 + + - name: Login to DockerHub + uses: docker/login-action@v1 + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + if: ${{ env.DOCKERHUB_USERNAME != '' }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Check specs with Perfecto + uses: essentialkaos/perfecto-action@v1 + with: + files: common/updown-badge-server.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa03cd8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +updown-badge-server +vendor diff --git a/Makefile b/Makefile index c20182f..271f10d 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,16 @@ ################################################################################ -# This Makefile generated by GoMakeGen 1.3.2 using next command: -# gomakegen . +# This Makefile generated by GoMakeGen 1.5.1 using next command: +# gomakegen --mod . # # More info: https://kaos.sh/gomakegen ################################################################################ +export GO111MODULE=on + .DEFAULT_GOAL := help -.PHONY = fmt vet all clean git-config deps help +.PHONY = fmt vet all clean deps mod-init mod-update mod-vendor help ################################################################################ @@ -23,13 +25,17 @@ install: ## Install all binaries uninstall: ## Uninstall all binaries rm -f /usr/bin/updown-badge-server -git-config: ## Configure git redirects for stable import path services - git config --global http.https://pkg.re.followRedirects true +deps: mod-update ## Download dependencies + +mod-init: ## Initialize new module + go mod init + go mod tidy + +mod-update: ## Download modules to local cache + go mod download -deps: git-config ## Download dependencies - go get -d -v github.com/valyala/fasthttp - go get -d -v pkg.re/essentialkaos/ek.v12 - go get -d -v pkg.re/essentialkaos/go-badge.v1 +mod-vendor: ## Make vendored copy of dependencies + go mod vendor fmt: ## Format source code with gofmt find . -name "*.go" -exec gofmt -s -w {} \; @@ -45,6 +51,6 @@ help: ## Show this info @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-21s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 1.3.2\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 1.5.1\033[0m\n' ################################################################################ diff --git a/api/api.go b/api/api.go index b929dde..00e8a22 100644 --- a/api/api.go +++ b/api/api.go @@ -2,7 +2,7 @@ package api // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2021 ESSENTIAL KAOS // +// Copyright (c) 2022 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/common/updown-badge-server.spec b/common/updown-badge-server.spec index 8b730af..bfffe8e 100644 --- a/common/updown-badge-server.spec +++ b/common/updown-badge-server.spec @@ -52,11 +52,11 @@ Summary: Service for generating badges for updown.io checks Name: updown-badge-server -Version: 1.1.0 +Version: 1.1.1 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 -URL: https://github.com/essentialkaos/updown-badge-server +URL: https://kaos.sh/updown-badge-server Source0: https://source.kaos.st/%{name}/%{name}-%{version}.tar.bz2 @@ -64,7 +64,7 @@ Source100: checksum.sha512 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: golang >= 1.16 +BuildRequires: golang >= 1.17 Requires: kaosv >= 2.16 Requires: systemd @@ -139,6 +139,11 @@ exit 0 ################################################################################ %changelog +* Thu Mar 31 2022 Anton Novojilov - 1.1.1-0 +- Removed pkg.re usage +- Added module info +- Added Dependabot configuration + * Wed Aug 25 2021 Anton Novojilov - 1.1.0-0 - Improved color generation for uptime and apdex badges diff --git a/daemon/daemon.go b/daemon/daemon.go index b05ffce..1125dcf 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -2,7 +2,7 @@ package daemon // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2021 ESSENTIAL KAOS // +// Copyright (c) 2022 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // @@ -13,21 +13,21 @@ import ( "strings" "time" - "pkg.re/essentialkaos/ek.v12/cache" - "pkg.re/essentialkaos/ek.v12/fmtc" - "pkg.re/essentialkaos/ek.v12/knf" - "pkg.re/essentialkaos/ek.v12/log" - "pkg.re/essentialkaos/ek.v12/options" - "pkg.re/essentialkaos/ek.v12/pid" - "pkg.re/essentialkaos/ek.v12/signal" - "pkg.re/essentialkaos/ek.v12/usage" + "github.com/essentialkaos/ek/v12/cache" + "github.com/essentialkaos/ek/v12/fmtc" + "github.com/essentialkaos/ek/v12/knf" + "github.com/essentialkaos/ek/v12/log" + "github.com/essentialkaos/ek/v12/options" + "github.com/essentialkaos/ek/v12/pid" + "github.com/essentialkaos/ek/v12/signal" + "github.com/essentialkaos/ek/v12/usage" - knfv "pkg.re/essentialkaos/ek.v12/knf/validators" - knff "pkg.re/essentialkaos/ek.v12/knf/validators/fs" - knfn "pkg.re/essentialkaos/ek.v12/knf/validators/network" - knfr "pkg.re/essentialkaos/ek.v12/knf/validators/regexp" + knfv "github.com/essentialkaos/ek/v12/knf/validators" + knff "github.com/essentialkaos/ek/v12/knf/validators/fs" + knfn "github.com/essentialkaos/ek/v12/knf/validators/network" + knfr "github.com/essentialkaos/ek/v12/knf/validators/regexp" - "pkg.re/essentialkaos/go-badge.v1" + "github.com/essentialkaos/go-badge" "github.com/valyala/fasthttp" @@ -39,7 +39,7 @@ import ( // Basic service info const ( APP = "UpDownBadgeServer" - VER = "1.1.0" + VER = "1.1.1" DESC = "Service for generating badges for updown.io checks" ) diff --git a/daemon/server.go b/daemon/server.go index 85b8e63..c42ccce 100644 --- a/daemon/server.go +++ b/daemon/server.go @@ -2,7 +2,7 @@ package daemon // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2021 ESSENTIAL KAOS // +// Copyright (c) 2022 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // @@ -11,13 +11,13 @@ import ( "fmt" "strings" - "pkg.re/essentialkaos/ek.v12/color" - "pkg.re/essentialkaos/ek.v12/easing" - "pkg.re/essentialkaos/ek.v12/log" - "pkg.re/essentialkaos/ek.v12/mathutil" - "pkg.re/essentialkaos/ek.v12/strutil" + "github.com/essentialkaos/ek/v12/color" + "github.com/essentialkaos/ek/v12/easing" + "github.com/essentialkaos/ek/v12/log" + "github.com/essentialkaos/ek/v12/mathutil" + "github.com/essentialkaos/ek/v12/strutil" - "pkg.re/essentialkaos/go-badge.v1" + "github.com/essentialkaos/go-badge" "github.com/valyala/fasthttp" ) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b562c26 --- /dev/null +++ b/go.mod @@ -0,0 +1,18 @@ +module github.com/essentialkaos/updown-badge-server + +go 1.17 + +require ( + github.com/essentialkaos/ek/v12 v12.42.1 + github.com/essentialkaos/go-badge v1.3.1 + github.com/valyala/fasthttp v1.34.0 +) + +require ( + github.com/andybalholm/brotli v1.0.4 // indirect + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/klauspost/compress v1.15.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + golang.org/x/image v0.0.0-20220321031419-a8550c1d254a // indirect + golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e1db954 --- /dev/null +++ b/go.sum @@ -0,0 +1,48 @@ +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= +github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/essentialkaos/check v1.2.1 h1:avvyFy/1acUNwfxwuOLsHeCjfXtMygtbu0lVDr3nxFs= +github.com/essentialkaos/check v1.2.1/go.mod h1:PhxzfJWlf5L/skuyhzBLIvjMB5Xu9TIyDIsqpY5MvB8= +github.com/essentialkaos/ek/v12 v12.42.1 h1:h3PPy0XNXUj1IsEid/p9IzaF0o5hZEGOBFh7XZawAyg= +github.com/essentialkaos/ek/v12 v12.42.1/go.mod h1:Cv/tOZshmFg4pMJnBkg4aW/WyYhzzc41qzZIfk5RSi4= +github.com/essentialkaos/go-badge v1.3.1 h1:oW8F0VJaZMc0e62GRrXoE9dgbzsV/9UxT4DRsJr046E= +github.com/essentialkaos/go-badge v1.3.1/go.mod h1:WgBYjPEO0e0pQn75KBc9ska0ezLdKX7aY1FZtr1a8q8= +github.com/essentialkaos/go-linenoise/v3 v3.3.5/go.mod h1:g4X3LhT83XT4h7xwrCLclAdMkJvS9qWBQTGNdS6y4vo= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U= +github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= +github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/image v0.0.0-20220321031419-a8550c1d254a h1:LnH9RNcpPv5Kzi15lXg42lYMPUf0x8CuPv1YnvBWZAg= +golang.org/x/image v0.0.0-20220321031419-a8550c1d254a/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/updown-badge-server.go b/updown-badge-server.go index 6cc4612..6a44734 100644 --- a/updown-badge-server.go +++ b/updown-badge-server.go @@ -2,7 +2,7 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2021 ESSENTIAL KAOS // +// Copyright (c) 2022 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // From 6fa46e3a479171995bf54c188bfb2bbddcbfb734 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 1 Apr 2022 01:06:49 +0300 Subject: [PATCH 2/2] Improve spec --- .gitignore | 2 +- common/updown-badge-server.spec | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index fa03cd8..76baf13 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -updown-badge-server vendor +updown-badge-server diff --git a/common/updown-badge-server.spec b/common/updown-badge-server.spec index bfffe8e..f6566e2 100644 --- a/common/updown-badge-server.spec +++ b/common/updown-badge-server.spec @@ -85,10 +85,8 @@ Service for generating badges for updown.io checks. %build export GOPATH=$(pwd) -export GO111MODULE=auto - pushd %{srcdir} - %{__make} %{?_smp_mflags} all + go build -mod vendor %{name}.go popd %install