Skip to content

Commit b3a5965

Browse files
authored
Merge pull request #15 from codeigniter4/add-phpunit-no-db.yml
Add workflow for PHPUnit without database testing
2 parents 4eaabb6 + 891fb54 commit b3a5965

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# This workflow is for packages without database testing.
2+
name: PHPUnit
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- develop
8+
paths:
9+
- '**.php'
10+
- 'composer.*'
11+
- 'phpunit*'
12+
- '.github/workflows/phpunit.yml'
13+
push:
14+
branches:
15+
- develop
16+
paths:
17+
- '**.php'
18+
- 'composer.*'
19+
- 'phpunit*'
20+
- '.github/workflows/phpunit.yml'
21+
workflow_call:
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
25+
cancel-in-progress: true
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
main:
32+
name: PHP ${{ matrix.php-versions }} Unit Tests
33+
runs-on: ubuntu-latest
34+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
35+
strategy:
36+
matrix:
37+
php-versions: ['7.4', '8.0', '8.1', '8.2']
38+
dependencies: ['highest', 'lowest']
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
44+
- name: Set up PHP
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: ${{ matrix.php-versions }}
48+
tools: composer, phive, phpunit
49+
extensions: intl, json, mbstring, gd, xdebug, xml, sqlite3
50+
coverage: xdebug
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Get composer cache directory
55+
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV
56+
57+
- name: Cache composer dependencies
58+
uses: actions/cache@v3
59+
with:
60+
path: ${{ env.COMPOSER_CACHE_FILES_DIR }}
61+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
62+
restore-keys: ${{ runner.os }}-composer-
63+
64+
- name: Install dependencies
65+
run: |
66+
if [ -f composer.lock ]; then
67+
composer install ${{ env.COMPOSER_UPDATE_FLAGS }} --no-progress --no-interaction --prefer-dist --optimize-autoloader
68+
else
69+
composer update ${{ env.COMPOSER_UPDATE_FLAGS }} --no-progress --no-interaction --prefer-dist --optimize-autoloader
70+
fi
71+
env:
72+
COMPOSER_UPDATE_FLAGS: ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }}
73+
74+
- name: Test with PHPUnit
75+
run: vendor/bin/phpunit --verbose --coverage-text --testsuite main
76+
env:
77+
TERM: xterm-256color
78+
TACHYCARDIA_MONITOR_GA: enabled
79+
80+
- if: matrix.php-versions == '8.1'
81+
name: Run Coveralls
82+
continue-on-error: true
83+
run: |
84+
sudo phive --no-progress install --global --trust-gpg-keys E82B2FB314E9906E php-coveralls
85+
php-coveralls --verbose --coverage_clover=build/phpunit/clover.xml --json_path build/phpunit/coveralls-upload.json
86+
env:
87+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
COVERALLS_PARALLEL: true
89+
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }}
90+
91+
coveralls:
92+
needs: [main]
93+
name: Coveralls Finished
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: Upload Coveralls results
97+
uses: coverallsapp/github-action@master
98+
continue-on-error: true
99+
with:
100+
github-token: ${{ secrets.GITHUB_TOKEN }}
101+
parallel-finished: true

.github/workflows/phpunit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# This workflow runs tests on all databases supported by CI4.
12
name: PHPUnit
23

34
on:

0 commit comments

Comments
 (0)