forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (171 loc) · 5.34 KB
/
test.yml
File metadata and controls
182 lines (171 loc) · 5.34 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Test
on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
test:
name: ${{ matrix.name }} ${{ matrix.arguments }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php-version:
- 8.4
arguments:
- --os a
- --os b,c,d
- --os e,f
- --os g,h,i
- --os j,k,l,m,n
- --os o,p,q,r,s
- --os t
- --os u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9
include:
-
name: PHP 8.4
php-version: 8.4
database: mariadb:11.7
-
name: Other
php-version: 8.4
database: mariadb:11.7
arguments: --full --exclude-phpunit-group=browser,mibs,external-dependencies,os
-
name: Other
php-version: 8.2
database: mysql:8.0
arguments: --full --exclude-phpunit-group=browser,mibs,external-dependencies,os
services:
database:
image: ${{ matrix.database }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: librenms_phpunit_78hunjuybybh
MYSQL_USER: librenms
MYSQL_PASSWORD: librenms
ports:
- 3306
steps:
-
name: Checkout
uses: actions/checkout@v5
-
name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer,php-cs-fixer
coverage: none
-
name: Get composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
-
name: Cache composer
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ secrets.CACHE_VERSION }}-
-
name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ secrets.CACHE_VERSION }}-
-
name: Pip install
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade --user pylint python-memcached mysqlclient
-
name: Composer validate
run: |
composer validate
-
name: Init env
run: |
cat > .env <<EOL
APP_KEY=base64:vHI+YHgkyCDad31iPEErGSNEOWO21wNzV+zyENKQv04=
APP_URL=http://127.0.0.1:8000
APP_ENV=testing
DB_DRIVER=mysql
DB_HOST=127.0.0.1
DB_PORT=${{ job.services.database.ports[3306] }}
DB_DATABASE=librenms_phpunit_78hunjuybybh
DB_USERNAME=librenms
DB_PASSWORD=librenms
DB_TEST_DRIVER=mysql
DB_TEST_HOST=127.0.0.1
DB_TEST_PORT=${{ job.services.database.ports[3306] }}
DB_TEST_DATABASE=librenms_phpunit_78hunjuybybh
DB_TEST_USERNAME=librenms
DB_TEST_PASSWORD=librenms
EOL
-
name: Composer install
run: |
composer install --prefer-dist --no-interaction --no-progress
-
name: Snmpsim setup
run: |
php lnms dev:simulate --setup-venv
-
name: Copy seeded config
run: cp "${GITHUB_WORKSPACE}/tests/testing_config.yaml" "${GITHUB_WORKSPACE}/database/seeders/config/"
-
name: Ensure MySQL is up
env:
PORT: ${{ job.services.database.ports[3306] }}
run: |
mysqladmin -h"127.0.0.1" -P"$PORT" --user=librenms --password=librenms ping --wait=5
-
name: Set MySQL authentication plugin
if: matrix.database == 'mysql:8.0'
env:
PORT: ${{ job.services.database.ports[3306] }}
run: |
mysql -h"127.0.0.1" -P"$PORT" --user=root -e "ALTER USER 'librenms'@'%' IDENTIFIED WITH mysql_native_password BY 'librenms'"
-
name: Set MySQL collate
env:
PORT: ${{ job.services.database.ports[3306] }}
run: |
mysql -h"127.0.0.1" -P"$PORT" --user=librenms --password=librenms -e 'ALTER DATABASE librenms_phpunit_78hunjuybybh CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
-
name: Setup SQLite
run: sqlite3 database/testing.sqlite ""
-
name: Migrate Database
run: php artisan migrate
-
name: Start SNMPSIM
run: |
.python_venvs/snmpsim/bin/snmpsim-command-responder-lite --data-dir=tests/snmpsim --agent-udpv4-endpoint=127.1.6.2:1162 --log-level=error --logging-method=file:/tmp/snmpsimd.log &
-
name: lnms dev:check ci
run: |
php lnms dev:check ci ${{ matrix.arguments }}
-
name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
-
name: Dump snmp logs
if: failure()
run: |
cat /tmp/snmpsimd.log || true
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1