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
5 changes: 4 additions & 1 deletion .github/workflows/release-bump-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
inputs:
modulePath: { type: string, required: true }
version: { type: string, required: true }
goModDirectoryPath: { type: string, required: false, default: "." }

jobs:
bump-module:
Expand All @@ -24,14 +25,16 @@ jobs:
- name: Setup go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: ${{ inputs.modulePath }}/go.mod
go-version-file: ${{ inputs.goModDirectoryPath }}/go.mod
check-latest: true

- name: Update internal module
env:
VERSION: ${{ inputs.version }}
MODULE_PATH: ${{ inputs.modulePath }}
GO_MOD_DIRECTORY_PATH: ${{ inputs.goModDirectoryPath }}
run: |
cd ${GO_MOD_DIRECTORY_PATH}
export GOWORK=off
go get github.com/thomaspoignant/go-feature-flag/${MODULE_PATH}@${VERSION }
go mod tidy
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ jobs:
modulePath: modules/core
version: ${{ needs.release-please.outputs.module_core_version }}

bump-module-core-dependency-for-evaluation:
if: ${{ needs.release-please.outputs.module_core_released == 'true' }}
uses: ./.github/workflows/release-bump-modules.yml
needs: release-please
with:
modulePath: modules/core
version: ${{ needs.release-please.outputs.module_core_version }}
goModDirectoryPath: modules/evaluation

python-provider-release:
if: ${{ needs.release-please.outputs.provider_python_released == 'true' }}
uses: ./.github/workflows/release-python-provider.yml
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ oryxBuildBinary
volume

.cursor/
.claude/
.claude/

go.work
go.work.sum
66 changes: 42 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@ Please take a moment to review the following guidelines.
## Table of Contents

1. [Code of Conduct](#-code-of-conduct)
2. [How Can I Contribute?](#-how-can-i-contribute)
3. [Where can I ask questions about the project?](#-where-can-i-ask-questions-about-the-project)
4. [Book a Meeting](#-book-a-meeting)
5. [Development Setup](#-development-setup)
6. [Documentation](#-documentation)
7. [License](#-license)

1. [How Can I Contribute?](#-how-can-i-contribute)
1. [Where can I ask questions about the project?](#-where-can-i-ask-questions-about-the-project)
1. [Book a Meeting](#-book-a-meeting)
1. [Development Setup](#-development-setup)
1. [Documentation](#-documentation)
1. [License](#-license)

## 🚓 Code of Conduct

We expect all contributors to abide by our [Code of Conduct](CODE_OF_CONDUCT.md).
Please read it thoroughly before contributing.

## 🙇 How Can I Contribute?

### Bug Reports

If you encounter any bugs or issues with the project, please [create a new issue](../../issues/new?assignees=&labels=bug%2Cneeds-triage&projects=&template=bug.yaml&title=%28bug%29+%3Ctitle%3E) and include as many details as possible, such as:

- A clear and descriptive title
Expand All @@ -35,15 +36,15 @@ If you encounter any bugs or issues with the project, please [create a new issue

### Feature Requests

If you have a feature idea that you would like to see implemented, please [create a new issue](../../issues/new?assignees=&labels=enhancement%2Cneeds-triage&projects=&template=feature.yaml&title=(feature)+<title>) with the following information:
If you have a feature idea that you would like to see implemented, please [create a new issue](<../../issues/new?assignees=&labels=enhancement%2Cneeds-triage&projects=&template=feature.yaml&title=(feature)+<title>>) with the following information:

- A clear and descriptive title
- A detailed description of the feature
- Any additional context that may be relevant

### Pull Requests

We welcome contributions in the form of pull requests.
We welcome contributions in the form of pull requests.

Before opening a pull request, we kindly request you check if there is an open issue related to your proposed contribution.
By doing so, we can initiate a discussion and provide feedback on your changes before proceeding with the pull request.
Expand All @@ -52,20 +53,20 @@ This approach ensures that your efforts align with the project's goals and enhan
If you want to take an issue that is already open, please follow those steps:

1. Check that the issue is not assigned.
2. Assign the issue to yourself by adding a comment on the issue containing the text `/assign-me`.
3. This will assign you the issue automatically.
4. After 10 days the assignment will be removed, if you need more time to work on it add a comment on the issue.
1. Assign the issue to yourself by adding a comment on the issue containing the text `/assign-me`.
1. This will assign you the issue automatically.
1. After 10 days the assignment will be removed, if you need more time to work on it add a comment on the issue.

To submit a pull request, follow these steps:

1. Fork the repository to your GitHub account.
2. Create a new branch from the `main` branch.
3. Make your changes.
4. Test your changes thoroughly.
5. Commit your changes with a clear and descriptive commit message.
6. Push your branch to your forked repository.
7. Open a pull request, comparing your branch to the `main` branch of this repository.
8. Provide a detailed description of your changes in the pull request.
1. Create a new branch from the `main` branch.
1. Make your changes.
1. Test your changes thoroughly.
1. Commit your changes with a clear and descriptive commit message.
1. Push your branch to your forked repository.
1. Open a pull request, comparing your branch to the `main` branch of this repository.
1. Provide a detailed description of your changes in the pull request.

We will review your pull request as soon as possible.
Please be patient, as it might take some time for us to get back to you.
Expand All @@ -75,37 +76,51 @@ If you want an early feedback on your pull requests, you can use gemini AI pull
It will trigger gemini to review your pull request.

## 🧑‍💻 Development Setup

We always strive to keep the project as simple as possible, so you will find everything you need in the `Makefile` at the root of the repository.

To start contributing please set up your GO environment and run:
GO Feature Flag is using a [go workspace](https://go.dev/doc/tutorial/workspaces) that needs to be initialized before starting any development.

To start contributing please set up your GO environment and run:

```shell
make vendor
make workspace-init # it will setup the go.work file at the root of the repo.
make vendor # will tidy the project and vendor the dependencies
```

It will download the dependencies and your project will be ready to be used.

### Coding standards

It is easier for contributors to work on the same project if it has a consistent, unified style, approach, and layout.

To help with that, we are using [pre-commit](https://pre-commit.com/) to lint before each commit, I would recommend you to install it, and to apply it to the project by running:

```bash
pre-commit install
```

### Tests

Every feature or bug should come with an associate test to keep the coverage as high as possible.
We aim to have 90% of coverage for the project.

To launch the tests please run:

```bash
make test
```

## 🤔 Where can I ask questions about the project?

If you want to contribute and you have any questions you can use different ways to contact us.

1. You can create an issue and ask your question - [Create an issue](https://github.com/thomaspoignant/go-feature-flag/issues/new/choose).
2. You can join the `#go-feature-flag` channel in the gopher slack.
1. You can join the `#go-feature-flag` channel in the gopher slack.
To join:
- Request an invitation [here](https://invite.slack.golangbridge.org/)
- Join the [`#go-feature-flag`](https://gophers.slack.com/archives/C029TH8KDFG) channel.
4. Send us an email to contact@gofeatureflag.org
1. Send us an email to contact@gofeatureflag.org

## 🎤 Book A Meeting

Expand All @@ -115,6 +130,7 @@ This will allow for a focused and interactive discussion.
## 📚 Documentation

We are maintaining 2 documentations:

- [README.md](README.md) which contains everything you need to know to start working with the module.
- [go-feature-flag website](https://gofeatureflag.org) which is the full detail website containing the documentation.

Expand All @@ -129,9 +145,11 @@ You can start locally the website.

1. Open a terminal and go to the root project of this repository.
2. Launch the command below, it will install the dependencies and run the local server for the documentation.

```shell
make watch-doc
```

3. You can now access to the documentation directly in your browser: [http://localhost:3000/](http://localhost:3000/).

## 🪪 License
Expand All @@ -144,4 +162,4 @@ If you want to check the stats of GO Feature Flag you can have a look at https:/

---

We encourage everyone to participate in this project and make it better for everyone. Happy contributing 🎉
We encourage everyone to participate in this project and make it better for everyone. Happy contributing 🎉
67 changes: 52 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ GOCMD=go
TINYGOCMD=tinygo
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
ALL_GO_MOD_DIRS := ./ ./modules/evaluation ./modules/core

# In CI we disable workspace mode.
ifeq ($(CI),true)
GOWORK_ENV := GOWORK=off
MODFLAG := -mod=vendor
else
GOWORK_ENV :=
MODFLAG :=
endif

GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
Expand All @@ -13,32 +23,40 @@ RESET := $(shell tput -Txterm sgr0)

all: help
## Build:
build: build-relayproxy build-lint build-editor-api build-jsonschema-generator build-cli ## Build all the binaries and put the output in out/bin/
build: build-modules build-relayproxy build-lint build-editor-api build-jsonschema-generator build-cli ## Build all the binaries and put the output in out/bin/

create-out-dir:
mkdir -p out/bin

build-relayproxy: create-out-dir ## Build the relay proxy in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/relayproxy ./cmd/relayproxy/
CGO_ENABLED=0 GO111MODULE=on $(GOWORK_ENV) $(GOCMD) build $(MODFLAG) -o out/bin/relayproxy ./cmd/relayproxy/

build-lint: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/lint ./cmd/lint/
CGO_ENABLED=0 GO111MODULE=on $(GOWORK_ENV) $(GOCMD) build $(MODFLAG) -o out/bin/lint ./cmd/lint/

build-cli: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/cli ./cmd/cli/
CGO_ENABLED=0 GO111MODULE=on $(GOWORK_ENV) $(GOCMD) build $(MODFLAG) -o out/bin/cli ./cmd/cli/

build-editor-api: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/editor-api ./cmd/editor/
CGO_ENABLED=0 GO111MODULE=on $(GOWORK_ENV) $(GOCMD) build $(MODFLAG) -o out/bin/editor-api ./cmd/editor/

build-jsonschema-generator: create-out-dir ## Build the jsonschema-generator in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/jsonschema-generator ./cmd/jsonschema-generator/
CGO_ENABLED=0 GO111MODULE=on $(GOWORK_ENV) $(GOCMD) build $(MODFLAG) -o out/bin/jsonschema-generator ./cmd/jsonschema-generator/

build-wasm: create-out-dir ## Build the wasm evaluation library in out/bin/
cd wasm && $(TINYGOCMD) build -o ../out/bin/gofeatureflag-evaluation.wasm -target wasm -opt=2 -opt=s --no-debug -scheduler=none && cd ..

build-wasi: create-out-dir ## Build the wasi evaluation library in out/bin/
cd wasm && $(TINYGOCMD) build -o ../out/bin/gofeatureflag-evaluation.wasi -target wasi -opt=2 -opt=s --no-debug -scheduler=none && cd ..

build-modules: ## Run build command to build all modules in the workspace
@echo "Building all modules in go.work..."
@$(GOCMD) work edit -json | jq -r '.Use[].DiskPath' | while read m; do \
echo "→ Building $$m"; \
( cd "$$m" && CGO_ENABLED=0 GO111MODULE=on $(GOWORK_ENV) $(GOCMD) build $(MODFLAG) ./... ); \
done


build-doc: ## Build the documentation
cd website; \
npm i && npm run build
Expand All @@ -47,17 +65,36 @@ clean: ## Remove build related file
-rm -fr ./bin ./out ./release
-rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml

vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
$(GOCMD) mod tidy
$(GOCMD) mod vendor
vendor: tidy ## Copy of all packages needed to support builds and tests in the vendor directory
ifneq ($(CI),)
$(GOWORK_ENV) $(GOCMD) mod vendor
else
$(GOWORK_ENV) $(GOCMD) work vendor
endif

tidy: ## Run go mod tidy for all modules in the workspace
ifeq ($(CI),)
$(GOWORK_ENV) $(GOCMD) work sync
endif
@echo "Tidying all modules in go.work..."
@$(GOCMD) work edit -json | jq -r '.Use[].DiskPath' | while read m; do \
echo "→ Tidying $$m"; \
( cd "$$m" && $(GOWORK_ENV) $(GOCMD) mod tidy ); \
done


## Dev:
workspace-init:
go work init
$(foreach module, $(ALL_GO_MOD_DIRS), go work use $(module);)
go work sync

watch-relayproxy: ## Launch the relay proxy in watch mode.
docker run -it --rm -w /go/src/github.com/thomaspoignant/go-feature-flag/ \
-v $(shell pwd):/go/src/github.com/thomaspoignant/go-feature-flag \
-v $(shell pwd)/cmd/relayproxy/testdata/config/valid-file.yaml:/goff/goff-proxy.yaml \
-p 1031:1031 cosmtrek/air \
--build.cmd "go build -mod vendor -o out/bin/relayproxy ./cmd/relayproxy/" \
--build.cmd "$(GOWORK_ENV) go build $(MODFLAG) -o out/bin/relayproxy ./cmd/relayproxy/" \
--build.bin "./out/bin/relayproxy"

watch-doc: ## Launch a local server to work on the documentation
Expand All @@ -69,11 +106,11 @@ serve-doc: ## Serve the doc build by the build-doc target
npm run serve

swagger: ## Build swagger documentation
$(GOCMD) install github.com/swaggo/swag/cmd/swag@latest
$(GOWORK_ENV) $(GOCMD) install github.com/swaggo/swag/cmd/swag@latest
cd cmd/relayproxy && swag init --parseDependency --parseDepth=1 --parseInternal --markdownFiles docs

generate-helm-docs: ## Generates helm documentation for the project
$(GOCMD) install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
$(GOWORK_ENV) $(GOCMD) install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
helm-docs

bump-helm-chart-version: ## Bump Helm chart version (usage: make bump-helm-chart-version VERSION=v1.2.3)
Expand All @@ -87,17 +124,17 @@ bump-helm-chart-version: ## Bump Helm chart version (usage: make bump-helm-chart

## Test:
test: ## Run the tests of the project
$(GOTEST) -v -race ./... -tags=docker
go list -f '{{.Dir}}/...' -m | xargs -I{} $(GOWORK_ENV) $(GOCMD) test -v -race -tags=docker {}

provider-tests: ## Run the integration tests for the Open Feature Providers
./openfeature/provider_tests/integration_tests.sh

coverage: ## Run the tests of the project and export the coverage
$(GOTEST) -cover -covermode=count -tags=docker -coverprofile=coverage.cov.tmp ./... \
$(GOWORK_ENV) $(GOTEST) -cover -covermode=count -tags=docker -coverprofile=coverage.cov.tmp ./... \
&& cat coverage.cov.tmp | grep -v "/examples/" > coverage.cov

bench: ## Launch the benchmark test
$(GOTEST) -tags=bench -bench Benchmark -cpu 2 -run=^$$
$(GOWORK_ENV) $(GOTEST) -tags=bench -bench Benchmark -cpu 2 -run=^$$

## Lint:
lint: ## Use golintci-lint on your project
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/evaluate/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

ffclient "github.com/thomaspoignant/go-feature-flag"
"github.com/thomaspoignant/go-feature-flag/internal/utils"
"github.com/thomaspoignant/go-feature-flag/model"
"github.com/thomaspoignant/go-feature-flag/modules/core/model"
"github.com/thomaspoignant/go-feature-flag/modules/core/utils"
"github.com/thomaspoignant/go-feature-flag/retriever/fileretriever"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/evaluate/evaluate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/thomaspoignant/go-feature-flag/model"
"github.com/thomaspoignant/go-feature-flag/modules/core/model"
)

func Test_evaluate_Evaluate(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/generate/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/thomaspoignant/go-feature-flag/cmd/cli/generate/manifest/model"
"github.com/thomaspoignant/go-feature-flag/cmd/cli/helper"
"github.com/thomaspoignant/go-feature-flag/model/dto"
dtoCore "github.com/thomaspoignant/go-feature-flag/modules/core/dto"
)

func NewManifest(
Expand Down Expand Up @@ -61,7 +62,7 @@ func (m *Manifest) generateDefinitions(flagDTOs map[string]dto.DTO) (
definitions := make(map[string]model.FlagDefinition)
output := helper.Output{}
for flagKey, flagDTO := range flagDTOs {
flag := dto.ConvertDtoToInternalFlag(flagDTO)
flag := dtoCore.ConvertDtoToInternalFlag(flagDTO)
flagType, err := helper.GetFlagTypeFromVariations(flag.GetVariations())
if err != nil {
return model.FlagManifest{}, output,
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/helper/number_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/thomaspoignant/go-feature-flag/cmd/cli/generate/manifest/model"
"github.com/thomaspoignant/go-feature-flag/cmd/cli/helper"
"github.com/thomaspoignant/go-feature-flag/testutils/testconvert"
"github.com/thomaspoignant/go-feature-flag/modules/core/testutils/testconvert"
)

func TestGetFlagTypeFromVariations(t *testing.T) {
Expand Down
Loading
Loading