Skip to content
Merged
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
128 changes: 128 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI

on:
pull_request:
branches:
- "*"
push:
branches:
- prod
- main
- master
- dev

env:
GO_VERSION: "1.24.x"
NODE_VERSION: "24"

jobs:
go-server:
name: Go Server CI
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/server

services:
postgres:
image: postgres:18
env:
POSTGRES_USER: coderz-space
POSTGRES_PASSWORD: coderz-space
POSTGRES_DB: coderz
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: apps/server/go.sum

- name: Install dependencies
run: go mod download

- name: Verify dependencies
run: go mod verify

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

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
run: staticcheck ./...

- name: Install golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
working-directory: apps/server
args: --timeout=5m

- name: Setup test environment
run: |
cp .env .env.test
echo "DB_URL=postgresql://coderz-space:coderz-space@localhost:5432/coderz?sslmode=disable" >> .env.test
echo "DB_DSN=postgresql://coderz-space:coderz-space@localhost:5432/coderz?sslmode=disable" >> .env.test

- name: Run migrations
run: |
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
migrate -path ./db/migrations -database "postgresql://coderz-space:coderz-space@localhost:5432/coderz?sslmode=disable" up

- name: Run tests
env:
DB_URL: postgresql://coderz-space:coderz-space@localhost:5432/coderz?sslmode=disable
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...

- name: Upload coverage
uses: codecov/codecov-action@v5
with:
files: ./apps/server/coverage.out
flags: go-server
fail_ci_if_error: false

- name: Build binary
run: go build -v -o bin/main ./cmd/main.go

- name: Install swag
run: go install github.com/swaggo/swag/cmd/swag@latest

- name: Generate Swagger docs
run: swag init -o ./swagger --parseDependency --parseInternal -g cmd/main.go

- name: Verify Swagger docs
run: test -f swagger/swagger.json && test -f swagger/swagger.yaml

docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: go-server

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: ./apps/server
file: ./apps/server/dockerfile
push: false
tags: coderz-space-server:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ Thumbs.db
*.tmp
*.log
private.md

.kiro
#######################################
# Environment / Secrets
#######################################

/temp

main
*SUMMARY.md
.env
.env.*
!.env.example
Expand Down
52 changes: 52 additions & 0 deletions apps/server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Git
.git
.gitignore

# Environment
.env
.env.*
!.env.example

# Build artifacts
bin/
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
coverage.out
*.coverprofile

# Documentation
README.md
*.md
!swagger/*.md

# CI/CD
.github/
.gitlab-ci.yml

# IDE
.vscode/
.idea/
*.iml

# Logs
logs/
*.log

# Docker
dockerfile
.dockerignore
docker-compose.yml

# Temporary files
*.tmp
*.swp
*.swo
.DS_Store
Thumbs.db

# Test files (optional - uncomment if you don't want tests in image)
# *_test.go
21 changes: 14 additions & 7 deletions apps/server/.env.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# Server Configuration
PORT=8080
FRONTEND_ORIGIN=http://localhost:3000
ENVIRONMENT=development
JWT_SECRET=j3QE2U6eBQj8EvRUnhPF2Sf2YuChgfhgfjhg0JMeSVWDNO138RYMj3QE2U6eBQj8EvRUnhPF2Sf2YuC0JMeSVWDNO138RYMj3QE2U6eBQj8EvRUnhPF2Sf2YuC0JMeSVWDNO138RYM
JWT_EXPIRES=1h # 1 hour
APP_NAME=Coderz_Space
VERSION=0.1.0

# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES=1h

# Logging Configuration
LOG_LEVEL=info
FILE_LOG_LEVEL=info
APP_NAME=Coderz_Space

VERSION=0.1.0
# Database Configuration
# Local development (with Docker Compose)
DB_URL=postgresql://coderz-space:coderz-space@localhost:5432/coderz?sslmode=disable
DB_DSN=postgresql://coderz-space:coderz-space@postgres:5432/coderz?sslmode=disable

# Database config
DB_URL=db_connectinon_url
# Database Connection Pool
MAX_DB_CONNS=10
MIN_DB_CONNS=2
MAX_DB_CONN_LIFETIME=1h
MAX_DB_CONN_IDLE_TIME=30m

55 changes: 55 additions & 0 deletions apps/server/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
run:
timeout: 5m
tests: true
modules-download-mode: readonly

linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- goimports
- misspell
- unconvert
- unparam
- gosec
- gocritic

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true

govet:
enable-all: true
disable:
- shadow

gofmt:
simplify: true

gosec:
excludes:
- G404 # Use of weak random number generator (math/rand instead of crypto/rand)

gocritic:
enabled-tags:
- diagnostic
- style
- performance

issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosec
- path: cmd/main\.go
linters:
- errcheck
max-issues-per-linter: 0
max-same-issues: 0
Loading
Loading