forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 3
200 lines (196 loc) · 6.1 KB
/
test.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: test
on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
-
php-version: 8.2
name: Unit
skip-web-check: 1
database: mariadb:10.5
-
php-version: 8.1
name: Unit
skip-web-check: 1
database: mysql:8.0
-
php-version: 8.1
name: Web
skip-unit-check: 1
database: mariadb:10.11
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@v4
with:
fetch-depth: 0
-
name: Set $FILES
run: |
FILES=$(git diff --diff-filter=d --name-only origin/master | tr '\n' ' '|sed 's/,*$//g')
echo $FILES
echo 'FILES<<EOF' >> $GITHUB_ENV
echo $FILES >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
-
name: Set $PATH
run: |
echo "/home/runner/.local/bin/" >> $GITHUB_PATH
-
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: Install packages
run: |
sudo apt-get -qq update
sudo apt-get install -y fping python3-pip python3-setuptools snmp sqlite3
-
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: Start ChromeDriver
if: matrix.skip-web-check != '1'
run: |
$CHROMEWEBDRIVER/chromedriver --port=9515 &
-
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: Artisan serve
if: matrix.skip-web-check != '1'
run: |
php artisan serve --env=dusk.testing >/tmp/artisan-serve.log 2>&1 &
sleep 5
-
name: Start SNMP
if: matrix.skip-unit-check != '1'
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
env:
SKIP_UNIT_CHECK: ${{ matrix.skip-unit-check }}
SKIP_WEB_CHECK: ${{ matrix.skip-web-check }}
-
name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
-
name: Dump serve logs
if: always() && matrix.skip-web-check != '1'
run: |
cat /tmp/artisan-serve.log || true
-
name: Dump snmp logs
if: failure() && matrix.skip-unit-check != '1'
run: |
cat /tmp/snmpsimd.log || true
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1