-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tim Yiu
authored and
Tim Yiu
committed
Oct 24, 2023
0 parents
commit f0d294c
Showing
21 changed files
with
3,628 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
dryRun: | ||
description: 'Do a dry run to preview instead of a real release' | ||
required: true | ||
default: 'true' | ||
|
||
jobs: | ||
authorize: | ||
name: Authorize | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ${{ github.actor }} permission check to do a release | ||
uses: octokit/[email protected] | ||
with: | ||
route: GET /repos/:repository/collaborators/${{ github.actor }} | ||
repository: ${{ github.repository }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
needs: [ authorize ] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Semantic Release --dry-run | ||
if: ${{ github.event.inputs.dryRun == 'true'}} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GIT_AUTHOR_NAME: amplitude-sdk-bot | ||
GIT_AUTHOR_EMAIL: [email protected] | ||
GIT_COMMITTER_NAME: amplitude-sdk-bot | ||
GIT_COMMITTER_EMAIL: [email protected] | ||
run: | | ||
npx \ | ||
-p lodash \ | ||
-p semantic-release \ | ||
-p @semantic-release/changelog \ | ||
-p @semantic-release/git \ | ||
-p @google/semantic-release-replace-plugin \ | ||
semantic-release --dry-run | ||
- name: Semantic Release | ||
if: ${{ github.event.inputs.dryRun == 'false'}} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GIT_AUTHOR_NAME: amplitude-sdk-bot | ||
GIT_AUTHOR_EMAIL: [email protected] | ||
GIT_COMMITTER_NAME: amplitude-sdk-bot | ||
GIT_COMMITTER_EMAIL: [email protected] | ||
run: | | ||
npx \ | ||
-p lodash \ | ||
-p semantic-release \ | ||
-p @semantic-release/changelog \ | ||
-p @semantic-release/git \ | ||
-p @google/semantic-release-replace-plugin \ | ||
semantic-release | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Semantic PR Check | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, edited] | ||
|
||
jobs: | ||
pr-title-check: | ||
name: Check PR for semantic title | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: PR title is valid | ||
if: > | ||
startsWith(github.event.pull_request.title, 'feat:') || startsWith(github.event.pull_request.title, 'feat(') || | ||
startsWith(github.event.pull_request.title, 'fix:') || startsWith(github.event.pull_request.title, 'fix(') || | ||
startsWith(github.event.pull_request.title, 'perf:') || startsWith(github.event.pull_request.title, 'perf(') || | ||
startsWith(github.event.pull_request.title, 'docs:') || startsWith(github.event.pull_request.title, 'docs(') || | ||
startsWith(github.event.pull_request.title, 'test:') || startsWith(github.event.pull_request.title, 'test(') || | ||
startsWith(github.event.pull_request.title, 'refactor:') || startsWith(github.event.pull_request.title, 'refactor(') || | ||
startsWith(github.event.pull_request.title, 'style:') || startsWith(github.event.pull_request.title, 'style(') || | ||
startsWith(github.event.pull_request.title, 'build:') || startsWith(github.event.pull_request.title, 'build(') || | ||
startsWith(github.event.pull_request.title, 'ci:') || startsWith(github.event.pull_request.title, 'ci(') || | ||
startsWith(github.event.pull_request.title, 'chore:') || startsWith(github.event.pull_request.title, 'chore(') || | ||
startsWith(github.event.pull_request.title, 'revert:') || startsWith(github.event.pull_request.title, 'revert(') | ||
run: | | ||
echo 'Title checks passed' | ||
- name: PR title is invalid | ||
if: > | ||
!startsWith(github.event.pull_request.title, 'feat:') && !startsWith(github.event.pull_request.title, 'feat(') && | ||
!startsWith(github.event.pull_request.title, 'fix:') && !startsWith(github.event.pull_request.title, 'fix(') && | ||
!startsWith(github.event.pull_request.title, 'perf:') && !startsWith(github.event.pull_request.title, 'perf(') && | ||
!startsWith(github.event.pull_request.title, 'docs:') && !startsWith(github.event.pull_request.title, 'docs(') && | ||
!startsWith(github.event.pull_request.title, 'test:') && !startsWith(github.event.pull_request.title, 'test(') && | ||
!startsWith(github.event.pull_request.title, 'refactor:') && !startsWith(github.event.pull_request.title, 'refactor(') && | ||
!startsWith(github.event.pull_request.title, 'style:') && !startsWith(github.event.pull_request.title, 'style(') && | ||
!startsWith(github.event.pull_request.title, 'build:') && !startsWith(github.event.pull_request.title, 'build(') && | ||
!startsWith(github.event.pull_request.title, 'ci:') && !startsWith(github.event.pull_request.title, 'ci(') && | ||
!startsWith(github.event.pull_request.title, 'chore:') && !startsWith(github.event.pull_request.title, 'chore(') && | ||
!startsWith(github.event.pull_request.title, 'revert:') && !startsWith(github.event.pull_request.title, 'revert(') | ||
run: | | ||
echo 'Pull request title is not valid. Please check https://github.com/amplitude/experiment-go-server/blob/main/CONTRIBUTING.md#pr-commit-title-conventions' | ||
exit 1 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 7.4 | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate --strict | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Run test suite | ||
run: composer run-script test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/vendor | ||
experiment-php-server.iml | ||
composer.phar | ||
.phpunit.result.cache | ||
.DS_Store | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 1.0.0 (2023-10-21) | ||
|
||
|
||
### Features | ||
|
||
* Remote Evaluation ([467aa5d](https://github.com/amplitude/experiment-php-server/commit/467aa5d8cef2c43082ec196beec75345c504bb40)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Amplitude Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<p align="center"> | ||
<a href="https://amplitude.com" target="_blank" align="center"> | ||
<img src="https://static.amplitude.com/lightning/46c85bfd91905de8047f1ee65c7c93d6fa9ee6ea/static/media/amplitude-logo-with-text.4fb9e463.svg" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
# Experiment PHP SDK | ||
Amplitude PHP Server SDK for Experiment. | ||
|
||
## Installation | ||
```php | ||
composer require amplitude/experiment-php-server | ||
``` | ||
|
||
## Remote Evaluation Quick Start | ||
```php | ||
<?php | ||
// (1) Initialize the experiment client | ||
$experiment = new \AmplitudeExperiment\Experiment(); | ||
$client = $experiment->initializeRemote('<DEPLOYMENT_KEY>') | ||
|
||
// (2) Fetch variants for a user | ||
$user = \AmplitudeExperiment\User::builder() | ||
->deviceId('abcdefg') | ||
->userId('[email protected]') | ||
->userProperties('premium' => True) | ||
->build(); | ||
$variants = experiment.fetch(user); | ||
|
||
// (3) Access a flag's variant | ||
if ($variant) { | ||
if ($variant->value == 'on') { | ||
// Flag is on | ||
} else { | ||
// Flag is off | ||
} | ||
} | ||
``` | ||
|
||
## More Information | ||
Please visit our :100:[Developer Center](https://www.docs.developers.amplitude.com/experiment/sdks/php-sdk/) for more instructions on using our the SDK. | ||
|
||
## Need Help? | ||
If you have any problems or issues over our SDK, feel free to [create a GitHub issue](https://github.com/amplitude/experiment-php-server/issues/new) or submit a request on [Amplitude Help](https://help.amplitude.com/hc/en-us/requests/new). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "amplitude/experiment-php-server", | ||
"description": "Amplitude Experiment Server SDK for PHP", | ||
"type": "library", | ||
"keywords": [ | ||
"amplitude", | ||
"ab test", | ||
"feature-flags", | ||
"php" | ||
], | ||
"homepage": "https://github.com/amplitude/experiment-php-server", | ||
"authors": [ | ||
{ | ||
"name": "Amplitude", | ||
"homepage": "https://amplitude.com/amplitude-experiment" | ||
} | ||
], | ||
"license": "MIT", | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require": { | ||
"php": "^7.4 || ^8", | ||
"ext-json": "*", | ||
"guzzlehttp/guzzle": "^7", | ||
"monolog/monolog": "^2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "9.*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"AmplitudeExperiment\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"AmplitudeExperiment\\Test\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "./vendor/bin/phpunit --no-coverage" | ||
} | ||
} |
Oops, something went wrong.