forked from XOOPS/XoopsCore25
-
-
Notifications
You must be signed in to change notification settings - Fork 3
148 lines (136 loc) · 4.51 KB
/
pr_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: CI
on: [push, pull_request]
jobs:
phpunit-tests:
strategy:
fail-fast: false
matrix:
include:
# PHP 8.1
- php_version: "8.1"
phpunit_version: "9.6"
# PHP 8.2
- php_version: "8.2"
phpunit_version: "10.5"
# PHP 8.3
- php_version: "8.3"
phpunit_version: "10.5"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
coverage: xdebug
tools: composer:v2
- name: Create composer.json
working-directory: htdocs/class/libraries
env:
PHP_VERSION: ${{ matrix.php_version }}
PHPUNIT_VERSION: ${{ matrix.phpunit_version }}
run: |
cat > composer.json << EOL
{
"name": "xoopscore25/libraries",
"license": "GPL-2.0-or-later",
"type": "project",
"description": "Libraries for XOOPS 2.5.12",
"config": {
"platform": {
"php": "$PHP_VERSION"
},
"allow-plugins": {
"composer/installers": true
}
},
"require": {
"php": ">=${PHP_VERSION}",
"xoops/base-requires25": "^1.1.6"
},
"require-dev": {
"phpunit/phpunit": "^${PHPUNIT_VERSION}"
},
"minimum-stability": "stable"
}
EOL
cat composer.json
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer Dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
working-directory: htdocs/class/libraries
env:
PHPUNIT_VERSION: ${{ matrix.phpunit_version }}
run: |
composer update --prefer-dist --no-interaction --no-progress
# The phpunit dependency is already specified in composer.json, so no need to require it again.
ls -la vendor/bin
if [ -f "vendor/bin/phpunit" ]; then
echo "PHPUnit is installed"
vendor/bin/phpunit --version
else
echo "PHPUnit installation failed"
exit 1
fi
- name: Create PHPUnit Config
working-directory: htdocs/class/libraries
run: |
cat > phpunit.xml << EOL
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
failOnRisky="true"
failOnWarning="true"
testdox="true">
<testsuites>
<testsuite name="XOOPS Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/>
</php>
</phpunit>
EOL
- name: Create Test Directory and Sample Test
working-directory: htdocs/class/libraries
run: |
mkdir -p tests
cat > tests/SampleTest.php << EOL
<?php
use PHPUnit\Framework\TestCase;
class SampleTest extends TestCase
{
public function testTrue(): void
{
\$this->assertTrue(true);
}
}
EOL
- name: Run PHPUnit
working-directory: htdocs/class/libraries
run: |
echo "Current directory: $(pwd)"
echo "Contents of vendor/bin:"
ls -la vendor/bin
vendor/bin/phpunit --version
vendor/bin/phpunit --configuration phpunit.xml --stderr