Skip to content

Commit

Permalink
ci: add quality workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cecobask committed Nov 22, 2023
1 parent 05f288e commit 1a733c9
Show file tree
Hide file tree
Showing 150 changed files with 182 additions and 24,680 deletions.
13 changes: 13 additions & 0 deletions .codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
coverage:
precision: 2
round: nearest
range: "75...100"
status:
project:
default:
target: "75%"
threshold: "0%"
patch: false
changes: false
comment:
layout: "diff, files"
49 changes: 49 additions & 0 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: quality
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Build
run: make build
test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Run tests
run: make test
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
17 changes: 9 additions & 8 deletions .github/workflows/sync.yml → .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
schedule:
- cron: "0 */3 * * *"
workflow_dispatch:

env:
IMDB_COOKIE_AT_MAIN: ${{ secrets.IMDB_COOKIE_AT_MAIN }}
IMDB_COOKIE_UBID_MAIN: ${{ secrets.IMDB_COOKIE_UBID_MAIN }}
Expand All @@ -17,15 +16,17 @@ env:
TRAKT_CLIENT_SECRET: ${{ secrets.TRAKT_CLIENT_SECRET }}
TRAKT_EMAIL: ${{ secrets.TRAKT_EMAIL }}
TRAKT_PASSWORD: ${{ secrets.TRAKT_PASSWORD }}

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.18'
cache: true
- name: Sync watchlist, lists and ratings
run: go run cmd/syncer/main.go
go-version: 1.21
- name: Build
run: make build
- name: Sync
run: ./build/syncer
26 changes: 2 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,2 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Environment variables
.env

# GoLand IDE configs
.idea/

# personal to do list for development purposes
TODO.md
build/
coverage.out
21 changes: 21 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- goimports
- misspell
- revive
- unconvert
- gci
run:
timeout: 5m
linters-settings:
revive:
rules:
- name: var-naming
arguments:
- ["ID", "URL", "HTTP", "JSON", "API"]
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.PHONY: *

build:
go build -o build/syncer cmd/syncer/main.go

fmt:
go fmt ./...

html-coverage:
go tool cover -html=coverage.out

lint:
golangci-lint run

lint-fix:
golangci-lint run --fix

mocks:
mockery

test:
go test -coverpkg=./... -race -coverprofile=coverage.out -shuffle on ./...
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![sync](https://github.com/cecobask/imdb-trakt-sync/actions/workflows/sync.yml/badge.svg?event=schedule)](https://github.com/cecobask/imdb-trakt-sync/actions/workflows/sync.yml)
[![sync](https://github.com/cecobask/imdb-trakt-sync/actions/workflows/sync.yml/badge.svg?event=schedule)](https://github.com/cecobask/imdb-trakt-sync/actions/workflows/sync.yml)
[![quality](https://github.com/cecobask/imdb-trakt-sync/actions/workflows/quality.yaml/badge.svg)](https://github.com/cecobask/imdb-trakt-sync/actions/workflows/quality.yaml)
[![codecov](https://codecov.io/gh/cecobask/imdb-trakt-sync/graph/badge.svg)](https://codecov.io/gh/cecobask/imdb-trakt-sync)
# imdb-trakt-sync
GoLang app that can sync [IMDb](https://www.imdb.com/) and [Trakt](https://trakt.tv/dashboard) user data - watchlist,
lists, ratings and history.
Expand Down
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
module github.com/cecobask/imdb-trakt-sync

go 1.18
go 1.21

require (
github.com/PuerkitoBio/goquery v1.8.0
github.com/joho/godotenv v1.4.0
go.uber.org/zap v1.24.0
github.com/PuerkitoBio/goquery v1.8.1
github.com/joho/godotenv v1.5.1
go.uber.org/zap v1.26.0
)

require (
github.com/andybalholm/cascadia v1.3.1 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/net v0.17.0 // indirect
)
56 changes: 38 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,32 +1,52 @@
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
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/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
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/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
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.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/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/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
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/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7 changes: 4 additions & 3 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package client
import (
"bytes"
"fmt"
"io"

"github.com/PuerkitoBio/goquery"
"github.com/cecobask/imdb-trakt-sync/pkg/entities"
"io"
)

type ImdbClientInterface interface {
Expand Down Expand Up @@ -64,7 +65,7 @@ type reusableReader struct {

func ReusableReader(r io.Reader) io.Reader {
readBuf := bytes.Buffer{}
readBuf.ReadFrom(r)
_, _ = readBuf.ReadFrom(r)
backBuf := bytes.Buffer{}
return reusableReader{
Reader: io.TeeReader(&readBuf, &backBuf),
Expand All @@ -76,7 +77,7 @@ func ReusableReader(r io.Reader) io.Reader {
func (r reusableReader) Read(p []byte) (int, error) {
n, err := r.Reader.Read(p)
if err == io.EOF {
io.Copy(r.readBuf, r.backBuf)
_, _ = io.Copy(r.readBuf, r.backBuf)
}
return n, err
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/client/imdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import (
"encoding/csv"
"errors"
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/cecobask/imdb-trakt-sync/pkg/entities"
"go.uber.org/zap"
"mime"
"net/http"
"net/http/cookiejar"
Expand All @@ -16,6 +13,10 @@ import (
"strings"
"sync"
"time"

"github.com/PuerkitoBio/goquery"
"github.com/cecobask/imdb-trakt-sync/pkg/entities"
"go.uber.org/zap"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions pkg/client/trakt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/cecobask/imdb-trakt-sync/pkg/entities"
"go.uber.org/zap"
"io"
"net/http"
"net/http/cookiejar"
Expand All @@ -15,6 +13,9 @@ import (
"strings"
"sync"
"time"

"github.com/cecobask/imdb-trakt-sync/pkg/entities"
"go.uber.org/zap"
)

const (
Expand Down
1 change: 1 addition & 0 deletions pkg/entities/trakt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entities

import (
"fmt"

"go.uber.org/zap/zapcore"
)

Expand Down
5 changes: 3 additions & 2 deletions pkg/logger/zap.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package logger

import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"os"
"time"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

func NewLogger() *zap.Logger {
Expand Down
7 changes: 4 additions & 3 deletions pkg/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package syncer

import (
"fmt"
"os"
"strconv"
"strings"

"github.com/cecobask/imdb-trakt-sync/pkg/client"
"github.com/cecobask/imdb-trakt-sync/pkg/entities"
"github.com/cecobask/imdb-trakt-sync/pkg/logger"
_ "github.com/joho/godotenv/autoload"
"go.uber.org/zap"
"os"
"strconv"
"strings"
)

const (
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/PuerkitoBio/goquery/.gitattributes

This file was deleted.

Loading

0 comments on commit 1a733c9

Please sign in to comment.