Skip to content
Merged

Go #3

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "just generate && go build -o ./tmp/main cmd/server/main.go"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "node_modules", "bin"]
exclude_file = []
exclude_regex = ["_test.go", ".*_templ.go", ".*\\.sql\\.go", "internal/database/(db|models|querier|copyfrom)\\.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "templ", "sql", "yaml", "yml", "toml", "env"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = false
keep_scroll = true
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Application Environment (dev, production)
APP_ENVIRONMENT=dev

# Application Settings
APP_APPLICATION__HOST=127.0.0.1
APP_APPLICATION__PORT=8000

# Database Connection
DATABASE_URL=postgres://postgres:password@localhost:5432/robswebhub?sslmode=disable

# For production on Fly.io
# APP_ENVIRONMENT=production
# APP_APPLICATION__HOST=0.0.0.0
# APP_APPLICATION__PORT=8080
1 change: 0 additions & 1 deletion .github/workflows/fly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ jobs:
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

145 changes: 145 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: General Checks

on: [push, pull_request]

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Install tools
run: |
go install github.com/a-h/templ/cmd/templ@latest
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest

- name: Generate code
run: |
templ generate
sqlc generate

- name: Download dependencies
run: go mod download

- name: Run go build
run: go build -v ./...

test:
name: Test Suite
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: robswebhub_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Install tools
run: |
go install github.com/a-h/templ/cmd/templ@latest
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

- name: Generate code
run: |
templ generate
sqlc generate

- name: Run migrations
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/robswebhub_test?sslmode=disable
run: |
migrate -path migrations -database "$DATABASE_URL" up

- name: Run tests
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/robswebhub_test?sslmode=disable
run: go test -v -race -coverprofile=coverage.out ./...

- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella
continue-on-error: true

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Install tools
run: |
go install github.com/a-h/templ/cmd/templ@latest
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest

- name: Generate code
run: |
templ generate
sqlc generate

- name: Run go fmt
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files are not formatted:"
gofmt -s -l .
exit 1
fi

- name: Run go vet
run: go vet ./...

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=5m

- name: Check templ formatting
run: |
templ fmt .
if [ -n "$(git status --porcelain)" ]; then
echo "templ files are not formatted. Please run 'templ fmt .'"
git diff
exit 1
fi

- name: Verify go mod tidy
run: |
go mod tidy
if [ -n "$(git status --porcelain)" ]; then
echo "go.mod or go.sum is not tidy. Please run 'go mod tidy'"
git diff
exit 1
fi
69 changes: 0 additions & 69 deletions .github/workflows/rust.yml

This file was deleted.

69 changes: 67 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
/target
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/
tmp/

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

# Output of the go coverage tool
*.out
coverage.html

# Dependency directories
vendor/

# Go workspace file
go.work

# Environment variables
.env
/images/match_plots/*
.env.local
.env.*.local

# IDE specific files
.idea/
*.swp
*.swo
*~
.vscode/
*.iml

# OS specific files
.DS_Store
Thumbs.db

# Air tmp directory
tmp/

# Just command runner
.just/

# Generated files
*_templ.go
*_templ.txt
internal/database/*.sql.go
internal/database/db.go
internal/database/models.go
internal/database/querier.go

# Static files that should be generated
static/images/match_plots/*.png

# Database
*.db
*.sqlite

# Logs
*.log

# Fly.io
fly.toml.local

# Docker
docker-compose.override.yml
Loading
Loading