diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..680570d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.22 + + - name: Install dependencies + run: | + go mod download + + - name: Lint code + run: | + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + golangci-lint run + + - name: Run tests + run: | + go test ./... + + - name: Build Docker image + run: | + docker build -t rentease . \ No newline at end of file diff --git a/Makefile b/Makefile index a865ab0..f35f4f0 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ run: build @docker run -p ${PORT}:${PORT} -e DATABASE_URL="host=docker.for.mac.host.internal user=${DB_USER} database=${DB_NAME}" -e PORT=${PORT} ${NAME} dev: templ @air cmd/main.go +test: + @go test ./... cron: @go run cmd/cron/main.go templ: diff --git a/main.go b/main.go index 6f11dab..640c40b 100644 --- a/main.go +++ b/main.go @@ -34,8 +34,8 @@ func main() { } } -func run(ctx context.Context, getEnv func(string) string) error { - ctx, cancel := signal.NotifyContext(ctx, os.Interrupt) +func run(c context.Context, getEnv func(string) string) error { + ctx, cancel := signal.NotifyContext(c, os.Interrupt) defer cancel() if err := sentry.Init(sentry.ClientOptions{