Skip to content

Commit 73aedf6

Browse files
authored
Add GHA workflow (#11)
* Add GHA worflow * Add composer.lock * Add Makefile * Fix lint errors * Fix Makefile * Remove Travis CI config
1 parent 4f43dc1 commit 73aedf6

File tree

8 files changed

+4233
-38
lines changed

8 files changed

+4233
-38
lines changed

.github/workflows/workflow.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Tests
2+
on: [pull_request]
3+
4+
env:
5+
# see: https://github.com/shivammathur/setup-php
6+
PHP_EXTENSIONS: mbstring, intl, json
7+
8+
jobs:
9+
unit-tests:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
max-parallel: 1
14+
matrix:
15+
php-version: ['7.3', '7.4']
16+
17+
env:
18+
EXECUTE_COVERAGE: ${{ matrix.php-version == '7.3' }}
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php-version }}
27+
extensions: ${{ env.PHP_EXTENSIONS }}
28+
29+
- name: Get Composer Cache Directory
30+
id: composer-cache
31+
run: |
32+
echo "::set-output name=dir::$(composer config cache-files-dir)"
33+
34+
- uses: actions/cache@v1
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-composer-
40+
41+
- name: Login composer
42+
run: composer config -g github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }}
43+
44+
- name: Install dependencies
45+
run: make install
46+
47+
- name: Run PhpUnit with coverage
48+
if: env.EXECUTE_COVERAGE == 'true'
49+
run: make report-coverage
50+
51+
- name: Run PhpUnit
52+
if: env.EXECUTE_COVERAGE != 'true'
53+
run: make test
54+
55+
- name: Coverage monitor
56+
if: env.EXECUTE_COVERAGE == 'true'
57+
uses: slavcodev/coverage-monitor-action@1.0.1
58+
with:
59+
github_token: ${{ secrets.GITHUB_TOKEN }}
60+
clover_file: "logs/clover.xml"
61+
comment: false
62+
threshold_alert: 80
63+
threshold_warning: 90
64+
65+
lint:
66+
runs-on: ubuntu-latest
67+
68+
strategy:
69+
matrix:
70+
php-version: ['7.3']
71+
72+
steps:
73+
- uses: actions/checkout@v2
74+
75+
- name: Setup PHP
76+
uses: shivammathur/setup-php@v2
77+
with:
78+
php-version: ${{ matrix.php-version }}
79+
extensions: ${{ env.PHP_EXTENSIONS }}
80+
81+
- name: Get Composer Cache Directory
82+
id: composer-cache
83+
run: |
84+
echo "::set-output name=dir::$(composer config cache-files-dir)"
85+
86+
- uses: actions/cache@v1
87+
with:
88+
path: ${{ steps.composer-cache.outputs.dir }}
89+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
90+
restore-keys: |
91+
${{ runner.os }}-composer-
92+
93+
- name: Login composer
94+
run: composer config -g github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }}
95+
96+
- name: Install dependencies
97+
run: make install
98+
99+
- name: Lint code
100+
run: make lint

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
vendor/
2-
composer.lock
32
/phpunit.xml
43
.php_cs.cache

.travis.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
CS_FIXER = php vendor/bin/php-cs-fixer fix --config=.php_cs -v --using-cache=no --diff --diff-format=udiff --ansi
2+
PSALM = vendor/bin/psalm --threads=1 --no-cache --find-dead-code=always --show-info=false --config=.psalm/config.xml
3+
PHPUNIT = php vendor/bin/phpunit
4+
5+
PHP_FILES_DIFF = $(shell git diff --name-only --diff-filter=ACMRTUXB $(1) | grep -iE \.php$)
6+
CS_FIXER_TEST = if test "$(1)" ; then $(CS_FIXER) --dry-run $(1) ; else echo "Nothing to fix" ; fi
7+
CS_FIXER_FIX = if test "$(1)" ; then $(CS_FIXER) $(1) ; else echo "Nothing to fix" ; fi
8+
9+
LOGS_DIR = logs
10+
CLOVER_FILE = $(LOGS_DIR)/clover.xml
11+
COVERAGE_REPORT_DIR = $(LOGS_DIR)/report
12+
PSALM_REPORT_FILE = $(LOGS_DIR)/psalm.local.json
13+
14+
.PHONY: all
15+
all: clean install test lint
16+
17+
.PHONY: lint
18+
lint: psalm cs-test
19+
20+
.PHONY: clean
21+
clean:
22+
rm -dfR $(LOGS_DIR)/*
23+
24+
.PHONY: install
25+
install:
26+
composer install -n --no-suggest
27+
28+
.PHONY: cs-test
29+
cs-test:
30+
$(call CS_FIXER_TEST,$(call PHP_FILES_DIFF,"origin/master"))
31+
32+
.PHONY: cs-fix
33+
cs-fix:
34+
$(call CS_FIXER_FIX,$(call PHP_FILES_DIFF,"origin/master"))
35+
36+
.PHONY: cs-test-all
37+
cs-test-all:
38+
$(CS_FIXER) --dry-run
39+
40+
.PHONY: cs-fix-all
41+
cs-fix-all:
42+
$(CS_FIXER)
43+
44+
.PHONY: psalm
45+
psalm:
46+
$(PSALM)
47+
48+
.PHONY: psalm-report
49+
psalm-report:
50+
$(PSALM) --report-show-info=false --report=$(PSALM_REPORT_FILE)
51+
52+
.PHONY: test
53+
test:
54+
$(PHPUNIT)
55+
56+
.PHONY: show-coverage
57+
show-coverage:
58+
$(PHPUNIT) --coverage-text=php://stdout
59+
60+
.PHONY: report-coverage
61+
report-coverage:
62+
$(PHPUNIT) --coverage-clover $(CLOVER_FILE)
63+
64+
.PHONY: report-html-coverage
65+
report-html-coverage:
66+
$(PHPUNIT) --coverage-html $(COVERAGE_REPORT_DIR)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[![Latest Version on Packagist][ico-version]][link-packagist]
33
[![Build Status][ico-travis]][link-travis]
44
[![Coverage Status][ico-coveralls]][link-coveralls]
5+
[![GitHub Actions status][ico-github-actions]][link-github]
56

67
# Money
78

@@ -244,11 +245,13 @@ If you discover a security vulnerability, please report it to security at rebill
244245
The Money library is open-sourced under the [MIT License](./LICENSE) distributed with the software.
245246

246247

248+
[ico-github-actions]: https://github.com/Rebilly/money/workflows/Tests/badge.svg
247249
[ico-version]: https://img.shields.io/packagist/v/Rebilly/money.svg?style=flat-square
248250
[ico-license]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square
249251
[ico-travis]: https://img.shields.io/travis/Rebilly/money/master.svg?style=flat-square
250252
[ico-coveralls]: https://img.shields.io/coveralls/github/Rebilly/money.svg?style=flat-square
251253

254+
[link-github]: https://github.com/Rebilly/money
252255
[link-packagist]: https://packagist.org/packages/Rebilly/money
253256
[link-license]: LICENSE
254257
[link-travis]: https://travis-ci.org/Rebilly/money

0 commit comments

Comments
 (0)