refactor: use drone instead of github actions, rename module (#1)
continuous-integration/drone/push Build is passing Details

Reviewed-on: #1
This commit is contained in:
Dawid Wysokiński 2022-09-08 06:36:04 +00:00
parent b45656739f
commit 0e104ff539
11 changed files with 142 additions and 112 deletions

114
.drone.yml Normal file
View File

@ -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

View File

@ -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 ./...

View File

@ -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

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/Kichiyaki/lubimyczytacrss
module gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss
go 1.19

View File

@ -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"
)

View File

@ -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 {

View File

@ -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) {

View File

@ -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

View File

@ -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 (

13
manifest.tmpl Normal file
View File

@ -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

View File

@ -1,7 +1,14 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"labels": [
"dependencies"
],
"extends": [
"config:base",
":semanticCommits",
":semanticCommitTypeAll(chore)"
],
"postUpdateOptions": [
"gomodTidy"
]
}