-
Notifications
You must be signed in to change notification settings - Fork 6
153 lines (141 loc) · 5.88 KB
/
ci.yml
File metadata and controls
153 lines (141 loc) · 5.88 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
name: phpList Web Frontend Build
on: [push, pull_request]
jobs:
main:
name: phpList Base Dist on PHP ${{ matrix.php-versions }}, with dist ${{ matrix.dependencies }} [Build, Test]
runs-on: ubuntu-22.04
env:
DB_DATABASE: phplist
DB_USERNAME: root
DB_PASSWORD: phplist
BROADCAST_DRIVER: log
API_BASE_URL: http://api.phplist.local/
REST_API_BASE_URL: http://api.phplist.local/api/v2
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
MYSQL_DATABASE: ${{ env.DB_DATABASE }}
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-versions: ['8.1']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Install JS dependencies
run: yarn install --frozen-lockfile
- name: Build frontend assets
run: yarn encore dev
- name: Install Symfony CLI
run: |
curl -sS https://get.symfony.com/cli/installer | bash
mv $HOME/.symfony*/bin/symfony /usr/local/bin/symfony
symfony version
- name: Install Google Chrome
run: |
curl -sSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor | sudo tee /usr/share/keyrings/google.gpg > /dev/null
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update
sudo apt-get install -y google-chrome-stable
sudo apt install socat
- name: Verify MySQL connection on host
run: mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} -e "SHOW DATABASES"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install PHP dependencies
run: composer install --no-interaction --prefer-dist
- name: Set up database schema
run: mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} ${{ env.DB_DATABASE }} < vendor/phplist/core/resources/Database/Schema.sql
- name: Validate composer.json
run: composer validate --no-check-all --no-check-lock --strict
- name: Lint PHP files
run: find src/ tests/ public/ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
- name: Run static analysis
run: vendor/bin/phpstan analyse -l 5 src/ tests/
- name: Run PHPMD
run: vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml
- name: Run PHP_CodeSniffer
run: vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/
- name: Install Prism
run: npm install -g @stoplight/prism-cli
- name: Start Prism Mock Server
run: |
prism mock --host 127.0.0.1 --port 4010 ./openapi.json &
- name: Add local hostname
run: echo "127.0.0.1 api.phplist.local" | sudo tee -a /etc/hosts
- name: Proxy port 80 to 4010
run: |
sudo socat -d -d TCP-LISTEN:80,reuseaddr,fork TCP:127.0.0.1:4010 &
- name: Wait for Prism and proxy
run: |
set -euo pipefail
prism_ready=0
for i in $(seq 1 30); do
if curl -sS -o /tmp/prism-health-body.txt -w "%{http_code}" \
-H 'Content-Type: application/json' \
-X POST http://127.0.0.1:4010/api/v2/sessions \
--data '{"login_name":"healthcheck","password":"healthcheck"}' > /tmp/prism-health-code.txt; then
code=$(cat /tmp/prism-health-code.txt)
if [ "$code" != "000" ]; then
echo "Prism is reachable on 127.0.0.1:4010 with HTTP ${code}"
prism_ready=1
break
fi
fi
sleep 1
done
if [ "$prism_ready" -ne 1 ]; then
echo "Prism did not become reachable in time."
exit 1
fi
proxy_ready=0
for i in $(seq 1 30); do
if curl -sS -o /tmp/proxy-health-body.txt -w "%{http_code}" \
-H 'Content-Type: application/json' \
-X POST http://api.phplist.local/api/v2/sessions \
--data '{"login_name":"healthcheck","password":"healthcheck"}' > /tmp/proxy-health-code.txt; then
code=$(cat /tmp/proxy-health-code.txt)
if [ "$code" != "000" ]; then
echo "Proxy is reachable on api.phplist.local with HTTP ${code}"
proxy_ready=1
break
fi
fi
sleep 1
done
if [ "$proxy_ready" -ne 1 ]; then
echo "Proxy did not become reachable in time."
exit 1
fi
- name: Run tests with phpunit
run: vendor/bin/phpunit tests
- name: Upload Panther screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: panther-screenshots
path: var/screenshots