Skip to content

Commit 9e2a73d

Browse files
Merge pull request #1 from go-feature-flag/init-repo
Init repo
2 parents d4297c6 + 75381e7 commit 9e2a73d

20 files changed

+1518
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: "Build"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [ opened, synchronize, reopened ]
8+
9+
jobs:
10+
Build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 1
17+
- name: Setup go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
check-latest: true
22+
- run: make vendor
23+
- run: make build
24+
Lint:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 1
31+
- name: Setup go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version-file: go.mod
35+
check-latest: true
36+
- run: make lint
37+
38+
Test:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 1
45+
- name: Setup go
46+
uses: actions/setup-go@v5
47+
with:
48+
go-version-file: go.mod
49+
check-latest: true
50+
- run: make test
51+
52+
Coverage:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout repository
56+
uses: actions/checkout@v4
57+
with:
58+
fetch-depth: 1
59+
- name: Setup go
60+
uses: actions/setup-go@v5
61+
with:
62+
go-version-file: go.mod
63+
check-latest: true
64+
- run: make coverage
65+
- name: Upload coverage reports to Codecov
66+
uses: codecov/codecov-action@v4
67+
with:
68+
fail_ci_if_error: true
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
env:
71+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
72+
73+
# swagger-change:
74+
# name: Swagger Change
75+
# runs-on: ubuntu-latest
76+
# steps:
77+
# - name: Checkout repository
78+
# uses: actions/checkout@v4
79+
# with:
80+
# fetch-depth: 1
81+
# - name: Setup go
82+
# uses: actions/setup-go@v5
83+
# with:
84+
# go-version-file: go.mod
85+
# check-latest: true
86+
# - run: make swagger
87+
# - run: git diff --exit-code --quiet

.gitignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
out/
2+
3+
.DS_Store
4+
.vscode
5+
.idea
6+
*.iml
7+
.run
8+
9+
# reporting stuff
10+
*-report.xml
11+
*.cov
12+
coverage.xml
13+
bin/
14+
15+
16+
# CI deployment folder
17+
.deployment
18+
19+
# goreleaser
20+
dist/
21+
release/
22+
23+
vendor/
24+
25+
# venv created for the documentation script
26+
.venv
27+
28+
# binaries
29+
release/
30+
cmd/migrationcli/migrationcli
31+
cmd/relayproxy/relayproxy
32+
tmp/
33+
34+
# Local dev files
35+
goff-proxy.yaml
36+
flags.yaml
37+
38+
go-feature-flag-relay-proxy/
39+
40+
# AWS SAM build folder
41+
.aws-sam
42+
43+
node_modules/
44+
oryxBuildBinary
45+
46+
./.sonarlint
47+
sonarlint.xml
48+
vcs.xml
49+
workspace.xml
50+
codeStyles/
51+
inspectionProfiles/
52+
misc.xml
53+
modules.xml
54+
shelf/

.golangci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
linters:
2+
enable:
3+
- asciicheck
4+
- bodyclose
5+
- dogsled
6+
- dupl
7+
- funlen
8+
- gochecknoinits
9+
- gocognit
10+
- goconst
11+
- gocritic
12+
- gocyclo
13+
- revive
14+
- gosec
15+
- lll
16+
- misspell
17+
- nakedret
18+
- noctx
19+
- prealloc
20+
- rowserrcheck
21+
- copyloopvar
22+
- stylecheck
23+
- unconvert
24+
- unparam
25+
- whitespace
26+
- gofmt
27+
- gci
28+
# - gofumpt
29+
linters-settings:
30+
funlen:
31+
lines: 90
32+
statements: 50
33+
gocritic:
34+
disabled-checks:
35+
- singleCaseSwitch
36+
golint:
37+
min-confidence: 0.6
38+
gosimple:
39+
checks: ["all","-S1023"]
40+
gofumpt:
41+
module-path: github.com/thomaspoignant/go-feature-flag
42+
gci:
43+
skip-generated: true
44+
no-lex-order: true
45+
issues:
46+
exclude-dirs:
47+
- (^|/)bin($|/)
48+
- (^|/)examples($|/)
49+
exclude-rules:
50+
- path: _test.go
51+
linters:
52+
- funlen
53+
- maligned
54+
- noctx
55+
- scopelint
56+
- bodyclose
57+
- lll
58+
- goconst
59+
- gocognit
60+
- gocyclo
61+
- gochecknoinits
62+
- dupl
63+
- staticcheck
64+
- revive
65+
- gosec
66+
- copyloopvar
67+
- path: _mock.go
68+
linters:
69+
- funlen
70+
- maligned
71+
- noctx
72+
- scopelint
73+
- bodyclose
74+
- lll
75+
- goconst
76+
- gocognit
77+
- gocyclo
78+
- gochecknoinits
79+
- dupl
80+
- staticcheck
81+
- revive

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/Bahjat/pre-commit-golang
3+
rev: v1.0.3
4+
hooks:
5+
- id: gofumpt
6+
7+
- repo: https://github.com/golangci/golangci-lint
8+
rev: v1.59.0
9+
hooks:
10+
- id: golangci-lint
11+
entry: golangci-lint run --enable-only=gci --fix
12+
13+
- repo: https://github.com/psf/black-pre-commit-mirror
14+
rev: 23.11.0
15+
hooks:
16+
- id: black
17+
language_version: python3.12

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
GOCMD=go
2+
GOTEST=$(GOCMD) test
3+
GOVET=$(GOCMD) vet
4+
5+
GREEN := $(shell tput -Txterm setaf 2)
6+
YELLOW := $(shell tput -Txterm setaf 3)
7+
WHITE := $(shell tput -Txterm setaf 7)
8+
CYAN := $(shell tput -Txterm setaf 6)
9+
RESET := $(shell tput -Txterm sgr0)
10+
11+
.PHONY: all test build vendor
12+
13+
14+
15+
all: help
16+
## Build:
17+
build: build-api ## Build all the binaries and put the output in out/bin/
18+
19+
create-out-dir:
20+
mkdir -p out/bin
21+
22+
build-api: create-out-dir ## Build the migration cli in out/bin/
23+
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/goff-api .
24+
25+
clean: ## Remove build related file
26+
-rm -fr ./bin ./out ./release
27+
-rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml
28+
29+
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
30+
$(GOCMD) mod tidy
31+
$(GOCMD) mod vendor
32+
33+
## Dev:
34+
swagger: ## Build swagger documentation
35+
$(GOCMD) install github.com/swaggo/swag/cmd/swag@latest
36+
cd cmd/relayproxy && swag init --parseDependency --parseDepth=1 --parseInternal --markdownFiles docs
37+
38+
setup-env:
39+
docker stop goff || true
40+
docker rm goff || true
41+
docker run --name goff -e POSTGRES_DB=gofeatureflag -e POSTGRES_PASSWORD=my-secret-pw -p 5432:5432 -e POSTGRES_USER=goff-user -d postgres
42+
sleep 2
43+
migrate -source "file://database_migration" -database "postgres://goff-user:my-secret-pw@localhost:5432/gofeatureflag?sslmode=disable" up
44+
45+
## Test:
46+
test: ## Run the tests of the project
47+
$(GOTEST) -v -race ./...
48+
49+
coverage: ## Run the tests of the project and export the coverage
50+
$(GOTEST) -cover -covermode=count -tags=docker -coverprofile=coverage.cov.tmp ./... \
51+
&& cat coverage.cov.tmp | grep -v "/examples/" > coverage.cov
52+
53+
54+
## Lint:
55+
lint: ## Use golintci-lint on your project
56+
mkdir -p ./bin
57+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest # Install linters
58+
./bin/golangci-lint run --timeout=5m --timeout=5m ./... --enable-only=gci --fix # Run linters
59+
60+
## Help:
61+
help: ## Show this help.
62+
@echo ''
63+
@echo 'Usage:'
64+
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
65+
@echo ''
66+
@echo 'Targets:'
67+
@awk 'BEGIN {FS = ":.*?## "} { \
68+
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
69+
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
70+
}' $(MAKEFILE_LIST)

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
1-
# app-api
2-
API for https://app.gofeatureflag.org to manage your feature flags.
1+
# GO Feature Flag API - API to configure your feature flag
2+
![WIP](https://img.shields.io/badge/status-%E2%9A%A0%EF%B8%8FWIP-red)
3+
4+
This repository is a work in progress initiative to create an API to manage your feature flags.
5+
6+
## Goals
7+
- Create an API to manage your feature flags
8+
- API should allow to add, modify and delete feature flags.
9+
- Use a database to store the feature flags.
10+
- This API is created to integrate a front end application to manage the feature flags.
11+
- We should manage authentication and authorization to access the API.
12+
- Authentication should be generic enough to be integrated with any authentication provider.
13+
- We should be able to provide history of a flag to see when it was created, modified and deleted.
14+
15+
## Tech stack
16+
- GO API using echo
17+
- Postgres database using `sqlx` and `pq` as driver.
18+
19+
20+
21+
## Contributing
22+
⚠️ Since this it is a work in progress initiative please come to the [Slack channel](https://gofeatureflag.org/slack) first before contributing.
23+
24+
### How to start the project.
25+
After cloning the project you can start the database _(using docker)_:
26+
```shell
27+
make setup-env
28+
```
29+
It will start an instance of postgres with the following credentials:
30+
- user: `goff-user`
31+
- password: `my-secret-pw`
32+
33+
And it will apply the database migrations to your environment.
34+
35+
To start the API:
36+
```shell
37+
make build
38+
./out/bin/goff-api
39+
```

codecov.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ignore:
2+
- "examples"
3+
- "testdata"
4+
- "testutils"
5+
- "**/_test.go"
6+
- "**/_mock.go"
7+
- "**/testdata/"
8+
- "**/testutils/"

0 commit comments

Comments
 (0)