-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from marc-mabe/ghaction
Migrate from travis to GH workflow
- Loading branch information
Showing
6 changed files
with
137 additions
and
90 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,18 @@ | ||
ARG PHP_VERSION=latest | ||
FROM php:${PHP_VERSION}-cli-alpine | ||
|
||
WORKDIR /workdir | ||
|
||
# install composer | ||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
ENV COMPOSER_HTACCESS_PROTECT=0 | ||
ENV COMPOSER_CACHE_DIR=/.composer | ||
|
||
# install PHP extension pcov | ||
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ | ||
&& mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \ | ||
&& docker-php-ext-install pcov \ | ||
&& docker-php-ext-enable pcov \ | ||
&& rm -Rf /usr/src/php/ext/pcov \ | ||
&& apk del --no-cache .build-deps |
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,105 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- '[0-9]+.x' | ||
|
||
jobs: | ||
php: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- PHP_VERSION: 7.1 | ||
CODE_COVERAGE: false | ||
RUN_PHPSTAN: false | ||
RUN_PSALM: false | ||
RUN_BENCHMARK: false | ||
- PHP_VERSION: 7.2 | ||
CODE_COVERAGE: true | ||
RUN_PHPSTAN: false | ||
RUN_PSALM: false | ||
RUN_BENCHMARK: false | ||
- PHP_VERSION: 7.3 | ||
CODE_COVERAGE: true | ||
RUN_PHPSTAN: false | ||
RUN_PSALM: false | ||
RUN_BENCHMARK: false | ||
- PHP_VERSION: 7.4 | ||
CODE_COVERAGE: true | ||
RUN_PHPSTAN: true | ||
RUN_PSALM: true | ||
RUN_BENCHMARK: true | ||
- PHP_VERSION: 8.0-rc | ||
CODE_COVERAGE: true | ||
RUN_PHPSTAN: true | ||
RUN_PSALM: true | ||
RUN_BENCHMARK: true | ||
COMPOSER_EXTRA_ARGS: --ignore-platform-reqs | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Cache Docker Image | ||
id: cache-docker-image | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/docker-image.tar | ||
key: cache-docker-image-test:${{ matrix.PHP_VERSION }} | ||
|
||
- name: Load Docker Image | ||
if: steps.cache-docker-image.outputs.cache-hit == 'true' | ||
run: docker load --input /tmp/docker-image.tar | ||
|
||
- name: Build Docker Image | ||
if: steps.cache-docker-image.outputs.cache-hit != 'true' | ||
run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' . | ||
|
||
- name: Cache Composer Cache Files | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/composer-cache-files | ||
key: cache-composer-cache-files-${{ matrix.PHP_VERSION }} | ||
restore-keys: | | ||
cache-composer-cache-files- | ||
- name: Install Composer Dependencies | ||
run: | | ||
if [ "${{ matrix.RUN_PHPSTAN }}" != "true" ]; then composer remove --dev phpstan/phpstan --no-update --no-interaction; fi | ||
if [ "${{ matrix.RUN_PSALM }}" != "true" ]; then composer remove --dev vimeo/psalm --no-update --no-interaction; fi | ||
if [ "${{ matrix.RUN_BENCHMARK }}" != "true" ]; then composer remove --dev phpbench/phpbench --no-update --no-interaction; fi | ||
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-files:/.composer' 'test:${{ matrix.PHP_VERSION }}' composer install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }} | ||
- name: Run Unit Test | ||
run: | | ||
if [ "${{ matrix.CODE_COVERAGE }}" == "true" ]; then | ||
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml | ||
else | ||
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit | ||
fi | ||
- name: Upload Codecov Report | ||
uses: codecov/codecov-action@v1 | ||
if: ${{ matrix.CODE_COVERAGE }} | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
file: .clover.xml | ||
|
||
- name: Run PHPStan | ||
if: ${{ matrix.RUN_PHPSTAN }} | ||
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/ | ||
|
||
- name: Run psalm | ||
if: ${{ matrix.RUN_PSALM }} | ||
run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}' php ./vendor/bin/psalm | ||
|
||
- name: Run benchmark | ||
if: ${{ matrix.RUN_BENCHMARK }} | ||
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=travis | ||
|
||
- name: Export Docker Image | ||
if: steps.cache-docker-image.outputs.cache-hit != 'true' | ||
run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}' |
This file was deleted.
Oops, something went wrong.
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
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
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