-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add GHA worflow * Add composer.lock * Add Makefile * Fix lint errors * Fix Makefile * Remove Travis CI config
- Loading branch information
Showing
8 changed files
with
4,233 additions
and
38 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,100 @@ | ||
name: Tests | ||
on: [pull_request] | ||
|
||
env: | ||
# see: https://github.com/shivammathur/setup-php | ||
PHP_EXTENSIONS: mbstring, intl, json | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
php-version: ['7.3', '7.4'] | ||
|
||
env: | ||
EXECUTE_COVERAGE: ${{ matrix.php-version == '7.3' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
extensions: ${{ env.PHP_EXTENSIONS }} | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Login composer | ||
run: composer config -g github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: make install | ||
|
||
- name: Run PhpUnit with coverage | ||
if: env.EXECUTE_COVERAGE == 'true' | ||
run: make report-coverage | ||
|
||
- name: Run PhpUnit | ||
if: env.EXECUTE_COVERAGE != 'true' | ||
run: make test | ||
|
||
- name: Coverage monitor | ||
if: env.EXECUTE_COVERAGE == 'true' | ||
uses: slavcodev/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
clover_file: "logs/clover.xml" | ||
comment: false | ||
threshold_alert: 80 | ||
threshold_warning: 90 | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php-version: ['7.3'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
extensions: ${{ env.PHP_EXTENSIONS }} | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Login composer | ||
run: composer config -g github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: make install | ||
|
||
- name: Lint code | ||
run: make lint |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
vendor/ | ||
composer.lock | ||
/phpunit.xml | ||
.php_cs.cache |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
CS_FIXER = php vendor/bin/php-cs-fixer fix --config=.php_cs -v --using-cache=no --diff --diff-format=udiff --ansi | ||
PSALM = vendor/bin/psalm --threads=1 --no-cache --find-dead-code=always --show-info=false --config=.psalm/config.xml | ||
PHPUNIT = php vendor/bin/phpunit | ||
|
||
PHP_FILES_DIFF = $(shell git diff --name-only --diff-filter=ACMRTUXB $(1) | grep -iE \.php$) | ||
CS_FIXER_TEST = if test "$(1)" ; then $(CS_FIXER) --dry-run $(1) ; else echo "Nothing to fix" ; fi | ||
CS_FIXER_FIX = if test "$(1)" ; then $(CS_FIXER) $(1) ; else echo "Nothing to fix" ; fi | ||
|
||
LOGS_DIR = logs | ||
CLOVER_FILE = $(LOGS_DIR)/clover.xml | ||
COVERAGE_REPORT_DIR = $(LOGS_DIR)/report | ||
PSALM_REPORT_FILE = $(LOGS_DIR)/psalm.local.json | ||
|
||
.PHONY: all | ||
all: clean install test lint | ||
|
||
.PHONY: lint | ||
lint: psalm cs-test | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -dfR $(LOGS_DIR)/* | ||
|
||
.PHONY: install | ||
install: | ||
composer install -n --no-suggest | ||
|
||
.PHONY: cs-test | ||
cs-test: | ||
$(call CS_FIXER_TEST,$(call PHP_FILES_DIFF,"origin/master")) | ||
|
||
.PHONY: cs-fix | ||
cs-fix: | ||
$(call CS_FIXER_FIX,$(call PHP_FILES_DIFF,"origin/master")) | ||
|
||
.PHONY: cs-test-all | ||
cs-test-all: | ||
$(CS_FIXER) --dry-run | ||
|
||
.PHONY: cs-fix-all | ||
cs-fix-all: | ||
$(CS_FIXER) | ||
|
||
.PHONY: psalm | ||
psalm: | ||
$(PSALM) | ||
|
||
.PHONY: psalm-report | ||
psalm-report: | ||
$(PSALM) --report-show-info=false --report=$(PSALM_REPORT_FILE) | ||
|
||
.PHONY: test | ||
test: | ||
$(PHPUNIT) | ||
|
||
.PHONY: show-coverage | ||
show-coverage: | ||
$(PHPUNIT) --coverage-text=php://stdout | ||
|
||
.PHONY: report-coverage | ||
report-coverage: | ||
$(PHPUNIT) --coverage-clover $(CLOVER_FILE) | ||
|
||
.PHONY: report-html-coverage | ||
report-html-coverage: | ||
$(PHPUNIT) --coverage-html $(COVERAGE_REPORT_DIR) |
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
Oops, something went wrong.