Skip to content

Commit 7e0ff47

Browse files
committed
Add initial GitHub Actions setup
1 parent 165e70a commit 7e0ff47

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# https://php.watch/articles/composer-gitattributes
2+
3+
# Exclude build/test files from archive
4+
/.github export-ignore
5+
/build export-ignore
6+
/tests export-ignore
7+
/.gitattributes export-ignore
8+
/.gitignore export-ignore
9+
/phpunit.xml export-ignore
10+
/phpunit.xml.dist export-ignore
11+
12+
# Configure diff output for .php and .phar files.
13+
*.php diff=php
14+
*.phar -diff

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: PHPUnit tests
2+
on: [push, pull_request]
3+
jobs:
4+
phpunit:
5+
name: PHPUnit tests
6+
runs-on: ubuntu-latest
7+
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
php-versions: ['8.2']
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
# Docs: https://github.com/shivammathur/setup-php
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php-versions }}
21+
extensions: curl
22+
coverage: xdebug
23+
24+
- name: Get composer cache directory
25+
id: composer-cache
26+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
27+
28+
- name: Cache composer dependencies
29+
uses: actions/cache@v3
30+
with:
31+
path: ${{ steps.composer-cache.outputs.dir }}
32+
# Use composer.json for key, if composer.lock is not committed.
33+
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
34+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
35+
restore-keys: ${{ runner.os }}-composer-
36+
37+
- name: Install Composer dependencies
38+
run: composer install --no-progress --prefer-dist --optimize-autoloader
39+
40+
- name: Show version information
41+
run: |
42+
php -v
43+
php -m
44+
composer --version
45+
46+
- name: Test with phpunit
47+
run: vendor/bin/phpunit --coverage-text

0 commit comments

Comments
 (0)