Skip to content

Commit 5f3cdce

Browse files
committed
feat: initial monorepo implementation
- gitsplit with Flagd repo - utilizes same org for read-only repo targets Signed-off-by: Tom Carrio <[email protected]>
1 parent d21ffb6 commit 5f3cdce

39 files changed

+398
-193
lines changed

.github/workflows/php-ci.yaml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: PHP CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
php:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
operating-system: [ubuntu-latest]
15+
php-version: ['7.4', '8.0', '8.1']
16+
project: ['Flagd']
17+
18+
# todo exclude some matrix combinations based on php version requirements
19+
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#excluding-matrix-configurations
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php-version }}
28+
coverage: xdebug
29+
extensions: ast, grpc
30+
31+
- name: Validate composer.json and composer.lock
32+
run: composer validate
33+
34+
- name: Cache Composer packages
35+
id: composer-cache
36+
uses: actions/cache@v3
37+
with:
38+
path: src/${{ matrix.project }}/vendor
39+
key: ${{ runner.os }}-${{ matrix.php-version }}-php-${{ hashFiles('**/composer.json') }}
40+
restore-keys: |
41+
${{ runner.os }}-${{ matrix.php-version }}-php-
42+
43+
- name: Install dependencies
44+
if: steps.composer-cache.outputs.cache-hit != 'true'
45+
working-directory: src/${{ matrix.project }}
46+
run: composer install --prefer-dist --no-progress --no-suggest
47+
48+
- name: Validate Packages composer.json
49+
working-directory: src/${{ matrix.project }}
50+
run: composer validate
51+
52+
- name: Check Style
53+
working-directory: src/${{ matrix.project }}
54+
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --stop-on-violation --using-cache=no -vvv
55+
56+
- name: Run Phan
57+
working-directory: src/${{ matrix.project }}
58+
env:
59+
PHAN_DISABLE_XDEBUG_WARN: 1
60+
run: vendor/bin/phan
61+
62+
- name: Run Psalm
63+
working-directory: src/${{ matrix.project }}
64+
run: vendor/bin/psalm --output-format=github --php-version=${{ matrix.php-version }}
65+
66+
- name: Run Phpstan
67+
working-directory: src/${{ matrix.project }}
68+
run: vendor/bin/phpstan analyse --error-format=github
69+
70+
- name: Run PHPUnit (unit tests)
71+
working-directory: src/${{ matrix.project }}
72+
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover --testsuite unit
73+
74+
### TODO: Implement integration testing
75+
# - name: Run PHPUnit (integration tests)
76+
# working-directory: src/${{ matrix.project }}
77+
# run: vendor/bin/phpunit --testsuite integration
78+
79+
### TODO: Enable codecov support
80+
# - name: Code Coverage
81+
# working-directory: src/${{ matrix.project }}
82+
# run: bash <(curl -s https://codecov.io/bash) -F ${{ matrix.php-version }}
83+
84+
packages:
85+
uses: opentelemetry-php/gh-workflows/.github/workflows/validate-packages.yml@main
86+
needs: php
87+
with:
88+
matrix_extension: '["ast, json, grpc"]'
89+
install_directory: '~/.test/.packages'

.github/workflows/split_monorepo.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: gitsplit
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- split
7+
release:
8+
types: [published]
9+
create:
10+
workflow_dispatch:
11+
12+
jobs:
13+
gitsplit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: checkout
17+
run: git clone "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout $GITHUB_SHA
18+
- name: Split repositories
19+
uses: docker://jderusse/gitsplit:latest
20+
with:
21+
args: gitsplit
22+
env:
23+
GH_TOKEN: ${{ secrets.GITSPLIT_TOKEN }}

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "schemas"]
2-
path = schemas
2+
path = src/Flagd/schemas
33
url = https://github.com/tcarrio/schemas/

.gitsplit.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Path to a cache directory Used to speed up the split over time by reusing git's objects
2+
cache_url: "/cache/gitsplit"
3+
4+
# Path to the repository to split (default = current path)
5+
project_url: "https://github.com/open-feature/php-sdk-contrib.git"
6+
7+
# List of splits.
8+
splits:
9+
- prefix: "src/Flagd"
10+
target: "https://${GH_TOKEN}@github.com/open-feature/php-sdk-contrib-flagd-provider.git"
11+
12+
# List of references to split (defined as regexp)
13+
origins:
14+
- ^main$
15+
- ^test$
16+
- ^split$
17+
- ^v\d+\.\d+\.\d+$
18+
- ^\d+\.\d+\.\d+$

captainhook.json

-52
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,6 @@
1313
}
1414
]
1515
},
16-
"pre-push": {
17-
"enabled": true,
18-
"actions": [
19-
{
20-
"action": "composer test"
21-
}
22-
]
23-
},
24-
"pre-commit": {
25-
"enabled": true,
26-
"actions": [
27-
{
28-
"action": "composer validate",
29-
"conditions": [
30-
{
31-
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\Any",
32-
"args": [["composer.json"]]
33-
}
34-
]
35-
},
36-
{
37-
"action": "composer normalize --dry-run",
38-
"conditions": [
39-
{
40-
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\Any",
41-
"args": [["composer.json"]]
42-
}
43-
]
44-
},
45-
{
46-
"action": "composer dev:lint:syntax -- {$STAGED_FILES|of-type:php}",
47-
"conditions": [
48-
{
49-
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
50-
"args": ["php"]
51-
}
52-
]
53-
},
54-
{
55-
"action": "composer dev:lint:style -- {$STAGED_FILES|of-type:php}",
56-
"conditions": [
57-
{
58-
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
59-
"args": ["php"]
60-
}
61-
]
62-
},
63-
{
64-
"action": "composer run dev:grpc"
65-
}
66-
]
67-
},
6816
"prepare-commit-msg": {
6917
"enabled": true,
7018
"actions": [

composer.json

+41-130
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,47 @@
11
{
2-
"name": "0xc/openfeature-flagd-provider",
3-
"description": "OpenFeature provider for flagd",
4-
"license": "Apache-2.0",
5-
"type": "library",
6-
"keywords": [
7-
"featureflags",
8-
"featureflagging",
9-
"openfeature",
10-
"flagd",
11-
"provider"
12-
],
13-
"authors": [
14-
{
15-
"name": "Tom Carrio",
16-
"email": "[email protected]"
17-
}
18-
],
19-
"require": {
20-
"php": "^7.4 || ^8",
21-
"open-feature/sdk": "^0.0.7",
22-
"php-http/httplug": "^2.3.0",
23-
"psr/http-client": "^1.0",
24-
"psr/http-factory": "^1.0",
25-
"psr/http-message": "^1.0",
26-
"psr/log": "^1.1"
2+
"name": "0xc/openfeature-flagd-provider",
3+
"description": "OpenFeature provider for flagd",
4+
"license": "Apache-2.0",
5+
"type": "library",
6+
"keywords": [
7+
"featureflags",
8+
"featureflagging",
9+
"openfeature",
10+
"provider",
11+
"hook"
12+
],
13+
"authors": [
14+
{
15+
"name": "OpenFeature PHP Maintainers",
16+
"homepage": "https://github.com/orgs/open-feature/teams/php-maintainer"
2717
},
28-
"require-dev": {
29-
"captainhook/captainhook": "^5.10",
30-
"captainhook/plugin-composer": "^5.3",
31-
"ergebnis/composer-normalize": "^2.25",
32-
"google/protobuf": "^3.17",
33-
"grpc/grpc": "^1.42",
34-
"hamcrest/hamcrest-php": "^2.0",
35-
"mdwheele/zalgo": "^0.3.1",
36-
"mockery/mockery": "^1.5",
37-
"php-http/mock-client": "^1.0",
38-
"php-parallel-lint/php-console-highlighter": "^1.0",
39-
"php-parallel-lint/php-parallel-lint": "^1.3",
40-
"phpstan/extension-installer": "^1.1",
41-
"phpstan/phpstan": "~1.8.0",
42-
"phpstan/phpstan-mockery": "^1.0",
43-
"phpstan/phpstan-phpunit": "^1.1",
44-
"psalm/plugin-mockery": "^0.9.1",
45-
"psalm/plugin-phpunit": "^0.17.0",
46-
"psr/http-client": "^1.0",
47-
"psr/http-factory": "^1.0",
48-
"psr/http-message": "^1.0",
49-
"ramsey/coding-standard": "^2.0.3",
50-
"ramsey/composer-repl": "^1.4",
51-
"ramsey/conventional-commits": "^1.3",
52-
"roave/security-advisories": "dev-latest",
53-
"spatie/phpunit-snapshot-assertions": "^4.2",
54-
"vimeo/psalm": "~4.25.0"
55-
},
56-
"minimum-stability": "dev",
57-
"prefer-stable": true,
58-
"autoload": {
59-
"psr-4": {
60-
"OpenFeature\\Providers\\Flagd\\": "src/",
61-
"": "proto/php/"
62-
}
63-
},
64-
"autoload-dev": {
65-
"psr-4": {
66-
"OpenFeature\\Providers\\Flagd\\Test\\": "tests/"
67-
}
68-
},
69-
"config": {
70-
"allow-plugins": {
71-
"phpstan/extension-installer": true,
72-
"dealerdirect/phpcodesniffer-composer-installer": true,
73-
"ergebnis/composer-normalize": true,
74-
"captainhook/plugin-composer": true,
75-
"ramsey/composer-repl": true
76-
},
77-
"sort-packages": true
78-
},
79-
"extra": {
80-
"captainhook": {
81-
"force-install": true
82-
},
83-
"ramsey/conventional-commits": {
84-
"configFile": "conventional-commits.json"
85-
}
18+
{
19+
"name": "open-feature/php-sdk-contrib Contributors",
20+
"homepage": "https://github.com/open-feature/php-sdk-contrib/graphs/contributors"
21+
}
22+
],
23+
"minimum-stability": "dev",
24+
"prefer-stable": true,
25+
"config": {
26+
"allow-plugins": {
27+
"phpstan/extension-installer": true,
28+
"dealerdirect/phpcodesniffer-composer-installer": true,
29+
"ergebnis/composer-normalize": true,
30+
"captainhook/plugin-composer": true,
31+
"ramsey/composer-repl": true
8632
},
87-
"scripts": {
88-
"dev:analyze": [
89-
"@dev:analyze:phpstan",
90-
"@dev:analyze:psalm"
91-
],
92-
"dev:analyze:phpstan": "phpstan analyse --ansi --debug --memory-limit=512M",
93-
"dev:analyze:psalm": "psalm",
94-
"dev:build:clean": "git clean -fX build/",
95-
"dev:grpc": [
96-
"@dev:grpc:init",
97-
"@dev:grpc:generate",
98-
"@dev:grpc:stage"
99-
],
100-
"dev:grpc:generate": "export GOPATH=\"$(pwd)/schemas/vendor\" && pushd schemas && make gen-php && popd",
101-
"dev:grpc:init": "git submodule update --recursive",
102-
"dev:grpc:stage": "git add --force ./proto",
103-
"dev:lint": [
104-
"@dev:lint:syntax",
105-
"@dev:lint:style"
106-
],
107-
"dev:lint:fix": "phpcbf",
108-
"dev:lint:style": "phpcs --colors",
109-
"dev:lint:syntax": "parallel-lint --colors src/ tests/",
110-
"dev:test": [
111-
"@dev:lint",
112-
"@dev:analyze",
113-
"@dev:test:unit"
114-
],
115-
"dev:test:coverage:ci": "phpunit --colors=always --coverage-text --coverage-clover build/coverage/clover.xml --coverage-cobertura build/coverage/cobertura.xml --coverage-crap4j build/coverage/crap4j.xml --coverage-xml build/coverage/coverage-xml --log-junit build/junit.xml",
116-
"dev:test:coverage:html": "phpunit --colors=always --coverage-html build/coverage/coverage-html/",
117-
"dev:test:unit": "phpunit --colors=always --testdox",
118-
"dev:test:unit:debug": "phpunit --colors=always --testdox -d xdebug.profiler_enable=on",
119-
"test": "@dev:test"
33+
"sort-packages": true
34+
},
35+
"extra": {
36+
"captainhook": {
37+
"force-install": true
12038
},
121-
"scripts-descriptions": {
122-
"dev:analyze": "Runs all static analysis checks.",
123-
"dev:analyze:phpstan": "Runs the PHPStan static analyzer.",
124-
"dev:analyze:psalm": "Runs the Psalm static analyzer.",
125-
"dev:build:clean": "Cleans the build/ directory.",
126-
"dev:lint": "Runs all linting checks.",
127-
"dev:lint:fix": "Auto-fixes coding standards issues, if possible.",
128-
"dev:lint:style": "Checks for coding standards issues.",
129-
"dev:lint:syntax": "Checks for syntax errors.",
130-
"dev:test": "Runs linting, static analysis, and unit tests.",
131-
"dev:test:coverage:ci": "Runs unit tests and generates CI coverage reports.",
132-
"dev:test:coverage:html": "Runs unit tests and generates HTML coverage report.",
133-
"dev:test:unit": "Runs unit tests.",
134-
"test": "Runs linting, static analysis, and unit tests."
39+
"ramsey/conventional-commits": {
40+
"configFile": "conventional-commits.json"
13541
}
42+
},
43+
"require": {
44+
"captainhook/captainhook": "^5.11",
45+
"ramsey/conventional-commits": "^1.3"
46+
}
13647
}

phpcs.xml.dist

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<arg name="colors"/>
66
<arg value="sp"/>
77

8-
<file>./src</file>
9-
<file>./tests</file>
8+
<file>./src/Flagd/src</file>
9+
<file>./src/Flagd/tests</file>
1010

1111
<exclude-pattern>*/tests/fixtures/*</exclude-pattern>
1212
<exclude-pattern>*/tests/*/fixtures/*</exclude-pattern>

phpstan.neon.dist

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ parameters:
22
tmpDir: ./build/cache/phpstan
33
level: max
44
paths:
5-
- ./src
6-
- ./tests
5+
- ./src/Flagd/src
6+
- ./src/Flagd/tests
77
excludePaths:
88
- */tests/fixtures/*
99
- */tests/*/fixtures/*

0 commit comments

Comments
 (0)