test-ci.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. name: PHP CI with Composer
  2. on: [push, pull_request]
  3. jobs:
  4. build:
  5. strategy:
  6. fail-fast: false
  7. matrix:
  8. php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Checkout
  12. uses: actions/checkout@v2
  13. - name: Setup php for mock server
  14. uses: shivammathur/setup-php@v2
  15. with:
  16. php-version: '8.2'
  17. - name: Install Go
  18. uses: actions/setup-go@v2
  19. with:
  20. go-version: '1.21.x'
  21. - name: Setup build-in server
  22. run: |
  23. nohup php -S localhost:9000 -t ./tests/mock-server/ > phpd.log 2>&1 &
  24. echo $! > mock-server.pid
  25. cd tests/socks5-server/
  26. nohup go run main.go > ../../socks5.log 2>&1 &
  27. echo $! > ../../socks-server.pid
  28. - name: Setup php
  29. uses: shivammathur/setup-php@v2
  30. with:
  31. php-version: ${{ matrix.php-versions }}
  32. - name: Install dependencies
  33. run: |
  34. composer self-update
  35. composer install --no-interaction --prefer-source --dev
  36. - name: Run cases
  37. run: |
  38. ./vendor/bin/phpcs --standard=PSR2 src
  39. ./vendor/bin/phpcs --standard=PSR2 examples
  40. ./vendor/bin/phpcs --standard=PSR2 tests
  41. ./vendor/bin/phpunit --coverage-clover=coverage.xml
  42. cat mock-server.pid | xargs kill
  43. cat socks-server.pid | xargs kill
  44. env:
  45. QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }}
  46. QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}
  47. QINIU_TEST_BUCKET: ${{ secrets.QINIU_TEST_BUCKET }}
  48. QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }}
  49. - name: Print mock servion log
  50. if: ${{ failure() }}
  51. run: |
  52. cat phpd.log
  53. - name: Print socks5 server log
  54. if: ${{ failure() }}
  55. run: |
  56. cat socks5.log
  57. - name: After_success
  58. run: bash <(curl -s https://codecov.io/bash)