|
| 1 | +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ '**' ] |
| 6 | + pull_request: |
| 7 | + branches: [ '**' ] |
| 8 | + |
| 9 | +name: "CI" |
| 10 | + |
| 11 | +jobs: |
| 12 | + tests: |
| 13 | + name: "Tests" |
| 14 | + |
| 15 | + runs-on: "ubuntu-latest" |
| 16 | + |
| 17 | + env: |
| 18 | + php_extensions: ctype, dom, fileinfo, hash, intl, mbstring, session, simplexml, tokenizer, xml, pdo, mysqli, gd, zip |
| 19 | + |
| 20 | + services: |
| 21 | + mysql: |
| 22 | + image: "mysql:5.7" |
| 23 | + env: |
| 24 | + MYSQL_ALLOW_EMPTY_PASSWORD: true |
| 25 | + MYSQL_ROOT_PASSWORD: |
| 26 | + MYSQL_DATABASE: test_db |
| 27 | + ports: |
| 28 | + - 3306/tcp |
| 29 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 30 | + |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + php-version: |
| 35 | + - "7.3" |
| 36 | + - "7.4" |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: "Checkout" |
| 40 | + uses: "actions/checkout@v2" |
| 41 | + |
| 42 | + - name: "Install PHP with extensions" |
| 43 | + uses: "shivammathur/setup-php@v2" |
| 44 | + with: |
| 45 | + php-version: "${{ matrix.php-version }}" |
| 46 | + extensions: "${{ env.php_extensions }}" |
| 47 | + coverage: "xdebug" |
| 48 | + |
| 49 | + - name: "Start mysql service" |
| 50 | + run: "sudo /etc/init.d/mysql start" |
| 51 | + |
| 52 | + - name: "Cache dependencies installed with composer" |
| 53 | + uses: "actions/cache@v1" |
| 54 | + with: |
| 55 | + path: "~/.composer/cache" |
| 56 | + key: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}" |
| 57 | + restore-keys: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" |
| 58 | + |
| 59 | + - name: "Authorize private packagist" |
| 60 | + env: |
| 61 | + COMPOSER_TOKEN: ${{ secrets.COMPOSER_TOKEN }} |
| 62 | + run: "if [[ $COMPOSER_TOKEN ]]; then composer config --global --auth http-basic.repo.packagist.com token $COMPOSER_TOKEN; fi" |
| 63 | + |
| 64 | + - name: "Install dependencies with composer" |
| 65 | + run: "composer install --no-ansi --no-interaction --no-progress" |
| 66 | + |
| 67 | + - name: "Run tests with phpunit/phpunit" |
| 68 | + env: |
| 69 | + SS_DATABASE_PORT: ${{ job.services.mysql.ports['3306'] }} |
| 70 | + run: "vendor/bin/phpunit --coverage-html=build/logs/coverage/html --coverage-xml=build/logs/coverage" |
| 71 | + |
| 72 | + - name: "Archive code coverage results" |
| 73 | + uses: "actions/upload-artifact@v2" |
| 74 | + with: |
| 75 | + name: "coverage" |
| 76 | + path: "build/logs/coverage/html" |
| 77 | + |
| 78 | + - name: "Run tests with squizlabs/php_codesniffer" |
| 79 | + run: "vendor/bin/phpcs src/ tests/ --standard=phpcs.xml.dist --report=checkstyle --report-file=build/logs/checkstyle.xml" |
| 80 | + |
| 81 | + - name: "Archive checkstyle results" |
| 82 | + uses: "actions/upload-artifact@v2" |
| 83 | + with: |
| 84 | + name: "checkstyle" |
| 85 | + path: "build/logs/checkstyle.xml" |
| 86 | + |
| 87 | + #- name: "Run tests with phpmd/phpmd" |
| 88 | + # run: "vendor/bin/phpmd src xml codesize,unusedcode,naming --reportfile build/logs/pmd.xml --exclude vendor/ --exclude autoload.php" |
| 89 | + |
| 90 | + - name: "Run tests with phploc/phploc" |
| 91 | + run: "vendor/bin/phploc --count-tests --exclude vendor/ --log-csv build/logs/phploc.csv --log-xml build/logs/phploc.xml src/ tests/ |
| 92 | +" |
| 93 | + - name: "Run tests with pdepend/pdepend" |
| 94 | + run: "vendor/bin/pdepend --jdepend-xml=build/logs/jdepend.xml --ignore=vendor src" |
| 95 | + |
| 96 | + - name: "Publish documentation" |
| 97 | + run: "vendor/bin/phpdox -f phpdox.xml" |
| 98 | + |
| 99 | + - name: "Archive documentation" |
| 100 | + uses: "actions/upload-artifact@v2" |
| 101 | + with: |
| 102 | + name: "documentation" |
| 103 | + path: "docs/html" |
0 commit comments