Skip to content

Commit

Permalink
Merge pull request #43 from hbomb79/testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hbomb79 authored Jul 21, 2024
2 parents e21d365 + c41b0ca commit ce07d6e
Show file tree
Hide file tree
Showing 71 changed files with 4,804 additions and 301 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tests/
mocks/
.*

!tests/test-config.toml
2 changes: 2 additions & 0 deletions .githooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Git Hooks

4 changes: 4 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

echo "Running pre-commit linting..."
make pre-commit
23 changes: 15 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Go

on: [push, pull_request]
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.1

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5.0.0
with:
go-version: '1.21.6'
go-version: '1.22.5'

- name: Verify Go Mod
run: go mod verify
Expand All @@ -26,7 +26,7 @@ jobs:
run: go run honnef.co/go/tools/cmd/staticcheck@latest -f stylish -checks=all,-ST1000,-U1000 ./...

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3.7.0
uses: golangci/golangci-lint-action@v4.0.0
with:
# during the golangci-lint execution, many files are extracted
# which conflict with those which are cached by the go setup
Expand All @@ -36,6 +36,13 @@ jobs:
# https://github.com/golangci/golangci-lint-action/issues/807
skip-cache: true

# - name: Test
# run: go test -v ./...

- name: Setup FFmpeg
id: setup_ffmpeg
uses: federicocarboni/[email protected]

- name: Run Tests
uses: robherley/[email protected]
env:
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
FORMAT_FFMPEG_BINARY_PATH: ${{ steps.setup_ffmpeg.outputs.ffmpeg-path }}/ffmpeg
FORMAT_FFPROBE_BINARY_PATH: ${{ steps.setup_ffmpeg.outputs.ffmpeg-path }}/ffprobe
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode
.env
*.gen.go
mocks/
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ linters-settings:
case:
rules:
json: snake
gosec:
excludes:
- G601
13 changes: 13 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with-expecter: true
filename: "mock_{{.InterfaceName}}.go"
mockname: "Mock{{.InterfaceName}}"
outpkg: "{{.PackageName}}"
packages:
github.com/hbomb79/Thea/internal/ingest:
config:
dir: "../../internal/ingest/mocks"
interfaces:
Searcher:
Scraper:
DataStore:

23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.22.1-alpine AS builder

ENV CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64

WORKDIR /

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN go generate ./...
RUN go build -o thea .

FROM alpine:latest

COPY ./tests/test-config.toml /config.toml
COPY --from=builder /thea /thea

EXPOSE 8080
ENTRYPOINT ["/thea"]
49 changes: 30 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ BINARY_NAME := thea
# HELPERS
# ==================================================================================== #

.PHONY: configure-hooks
configure-hooks:
@git config --local core.hooksPath .githooks/

## help: print this help message
.PHONY: help
help:
Expand All @@ -29,41 +33,37 @@ no-dirty:
tidy:
go fmt ./...
go mod tidy -v

.PHONY: fix
fix: build
go mod tidy -v
golangci-lint run --fix

## audit: run quality control checks
.PHONY: audit
audit: tidy
go generate ./...
go mod verify

## lint: run linting of src and go mod using std tools and golangci-lint
.PHONY: lint
lint:
go vet ./...
# go run honnef.co/go/tools/cmd/staticcheck@latest -f stylish -checks=all,-ST1000,-U1000 ./...
golangci-lint run
go run honnef.co/go/tools/cmd/staticcheck@latest -f stylish -checks=all,-ST1000,-U1000 ./...

## audit: run quality control checks (tidy, lints, builds, checks for dep vulns and runs tests)
.PHONY: audit
audit: build tidy lint
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
# go test -race -buildvcs -vet=off ./...
go test -buildvcs -vet=off ./...

.PHONY: test
test: build
go test --count=1 -p=1 -v ./...

# ==================================================================================== #
# DEVELOPMENT
# ==================================================================================== #

## test: run all tests
# .PHONY: test
# test:
# go test -v -race -buildvcs ./...

## clean: remove existing artifcats generated by this makefile (.bin)
.PHONY: clean
clean:
rm -rf ./.bin/

## build: build the application
.PHONY: build
build:
build: configure-hooks
go generate ./...
go build -o=.bin/${BINARY_NAME}

Expand All @@ -79,5 +79,16 @@ run/live:
--pattern '**/*.go' \
--pattern '**/*.yaml' \
--pattern '**/*.tmpl' \
--ignore 'internal/api/gen/*.gen.go' \
--ignore '**/*.gen.go' \
--ignore '**/mocks/*' \
-- make run

# ==================================================================================== #
# GIT HOOKS
# ==================================================================================== #

.PHONY: pre-commit
pre-commit: lint

.PHONY: pre-push
pre-push: audit
71 changes: 56 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module github.com/hbomb79/Thea

go 1.21
go 1.22.5

require (
github.com/deepmap/oapi-codegen/v2 v2.0.0
github.com/docker/docker v24.0.2+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/docker v26.1.2+incompatible
github.com/docker/go-connections v0.5.0
github.com/floostack/transcoder v1.1.2-0.20210806093423-9367de148a50
github.com/getkin/kin-openapi v0.118.0
github.com/go-playground/validator/v10 v10.14.1
github.com/google/uuid v1.5.0
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/ilyakaznacheev/cleanenv v1.4.2
Expand All @@ -22,10 +22,52 @@ require (
github.com/pressly/goose/v3 v3.13.4
github.com/rjeczalik/notify v0.9.3
github.com/simukti/sqldb-logger v0.0.0-20230108155151-646c1a075551
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.28.0
github.com/testcontainers/testcontainers-go/modules/postgres v0.28.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

Expand All @@ -43,16 +85,16 @@ require (

require (
github.com/golang-jwt/jwt/v5 v5.0.0
github.com/kr/pretty v0.3.0 // indirect
github.com/hbomb79/go-chanassert v0.2.0
)

require (
github.com/adrg/strutil v0.3.0
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/labstack/gommon v0.4.2
github.com/leodido/go-urn v1.2.4 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
Expand All @@ -61,7 +103,7 @@ require (
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.0.2 // indirect
gotest.tools/v3 v3.5.0
)

require (
Expand All @@ -74,21 +116,20 @@ require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Masterminds/squirrel v1.5.4
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/joho/godotenv v1.5.1
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/mattn/go-sqlite3 v1.14.7 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/crypto v0.17.0
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/crypto v0.23.0
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
)

Expand Down
Loading

0 comments on commit ce07d6e

Please sign in to comment.