always set https on redirect on prod #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Run Tests | |
| 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 | |
| go install gotest.tools/gotestsum@latest | |
| - name: Generate code | |
| run: | | |
| templ generate | |
| sqlc generate | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run Unit Tests | |
| run: | | |
| gotestsum --format testname -- -v -race -coverprofile=coverage.out ./... | |
| - name: Run Integration Tests | |
| env: | |
| DATABASE_URL: postgres://postgres:password@localhost:5432/robswebhub_test?sslmode=disable | |
| run: | | |
| migrate -path migrations -database "$DATABASE_URL" up | |
| gotestsum --format testname -- -v -race -tags=integration ./... | |
| - name: Run E2E Tests | |
| env: | |
| DATABASE_URL: postgres://postgres:password@localhost:5432/robswebhub_test?sslmode=disable | |
| run: | | |
| gotestsum --format testname -- -v -race -tags=e2e ./... | |
| - name: Generate Test Report | |
| if: always() | |
| run: | | |
| gotestsum --junitfile test-results.xml --format standard-verbose -- -v ./... | |
| - name: Upload Test Results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: test-results.xml | |
| - name: Upload Coverage Reports | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.out | |
| flags: unittests | |
| name: codecov-umbrella | |
| continue-on-error: true | |
| - name: Display Test Summary | |
| if: always() | |
| run: | | |
| echo "## Test Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "Test results have been generated with gotestsum" >> $GITHUB_STEP_SUMMARY | |
| if [ -f test-results.xml ]; then | |
| echo "✅ Test report available as artifact" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| if [ -f coverage.out ]; then | |
| echo "📊 Coverage report uploaded to Codecov" >> $GITHUB_STEP_SUMMARY | |
| go tool cover -func=coverage.out | tail -n 1 >> $GITHUB_STEP_SUMMARY | |
| fi | |
| 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 | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| - name: Generate code | |
| run: | | |
| templ generate | |
| sqlc generate | |
| - 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 formatting | |
| run: | | |
| templ fmt . | |
| gofmt -l -w . | |
| goimports -w . | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Files are not formatted." | |
| 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 |