From 0e104ff539d3484d3de7e209919ac5ff2dc79bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wysoki=C5=84ski?= Date: Thu, 8 Sep 2022 06:36:04 +0000 Subject: [PATCH] refactor: use drone instead of github actions, rename module (#1) Reviewed-on: https://gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/pulls/1 --- .drone.yml | 114 +++++++++++++++++++++ .github/workflows/pr.yml | 55 ---------- .github/workflows/publish.yml | 49 --------- go.mod | 2 +- internal/api/handler.go | 2 +- internal/api/rss.go | 2 +- internal/lubimyczytac/client_test.go | 4 +- internal/lubimyczytac/testdata/testdata.go | 2 +- main.go | 4 +- manifest.tmpl | 13 +++ renovate.json | 7 ++ 11 files changed, 142 insertions(+), 112 deletions(-) create mode 100644 .drone.yml delete mode 100644 .github/workflows/pr.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 manifest.tmpl diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..142fbab --- /dev/null +++ b/.drone.yml @@ -0,0 +1,114 @@ +--- +kind: pipeline +type: docker +name: test + +steps: + - name: test + image: golang:1.19 + commands: + - go test -race -coverprofile=coverage.txt -covermode=atomic ./... + +trigger: + event: + - push + - pull_request + branch: + - master + +--- +kind: pipeline +type: docker +name: check-go-mod + +steps: + - name: check go.mod + image: golang:1.19 + commands: + - 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: run golangci-lint + image: golangci/golangci-lint:v1.49 + commands: + - golangci-lint run + +trigger: + event: + - push + - pull_request + branch: + - master + +--- +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/kichiyaki/lubimyczytacrss + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: Dockerfile + +trigger: + event: + - tag +--- +kind: pipeline +type: docker +name: manifest + +steps: + - name: manifest + image: plugins/manifest + settings: + auto_tag: "true" + ignore_missing: "true" + spec: 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: manifest.tmpl + username: + from_secret: docker_username + password: + from_secret: docker_password + +trigger: + event: + - tag + +depends_on: + - linux-amd64 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index ef90e2f..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: PR checks -on: - push: - branches: - - master - pull_request: - -env: - GO_VERSION: 1.19.x - -jobs: - go-mod: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - - name: Check go mod - run: | - go mod tidy - git diff --exit-code go.mod - - golangci-lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.48 - - tests: - strategy: - matrix: - go: [ 1.19.x ] - platform: [ ubuntu-latest ] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go }} - - name: Run go vet - run: go vet ./... - - name: Run go build - run: go build - - name: Run tests - run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 7944eb7..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Build and push to registry - -on: - push: - tags: - - 'v*' - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.REGISTRY_LOGIN }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - tags: | - ${{ secrets.REGISTRY_NAME }}/lubimyczytacrss:latest - ${{ secrets.REGISTRY_NAME }}/lubimyczytacrss:${{ steps.get_version.outputs.VERSION }} - file: ./Dockerfile - push: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/go.mod b/go.mod index ca03495..d78220d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Kichiyaki/lubimyczytacrss +module gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss go 1.19 diff --git a/internal/api/handler.go b/internal/api/handler.go index 4ccdd46..35365c8 100644 --- a/internal/api/handler.go +++ b/internal/api/handler.go @@ -4,7 +4,7 @@ import ( "encoding/xml" "net/http" - "github.com/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" + "gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/rss.go b/internal/api/rss.go index 114c930..2431090 100644 --- a/internal/api/rss.go +++ b/internal/api/rss.go @@ -3,7 +3,7 @@ package api import ( "encoding/xml" - "github.com/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" + "gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" ) type rssItem struct { diff --git a/internal/lubimyczytac/client_test.go b/internal/lubimyczytac/client_test.go index df22522..78a91e8 100644 --- a/internal/lubimyczytac/client_test.go +++ b/internal/lubimyczytac/client_test.go @@ -7,11 +7,11 @@ import ( "net/http/httptest" "testing" - "github.com/Kichiyaki/lubimyczytacrss/internal/lubimyczytac/testdata" + "gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/internal/lubimyczytac/testdata" "github.com/stretchr/testify/assert" - "github.com/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" + "gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" ) func TestClient_GetAuthor(t *testing.T) { diff --git a/internal/lubimyczytac/testdata/testdata.go b/internal/lubimyczytac/testdata/testdata.go index 9a2889f..4e79c76 100644 --- a/internal/lubimyczytac/testdata/testdata.go +++ b/internal/lubimyczytac/testdata/testdata.go @@ -3,7 +3,7 @@ package testdata import ( _ "embed" - "github.com/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" + "gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" ) //go:embed remigiusz_mroz.html diff --git a/main.go b/main.go index d1360a0..6e1b1e4 100644 --- a/main.go +++ b/main.go @@ -8,13 +8,13 @@ import ( "os/signal" "time" - "github.com/Kichiyaki/lubimyczytacrss/internal/api" + "gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/internal/api" "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5" - "github.com/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" + "gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss/internal/lubimyczytac" ) const ( diff --git a/manifest.tmpl b/manifest.tmpl new file mode 100644 index 0000000..6c69edb --- /dev/null +++ b/manifest.tmpl @@ -0,0 +1,13 @@ +image: gitea.dwysokinski.me/kichiyaki/lubimyczytacrss:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - + image: gitea.dwysokinski.me/kichiyaki/lubimyczytacrss:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux diff --git a/renovate.json b/renovate.json index c073fea..b20b188 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,14 @@ { + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "labels": [ + "dependencies" + ], "extends": [ "config:base", ":semanticCommits", ":semanticCommitTypeAll(chore)" + ], + "postUpdateOptions": [ + "gomodTidy" ] }