-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (175 loc) · 5.82 KB
/
ci.yml
File metadata and controls
182 lines (175 loc) · 5.82 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: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
pull-requests: write
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, mbstring, json
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite
run: composer run lint
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, mbstring, json
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y jq curl netcat-traditional
- name: Build Docker images
run: make docker-compose-build
- name: Start Docker containers
run: make docker-compose-up
- name: Wait for services to be ready
run: |
echo "Waiting for services to be ready..."
for i in {1..30}; do
if nc -z localhost 38080 2>/dev/null; then
echo "Write API server port is open!"
break
fi
echo "Waiting for write-api-server... ($i/30)"
sleep 2
done
for i in {1..30}; do
if nc -z localhost 38082 2>/dev/null; then
echo "Read API server port is open!"
break
fi
echo "Waiting for read-api-server... ($i/30)"
sleep 2
done
echo "Additional wait for service initialization..."
sleep 10
- name: Run tests with coverage
run: |
docker compose exec -T app vendor/bin/phpunit --testdox --coverage-text > coverage_output.txt 2>&1 || true
cat coverage_output.txt
- name: Generate coverage report
id: coverage
run: |
COVERAGE_SUMMARY=$(docker compose exec -T app vendor/bin/phpunit --testdox --coverage-text 2>&1 | grep -A 50 "Code Coverage Report:" || echo "Coverage report not found")
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$COVERAGE_SUMMARY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
PERCENTAGE=$(echo "$COVERAGE_SUMMARY" | grep -oP "Lines:\s+\K[\d\.]+(?=%)" | head -1 || echo "0")
echo "percentage=$PERCENTAGE" >> $GITHUB_OUTPUT
echo "Coverage: $PERCENTAGE%"
- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const coverage = '${{ steps.coverage.outputs.percentage }}';
const summary = `${{ steps.coverage.outputs.summary }}`;
const comment = `## Test Coverage Report
📊 **Overall Coverage: ${coverage}%**
<details>
\`\`\`
${summary}
\`\`\`
</details>
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
- name: Show logs on failure
if: failure()
run: |
docker compose logs --tail=100
e2e:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, mbstring, json
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y jq curl netcat-traditional
- name: Build Docker images
run: make docker-compose-build
- name: Start Docker containers
run: make docker-compose-up
- name: Wait for services to be ready
run: |
echo "Waiting for services to be ready..."
for i in {1..30}; do
if nc -z localhost 38080 2>/dev/null; then
echo "Write API server port is open!"
break
fi
echo "Waiting for write-api-server... ($i/30)"
sleep 2
done
for i in {1..30}; do
if nc -z localhost 38082 2>/dev/null; then
echo "Read API server port is open!"
break
fi
echo "Waiting for read-api-server... ($i/30)"
sleep 2
done
echo "Additional wait for service initialization..."
sleep 10
- name: Run E2E tests
run: |
make verify-group-chat
- name: Show logs on failure
if: failure()
run: |
docker compose logs --tail=100