From 853400b04b319b46be3486832c11cf16c3570e65 Mon Sep 17 00:00:00 2001 From: Dalibor Korpar Date: Mon, 7 Dec 2020 22:13:43 +0100 Subject: [PATCH] add github actions build --- .github/workflows/main.yml | 153 +++++++++++++++++++++++++++++++++++++ tests/php.ini-unix | 4 + 2 files changed, 157 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..bca8c9f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,153 @@ +name: "build" + +on: + pull_request: + paths-ignore: + - ".docs/**" + push: + branches: + - "master" + schedule: + - cron: "0 8 * * 1" # At 08:00 on Monday + +env: + extensions: "json" + cache-version: "1" + composer-version: "v2" + composer-install: "composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable" + +jobs: + tests: + name: "Tests" + runs-on: "${{ matrix.operating-system }}" + strategy: + matrix: + php-version: ["7.2", "7.3", "7.4"] + operating-system: ["ubuntu-latest"] + composer-args: [ "" ] + include: + - php-version: "7.4" + operating-system: "ubuntu-latest" + composer-args: "--prefer-lowest" + - php-version: "8.0" + operating-system: "ubuntu-latest" + composer-args: "--ignore-platform-reqs" + fail-fast: false + + continue-on-error: "${{ matrix.php-version == '8.0' }}" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Setup PHP cache environment" + id: "extcache" + uses: "shivammathur/cache-extensions@v1" + with: + php-version: "${{ matrix.php-version }}" + extensions: "${{ env.extensions }}" + key: "${{ env.cache-version }}" + + - name: "Cache PHP extensions" + uses: "actions/cache@v2" + with: + path: "${{ steps.extcache.outputs.dir }}" + key: "${{ steps.extcache.outputs.key }}" + restore-keys: "${{ steps.extcache.outputs.key }}" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + extensions: "${{ env.extensions }}" + tools: "composer:${{ env.composer-version }} " + + - name: "Setup problem matchers for PHP" + run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' + + - name: "Get Composer cache directory" + id: "composercache" + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' + + - name: "Cache PHP dependencies" + uses: "actions/cache@v2" + with: + path: "${{ steps.composercache.outputs.dir }}" + key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" + restore-keys: "${{ runner.os }}-composer-" + + - name: "Install dependencies" + run: "${{ env.composer-install }} ${{ matrix.composer-args }}" + + - name: "Setup problem matchers for PHPUnit" + run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"' + + - name: "Tests" + run: "vendor/bin/tester -p phpdbg -c ./tests/php.ini-unix ./tests/KdybyTests/" + + tests-code-coverage: + name: "Tests with code coverage" + runs-on: "${{ matrix.operating-system }}" + + strategy: + matrix: + php-version: ["7.4"] + operating-system: ["ubuntu-latest"] + fail-fast: false + + if: "github.event_name == 'push'" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Setup PHP cache environment" + id: "extcache" + uses: "shivammathur/cache-extensions@v1" + with: + php-version: "${{ matrix.php-version }}" + extensions: "${{ env.extensions }}" + key: "${{ env.cache-version }}" + + - name: "Cache PHP extensions" + uses: "actions/cache@v2" + with: + path: "${{ steps.extcache.outputs.dir }}" + key: "${{ steps.extcache.outputs.key }}" + restore-keys: "${{ steps.extcache.outputs.key }}" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + extensions: "${{ env.extensions }}" + tools: "composer:${{ env.composer-version }} " + + - name: "Setup problem matchers for PHP" + run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' + + - name: "Get Composer cache directory" + id: "composercache" + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' + + - name: "Cache PHP dependencies" + uses: "actions/cache@v2" + with: + path: "${{ steps.composercache.outputs.dir }}" + key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" + restore-keys: "${{ runner.os }}-composer-" + + - name: "Install dependencies" + run: "${{ env.composer-install }}" + + - name: "Tests" + run: "vendor/bin/tester --coverage ./coverage.xml --coverage-src ./src -s -p phpdbg -c ./tests/php.ini-unix ./tests/KdybyTests/" + + - name: "Coveralls.io" + env: + CI_NAME: github + CI: true + COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + run: | + wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar + php php-coveralls.phar --verbose --config tests/.coveralls.yml \ No newline at end of file diff --git a/tests/php.ini-unix b/tests/php.ini-unix index e69de29..223be91 100644 --- a/tests/php.ini-unix +++ b/tests/php.ini-unix @@ -0,0 +1,4 @@ +[PHP] + +extension=tokenizer.so +extension=json.so \ No newline at end of file