-
Notifications
You must be signed in to change notification settings - Fork 29
137 lines (124 loc) · 5.88 KB
/
phpunit.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
name: Phpunit tests
on:
push:
branches: [ main, test ]
paths:
- .github/workflows/phpunit.yml
- appinfo/**
- composer.*
- lib/**
- templates/**
- tests/**
pull_request:
branches: [ main ]
paths:
- .github/workflows/phpunit.yml
- appinfo/**
- composer.*
- lib/**
- templates/**
- tests/**
env:
APP_ID: cospend
jobs:
tests:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
server-versions: ['master']
databases: ['sqlite', 'mysql', 'pgsql']
#php-versions: ['8.2']
#databases: ['sqlite']
#server-versions: ['master']
#exclude:
# - php-versions: 7.4
# server-versions: master
name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}
services:
postgres:
image: postgres:14
ports:
- 4445:5432/tcp
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: rootpassword
POSTGRES_DB: nextcloud
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
mysql:
image: mariadb:10.5
ports:
- 4444:3306/tcp
env:
MYSQL_ROOT_PASSWORD: rootpassword
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, sqlite3, curl, xml, json, zip, gd
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: php-cs-fixer
- uses: actions/checkout@v2
- name: Setup Nextcloud
run: |
export DEBIAN_FRONTEND=noninteractive
#sudo apt update -y
#sudo apt install python3-pip git sudo unzip curl wget sed make rsync -y
mkdir -p ~/html
echo "git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.server-versions }} ~/html/nextcloud"
git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.server-versions }} ~/html/nextcloud
sed -i $'s|if (substr($fullPath, 0, strlen($root) + 1) === $root . \'/\')|if (is_string($root) and substr($fullPath, 0, strlen($root) + 1) === $root . \'/\')|g' ~/html/nextcloud/lib/autoloader.php
cp -r $GITHUB_WORKSPACE ~/html/nextcloud/apps/${{ env.APP_ID }}
# SETUP NEXTCLOUD
if [ "${{ matrix.databases }}" = "mysql" ]; then
export DB_PORT=4444
elif [ "${{ matrix.databases }}" = "pgsql" ]; then
export DB_PORT=4445
fi
echo "php ~/html/nextcloud/occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin"
php ~/html/nextcloud/occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
php ~/html/nextcloud/occ app:enable --force ${{ env.APP_ID }}
php ~/html/nextcloud/occ maintenance:mode --off
echo "##### App is installed"
cd ~/html/nextcloud/apps/${{ env.APP_ID }}
composer i
- name: Perform PhpUnit tests with coverage
if: ${{ matrix.databases == 'sqlite' && matrix.php-versions == '8.0' && matrix.server-versions == 'master' }}
run: |
mkdir /tmp/coverage
cd /tmp
echo "##### PHPunit"
XDEBUG_MODE=coverage ~/html/nextcloud/apps/${{ env.APP_ID }}/vendor/bin/phpunit --configuration ~/html/nextcloud/apps/${{ env.APP_ID }}/tests/phpunit.xml --coverage-text --color=never --coverage-html coverage > /tmp/cov.txt && SUCCESS=yes || SUCCESS=no
echo "phpunit finished ############################"
cat /tmp/cov.txt
if [ $SUCCESS = "yes" ]; then echo "TESTS PASSED"; else echo "TESTS FAILED"; exit 1; fi
echo "generating badge ############################"
grep "^\s\+Lines:" /tmp/cov.txt > /tmp/cov.line.txt
grep -o "[0-9]\+\.[0-9]\+" /tmp/cov.line.txt > /tmp/cov.value.txt
mv /tmp/cov.value.txt /tmp/coverage/cov.value.txt
echo "anybadge ############################"
sudo -H pip3 install anybadge
cat /tmp/coverage/cov.value.txt
anybadge -l coverage -v `cat /tmp/coverage/cov.value.txt` -m "%.2f%%" -f /tmp/coverage/coverage.svg 50=red 70=orange 80=yellow 90=green
- name: Perform PhpUnit tests
if: ${{ !(matrix.databases == 'sqlite' && matrix.php-versions == '8.0' && matrix.server-versions == 'master') }}
run: |
~/html/nextcloud/apps/${{ env.APP_ID }}/vendor/bin/phpunit --configuration ~/html/nextcloud/apps/${{ env.APP_ID }}/tests/phpunit.xml && SUCCESS=yes || SUCCESS=no
if [ $SUCCESS = "yes" ]; then echo "TESTS PASSED"; else echo "TESTS FAILED"; exit 1; fi
- name: Upload coverage
if: ${{ github.ref == 'refs/heads/master' && matrix.databases == 'sqlite' && matrix.php-versions == '8.0' && matrix.server-versions == 'master' }}
uses: actions/upload-artifact@v2
with:
name: coverage
path: /tmp/coverage
- name: Deploy
if: ${{ github.ref == 'refs/heads/master' && matrix.databases == 'sqlite' && matrix.php-versions == '8.0' && matrix.server-versions == 'master' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: /tmp/coverage