-
Notifications
You must be signed in to change notification settings - Fork 189
131 lines (114 loc) · 4.09 KB
/
ci.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
name: CI
on:
pull_request:
paths:
- "webapp/go/**"
- "webapp/ruby/**"
- "bench/**"
- "cmd/**"
- "initial-data/**"
- ".github/workflows/ci.yml"
- "Makefile"
- "go.mod"
- "go.sum"
- "compose.yml"
- "webapp/compose.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Initialize the project
run: make init
- name: Check for changes in ruby directory
id: check-changes
run: |
git fetch origin
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
if echo "$CHANGED_FILES" | grep 'ruby/'; then
echo "Changes detected in ruby directory"
echo "ruby_changes_detected=true" >> $GITHUB_OUTPUT
exit 0
fi
- name: Download purl
run: |
curl -sL https://github.com/catatsuy/purl/releases/latest/download/purl-linux-amd64.tar.gz | tar xz -C /tmp
- name: Move files to /usr/local/bin for purl
run: |
sudo mv /tmp/purl /usr/local/bin/
- name: Update compose.yml if changes are detected
if: steps.check-changes.outputs.ruby_changes_detected == 'true'
run: |
purl -fail -overwrite -replace '@dockerfile: go/@dockerfile: ruby/@' ./webapp/compose.yml
- name: Start the server
run: |
cd webapp
docker compose up --build -d
- name: Build the benchmark
run: |
docker build -t isucari-benchmarker -f bench/Dockerfile .
- name: Wait for data initialization to complete
run: |
cd webapp
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM users LIMIT 1;" isucari; do
echo "Waiting for database initialization..."
sleep 10
done
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM items LIMIT 1;" isucari; do
echo "Waiting for database initialization..."
sleep 10
done
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM transaction_evidences LIMIT 1;" isucari; do
echo "Waiting for database initialization..."
sleep 10
done
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM shippings LIMIT 1;" isucari; do
echo "Waiting for database initialization..."
sleep 10
done
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM categories LIMIT 1;" isucari; do
echo "Waiting for database initialization..."
sleep 10
done
sleep 10
- name: Run the benchmark
continue-on-error: true
run: |
docker container run \
--add-host host.docker.internal:host-gateway \
-p 5678:5678 \
-p 7890:7890 \
-i isucari-benchmarker \
/bin/benchmarker \
-target-url http://host.docker.internal \
-data-dir /initial-data \
-static-dir /static \
-payment-url http://host.docker.internal:5678 \
-payment-port 5678 \
-shipment-url http://host.docker.internal:7890 \
-shipment-port 7890 \
| tee benchmark_output.json || echo "BENCHMARK_FAILED=true" >> $GITHUB_ENV
- name: Show logs
run: |
cd webapp
docker compose logs
- name: Check benchmark result
run: |
if [ ! -f benchmark_output.json ]; then
echo "benchmark_output.json not found"
exit 1
fi
if ! jq -e '.pass == true' benchmark_output.json > /dev/null; then
echo "Benchmark failed: pass is not true"
exit 1
fi
- name: Fail if benchmark failed
if: env.BENCHMARK_FAILED == 'true'
run: |
echo "Benchmark failed"
exit 1