Merge pull request #55 from LucentYang/main #129
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
name: PHP Unittest | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment to run tests against' | |
default: develop | |
type: choice | |
options: | |
- develop | |
- prod | |
push: | |
branches: [ main ] | |
pull_request_target: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Github Action for wget | |
uses: wei/wget@v1.1.1 | |
with: | |
args: -O sample.html https://httpbin.org/html | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
php-version: 7.4 | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
- name: Install dependencies | |
run: composer update --ignore-platform-reqs | |
- name: Install phpunit.phar | |
run: wget https://phar.phpunit.de/phpunit-9.6.phar | |
- name: Run test suite for ClientTest | |
env: | |
ENV: "${{ github.event.inputs.environment == 'prod' && 'prod' || 'develop'}}" | |
SECRET: "${{ github.event.inputs.environment == 'prod' && secrets.PRODSECRET || secrets.DEVELOPSECRET}}" | |
MPCSECRET: "${{secrets.DEVELOPMPCSECRET}}" | |
run: | |
php -denv=$ENV -dsecret=$SECRET phpunit-9.6.phar ClientTest.php | |
- name: Run test suite for MPCClientTest | |
env: | |
ENV: "${{ github.event.inputs.environment == 'prod' && 'prod' || 'develop'}}" | |
SECRET: "${{ github.event.inputs.environment == 'prod' && secrets.PRODSECRET || secrets.DEVELOPSECRET}}" | |
MPCSECRET: "${{secrets.DEVELOPMPCSECRET}}" | |
run: | |
php -denv=$ENV -dMPCApiSecret=$MPCSECRET phpunit-9.6.phar MPCClientTest.php |