Skip to content

Commit 82d9cb9

Browse files
fix: codacy error in ci and add readme
1 parent 17dae71 commit 82d9cb9

File tree

2 files changed

+116
-1
lines changed

2 files changed

+116
-1
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: go mod download
4545

4646
- name: Run tests
47-
run: go test -v -race -coverprofile=coverage.out ./...
47+
run: go test -v -race -covermode=atomic -coverprofile=coverage.out ./...
4848
env:
4949
DATABASE_URL: postgres://postgres:password@localhost:5432/testdb?sslmode=disable
5050

@@ -53,6 +53,12 @@ jobs:
5353
with:
5454
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
5555
coverage-reports: coverage.out
56+
force-coverage-parser: go
57+
58+
- name: Codacy finalize coverage
59+
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) final
60+
env:
61+
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
5662

5763
- name: Run linter
5864
uses: golangci/golangci-lint-action@v3

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Forgotten API
2+
3+
A Twitter-like social media API built with Go. This is an ongoing project; the README and features will evolve over time.
4+
5+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b107d45cd0f14123ae60578870cf9a28)](https://app.codacy.com/gh/nevzattalhaozcan/forgotten/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
6+
[![Codacy Coverage Badge](https://app.codacy.com/project/badge/Coverage/b107d45cd0f14123ae60578870cf9a28)](https://app.codacy.com/gh/nevzattalhaozcan/forgotten/dashboard?utm_source=github.com&utm_medium=referral&utm_content=nevzattalhaozcan/forgotten&utm_campaign=Badge_Coverage)
7+
[![CI](https://github.com/nevzattalhaozcan/forgotten/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/nevzattalhaozcan/forgotten/actions/workflows/ci.yml)
8+
9+
10+
## Overview
11+
12+
- REST API with JWT auth, user registration/login
13+
- Built with Gin and Gorm (PostgreSQL)
14+
- Structured logging, request metrics, and CORS enabled
15+
- Swagger/OpenAPI documentation (generated with swag)
16+
- Dockerized for local/dev; CI/CD via GitHub Actions
17+
18+
## Tech stack
19+
20+
- Go 1.23
21+
- Gin (HTTP), Gorm (ORM, Postgres)
22+
- Swagger (swaggo), Prometheus metrics
23+
- Docker + docker-compose
24+
- GitHub Actions (CI + Deploy)
25+
26+
## Getting started
27+
28+
1) Prerequisites
29+
- Go 1.23+
30+
- Docker (optional, for containerized dev)
31+
- PostgreSQL (if running locally without Docker)
32+
33+
2) Clone and enter the project
34+
```sh
35+
git clone https://github.com/nevzattalhaozcan/forgotten.git
36+
cd forgotten
37+
```
38+
39+
3) Configure environment
40+
- Copy `.env.example` to `.env` and adjust as needed:
41+
- `DATABASE_URL` (e.g., postgres://user:password@localhost:5432/forgotten_db?sslmode=disable)
42+
- Seed data lives at `data/seed_users.json`.
43+
44+
### Run locally (without Docker)
45+
46+
```sh
47+
# run the server
48+
go run ./cmd/server
49+
# server defaults to http://localhost:8080
50+
```
51+
52+
### Run with Docker Compose
53+
54+
```sh
55+
cd docker
56+
docker-compose up -d
57+
# API available at http://localhost:8080
58+
```
59+
60+
## API docs (Swagger)
61+
62+
- The top-level annotations live in `cmd/server/main.go`.
63+
- (If needed) generate/update docs:
64+
```sh
65+
go install github.com/swaggo/swag/cmd/swag@latest
66+
swag init -g cmd/server/main.go -o ./docs
67+
```
68+
- Swagger UI can be served at `/swagger` once wired in the router.
69+
- If not yet enabled, add a route that uses `gin-swagger` and import the generated `docs` package.
70+
71+
Base path: `/api/v1`
72+
73+
## Testing
74+
75+
- Unit tests:
76+
```sh
77+
go test -v -race ./...
78+
```
79+
- Coverage:
80+
```sh
81+
go test -v -race -coverprofile=coverage.out ./...
82+
```
83+
84+
Note: Most tests use an in-memory SQLite DB via `pkg/testutil`; add Postgres-backed integration tests as needed.
85+
86+
## Metrics
87+
88+
- Prometheus-compatible metrics middleware is included. Expose your metrics endpoint (e.g., `/metrics`) as you wire up monitoring.
89+
90+
## Project structure (high level)
91+
92+
- `cmd/server` – application entrypoint
93+
- `internal/` – config, database, handlers, repository, services, middleware, models
94+
- `pkg/` – shared libs (logger, metrics, utils, test utilities)
95+
- `docs/` – generated Swagger docs
96+
- `docker/` – Dockerfile, docker-compose, Prometheus config
97+
- `data/` – seed fixtures
98+
99+
## CI/CD
100+
101+
- `.github/workflows/ci.yml` runs tests, lint, and build on PRs/commits.
102+
- `.github/workflows/deploy.yml` builds and pushes a Docker image and deploys over SSH on main (requires repo secrets).
103+
104+
## Roadmap
105+
106+
- More endpoints (profiles, posts, timelines)
107+
- RBAC/permissions
108+
- Full integration test suite
109+
- Production-ready observability and hardening

0 commit comments

Comments
 (0)