Compare commits
10 Commits
v0.0.1-alp
...
master
Author | SHA1 | Date |
---|---|---|
Dawid Wysokiński | 4b641dc0be | |
Dawid Wysokiński | 0e104ff539 | |
Dawid Wysokiński | b45656739f | |
renovate[bot] | e086dc6f02 | |
renovate[bot] | ae47394483 | |
renovate[bot] | f5dcdd4095 | |
renovate[bot] | 970b4841e6 | |
renovate[bot] | a5e6b796b9 | |
Dawid Wysokiński | 410deaeca0 | |
Dawid Wysokiński | 2c9eb1e463 |
|
@ -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
|
|
@ -1,54 +0,0 @@
|
|||
name: PR checks
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
GO_VERSION: 1.18.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.46
|
||||
|
||||
tests:
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ 1.18.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 ./...
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.18.3-alpine3.16 as builder
|
||||
FROM golang:1.19.0-alpine3.16 as builder
|
||||
|
||||
WORKDIR /app/lubimyczytacrss
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
# lubimyczytacrss
|
||||
|
||||
lubimyczytacrss is an RSS feed generator for [lubimyczytac.pl](https://lubimyczytac.pl).
|
||||
|
||||
## How to use?
|
||||
|
||||
### Option 1: Use Docker
|
||||
|
||||
```shell
|
||||
$ docker run -d \
|
||||
-p 9234:9234 \
|
||||
--name lubimyczytacrss \
|
||||
kichiyaki/lubimyczytacrss:latest
|
||||
```
|
||||
Or via docker-compose:
|
||||
```yaml
|
||||
version: "3.6"
|
||||
|
||||
services:
|
||||
lubimyczytacrss:
|
||||
image: gitea.dwysokinski.me/kichiyaki/lubimyczytacrss:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '9234:9234'
|
||||
networks:
|
||||
- default
|
||||
```
|
||||
|
||||
## Available endpoints
|
||||
|
||||
### GET /api/v1/rss/authors/{authorID}
|
||||
|
||||
Returns the RSS feed of the newest books written by the author with the given ID.
|
10
go.mod
10
go.mod
|
@ -1,17 +1,17 @@
|
|||
module github.com/Kichiyaki/lubimyczytacrss
|
||||
module gitea.dwysokinski.me/Kichiyaki/lubimyczytacrss
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/go-chi/chi/v5 v5.0.7
|
||||
github.com/stretchr/testify v1.7.1
|
||||
github.com/stretchr/testify v1.8.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
10
go.sum
10
go.sum
|
@ -2,15 +2,18 @@ github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0g
|
|||
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
|
||||
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
|
||||
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
|
||||
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 h1:/6y1LfuqNuQdHAm0jjtPtgRcxIxjVZgm5OTu8/QhZvk=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -20,5 +23,6 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -17,7 +17,7 @@ func NewHandler(client *lubimyczytac.Client) *Handler {
|
|||
}
|
||||
|
||||
func (h *Handler) Register(r chi.Router) {
|
||||
r.Get("/api/v1/rss/author/{authorID}", h.getRSSAuthor)
|
||||
r.Get("/api/v1/rss/authors/{authorID}", h.getRSSAuthor)
|
||||
}
|
||||
|
||||
func (h *Handler) getRSSAuthor(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
4
main.go
4
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 (
|
||||
|
|
|
@ -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
|
|
@ -1,7 +1,14 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"labels": [
|
||||
"dependencies"
|
||||
],
|
||||
"extends": [
|
||||
"config:base",
|
||||
":semanticCommits",
|
||||
":semanticCommitTypeAll(chore)"
|
||||
],
|
||||
"postUpdateOptions": [
|
||||
"gomodTidy"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue