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
167 changes: 146 additions & 21 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,174 @@ name: Checks
on:
push:
branches:
- '**'
- main
tags:
- 'v*.*.*'
pull_request:
types:
- opened
- synchronize # when a PR is updated
- reopened # when a PR is reopened
- ready_for_review # when a PR is ready for review
- review_requested # when a PR is requested for review

permissions:
contents: read

concurrency:
group: checks-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
name: Checks
base-sdk:
name: Base SDK (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
php:
- '8.0'
- '8.5'
steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v7

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
# extensions: mbstring, intl, dom
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2, phpunit:9.6.35

- name: Install base SDK dependencies
run: composer install --no-dev --no-interaction --prefer-dist --no-progress

- name: Test base SDK without OpenFeature
run: phpunit --bootstrap vendor/autoload.php --exclude-group openfeature tests

openfeature:
name: OpenFeature (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
php:
- '8.0'
- '8.5'
steps:
- name: Check out repository
uses: actions/checkout@v7

- uses: actions/setup-node@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
node-version-file: '.nvmrc'
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer install
run: composer install --no-interaction --prefer-dist --no-progress

- name: Test OpenFeature provider
run: vendor/bin/phpunit --group openfeature tests

- name: SAST
quality:
name: Quality
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v7

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
coverage: none
tools: composer:v2

- name: Validate Composer configuration
run: composer validate --strict

- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress

- name: Audit dependencies
run: composer audit --locked --no-interaction

- name: Static analysis
run: composer sast

- name: Test
- name: Run complete unit suite
run: composer test

- name: Setup Featurevisor example-1 project
package-boundaries:
name: Package boundaries
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v7

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
coverage: none
tools: composer:v2

- name: Verify base SDK without OpenFeature
shell: bash
run: |
mkdir "${{ runner.temp }}/featurevisor-base-consumer"
cd "${{ runner.temp }}/featurevisor-base-consumer"
composer init --name=featurevisor/base-consumer --no-interaction
composer config minimum-stability dev
composer config prefer-stable true
composer config repositories.featurevisor "{\"type\":\"path\",\"url\":\"$GITHUB_WORKSPACE\",\"options\":{\"symlink\":false}}"
composer require featurevisor/featurevisor-php:@dev --no-interaction --prefer-dist --no-progress
php -r 'require "vendor/autoload.php"; $f = Featurevisor\Featurevisor::createFeaturevisor(["logLevel" => "fatal"]); if ($f->getSchemaVersion() !== "2" || class_exists("Featurevisor\\Logger") || class_exists("Featurevisor\\Internal\\Logger") || class_exists(OpenFeature\OpenFeatureAPI::class)) { exit(1); }'
if composer show psr/log --no-interaction >/dev/null 2>&1; then exit 1; fi

- name: Verify SDK with OpenFeature
shell: bash
run: |
mkdir "${{ runner.temp }}/featurevisor-openfeature-consumer"
cd "${{ runner.temp }}/featurevisor-openfeature-consumer"
composer init --name=featurevisor/openfeature-consumer --no-interaction
composer config minimum-stability dev
composer config prefer-stable true
composer config repositories.featurevisor "{\"type\":\"path\",\"url\":\"$GITHUB_WORKSPACE\",\"options\":{\"symlink\":false}}"
composer require featurevisor/featurevisor-php:@dev open-feature/sdk:^2.2 --no-interaction --prefer-dist --no-progress
php -r 'require "vendor/autoload.php"; $p = new Featurevisor\OpenFeatureProvider(["logLevel" => "fatal"]); if ($p->getMetadata()->getName() !== "Featurevisor") { exit(1); } $p->shutdown();'

example-project:
name: Featurevisor example-1
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v7

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress

- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
package-manager-cache: false

- name: Set up Featurevisor example-1 project
run: |
mkdir example-1
(cd example-1 && npx @featurevisor/cli@2.x init --example=1)
(cd example-1 && npx --yes @featurevisor/cli@3 init --example=1)
(cd example-1 && npm install)
(cd example-1 && npx featurevisor test)
(cd example-1 && npx featurevisor build)
(cd example-1 && npx featurevisor test --onlyFailures)

- name: Run Featurevisor project tests against PHP SDK
run: (cd ./example-1 && ../featurevisor test)
run: ./featurevisor test --projectDirectoryPath=./example-1 --onlyFailures --quiet
39 changes: 34 additions & 5 deletions .github/workflows/packagist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,51 @@ on:
tags:
- 'v*'

permissions:
contents: read

concurrency:
group: packagist-${{ github.ref }}
cancel-in-progress: false

jobs:
ci:
name: Notify Packagist
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v7

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
tools: composer:v2

- name: Validate release tag
shell: bash
run: |
if [[ ! "$GITHUB_REF_NAME" =~ ^v2\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Expected a Featurevisor PHP v2 semantic version tag such as v2.0.0"
exit 1
fi

- name: Install and verify package
run: |
composer install --no-interaction --prefer-dist --no-progress
make check

- name: Notify
- name: Notify Packagist
shell: bash
env:
PACKAGIST_USERNAME: ${{ secrets.PACKAGIST_USERNAME }}
PACKAGIST_API_TOKEN: ${{ secrets.PACKAGIST_API_TOKEN }}
run: |
echo "Notifying Packagist of new release: ${{ github.event.release.tag_name }}"
echo "Notifying Packagist of new release: ${{ github.ref_name }}"

curl -X POST -H 'content-type:application/json' \
curl --fail-with-body --silent --show-error --request POST \
--header 'content-type: application/json' \
"https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_API_TOKEN" \
-d '{"repository":{"url":"https://packagist.org/packages/featurevisor/featurevisor-php"}}'
--data '{"repository":{"url":"https://packagist.org/packages/featurevisor/featurevisor-php"}}'
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
24
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2025 Fahad Heylaal (https://fahad19.com)
Copyright (c) 2026 Fahad Heylaal (https://fahad19.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
.PHONY: install test setup-monorepo update-monorepo test-example-1 test-example-project
.PHONY: install sast test test-base test-openfeature check setup-monorepo update-monorepo test-example-1 test-example-project

install:
composer install

test:
composer test

sast:
composer sast

test-base:
vendor/bin/phpunit --exclude-group openfeature tests

test-openfeature:
vendor/bin/phpunit --group openfeature tests

check:
composer validate --strict
composer audit --locked --no-interaction
composer sast
composer test

setup-monorepo:
mkdir -p monorepo
if [ ! -d "monorepo/.git" ]; then \
Expand All @@ -20,6 +35,6 @@ update-monorepo:

test-example-1:
composer test
./featurevisor test --projectDirectoryPath="../featurevisor/examples/example-1" --onlyFailures
./featurevisor test --projectDirectoryPath="../featurevisor/examples/example-1" --onlyFailures --quiet

test-example-project: test-example-1
Loading