Skip to content

Commit cb7ca44

Browse files
authored
Merge pull request #1 from mickamy/feat/add-ci
ci: add github actions workflow to run benchmark
2 parents 97e58d3 + 7ecccac commit cb7ca44

File tree

14 files changed

+133
-7
lines changed

14 files changed

+133
-7
lines changed

.github/workflows/benchmark.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Benchmark
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.sha }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
benchmark:
13+
name: Run benchmark
14+
runs-on: ubuntu-22.04
15+
timeout-minutes: 60
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
language:
20+
- "crystal"
21+
- "go"
22+
- "nodejs"
23+
- "php"
24+
- "python"
25+
- "python_sanic"
26+
- "ruby"
27+
steps:
28+
- uses: actions/checkout@v2
29+
- run: echo 'Run benchmark for ISHOCON2'
30+
- run: |
31+
sed -i 's/python/'"$ISHOCON_APP_LANG"'/g' ./docker-compose.yml
32+
cat ./docker-compose.yml
33+
make build
34+
env:
35+
ISHOCON_APP_LANG: ${{ matrix.language }}
36+
- run: make up && sleep 30
37+
- run: make bench
38+
timeout-minutes: 5

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
common:
2+
docker build -f docker/app/base/Dockerfile -t showwin/ishocon2_app_base:latest .
3+
4+
build: common
5+
docker compose build
6+
7+
up: build
8+
docker compose up -d
9+
10+
down:
11+
docker compose down
12+
13+
bench:
14+
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443"

doc/local_manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ $ docker exec -it ishocon2_app_1 /bin/bash
4343
## ベンチマーカー
4444

4545
```
46-
$ docker exec -it ishocon2_bench_1 /bin/bash
46+
$ docker exec -it ishocon2-bench-1 /bin/bash
4747
$ ./benchmark --ip app:443 # docker-compose.yml で link しているので app で到達できます
4848
```

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ services:
44
build:
55
context: .
66
dockerfile: ./docker/app/python/Dockerfile
7-
command: tail -f /dev/null
7+
environment:
8+
ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}"
9+
command: [/home/ishocon/run.sh]
10+
tty: true
811
volumes:
912
- storage_app:/var/lib/mysql
1013
- ./webapp:/home/ishocon/webapp

docker/app/crystal/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ FROM showwin/ishocon2_app_base:latest
22
ENV APP_LANG 'Crystal'
33

44
# Crystal のインストール
5+
RUN sudo apt-get update
56
RUN sudo apt-get install -y gnupg2
67
RUN curl -sL "https://keybase.io/crystal/pgp_keys.asc" | sudo apt-key add -
78
RUN echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list
8-
RUN sudo apt-get update
99
RUN sudo apt install -y libssl1.0-dev crystal
1010

1111
# アプリケーション
@@ -17,6 +17,8 @@ COPY admin/config/bashrc /home/ishocon/.bashrc
1717
WORKDIR /home/ishocon
1818
EXPOSE 443
1919

20+
COPY run.sh /home/ishocon/run.sh
21+
2022
COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
2123
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]
2224

docker/app/entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash
1+
#!/bin/bash -eux
2+
23
sudo service nginx start
34
sudo service mysql start
45
sudo chown -R mysql:mysql /var/lib/mysql /var/run/mysqld

docker/app/go/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ COPY admin/config/bashrc /home/ishocon/.bashrc
1919
WORKDIR /home/ishocon
2020
EXPOSE 443
2121

22+
COPY run.sh /home/ishocon/run.sh
23+
2224
COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
2325
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]
2426

docker/app/nodejs/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ RUN cd /home/ishocon/webapp/nodejs && \
1818
WORKDIR /home/ishocon
1919
EXPOSE 443
2020

21+
COPY run.sh /home/ishocon/run.sh
22+
2123
COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
2224
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]
2325

docker/app/php/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ RUN cd /home/ishocon/webapp/php && \
2121
WORKDIR /home/ishocon
2222
EXPOSE 443
2323

24+
COPY run.sh /home/ishocon/run.sh
25+
2426
COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
2527
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]
2628

docker/app/python/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ FROM showwin/ishocon2_app_base:latest
22
ENV APP_LANG 'Python'
33

44
# Python のインストール
5+
RUN sudo apt-get update
56
RUN sudo apt-get install -y zlib1g-dev
67
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \
78
PYENV_ROOT="$HOME/.pyenv" && PATH="$PYENV_ROOT/bin:$PATH" && \
89
eval "$(pyenv init -)" && \
910
pyenv install 3.6.5 && pyenv global 3.6.5 && \
10-
cd && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py && rm get-pip.py
11+
cd && curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py && python get-pip.py && rm get-pip.py
1112

1213
# アプリケーション
1314
RUN mkdir /home/ishocon/data /home/ishocon/webapp
@@ -23,6 +24,8 @@ RUN LC_ALL=C.UTF-8 && LANG=C.UTF-8 && cd /home/ishocon/webapp/python && \
2324
WORKDIR /home/ishocon
2425
EXPOSE 443
2526

27+
COPY run.sh /home/ishocon/run.sh
28+
2629
COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
2730
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]
2831

docker/app/ruby/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM showwin/ishocon2_app_base:latest
22
ENV APP_LANG 'Ruby'
33

44
# Ruby のインストール
5+
RUN sudo apt-get update
56
RUN sudo apt-get install -y ruby-dev libmysqlclient-dev && \
67
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
78
RUN PATH="$HOME/.rbenv/bin:$PATH" && \
@@ -21,6 +22,8 @@ RUN cd /home/ishocon/webapp/ruby && sudo gem install bundler -v "1.16.1" && bund
2122
WORKDIR /home/ishocon
2223
EXPOSE 443
2324

25+
COPY run.sh /home/ishocon/run.sh
26+
2427
COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
2528
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]
2629

docker/benchmarker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM ubuntu:18.04
22

3-
RUN apt-get update
3+
RUN sudo apt-get update
44
RUN apt-get install -y wget
55

66
# Go のインストール

docker/benchmarker/entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash
1+
#!/bin/bash -ux
2+
23
service mysql start # なぜか失敗する(調査中)
34
chown -R mysql:mysql /var/lib/mysql /var/run/mysqld
45
service mysql start # 正しく起動

run.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash -eux
2+
3+
app_lang="${ISHOCON_APP_LANG}"
4+
5+
if [ -z "$app_lang" ]
6+
then
7+
echo "ISHOCON_APP_LANG is not set"
8+
exit 1
9+
fi
10+
11+
check_message="start application w/ ${app_lang}..."
12+
13+
echo "app_lang: $app_lang"
14+
15+
function run_ruby() {
16+
bundle install
17+
unicorn -c unicorn_config.rb
18+
echo "$check_message"
19+
}
20+
21+
function run_python() {
22+
/home/ishocon/.pyenv/shims/uwsgi --ini app.ini
23+
echo "$check_message"
24+
}
25+
26+
function run_python_sanic() {
27+
/home/ishocon/.pyenv/shims/uwsgi --ini app.ini
28+
echo "$check_message"
29+
}
30+
31+
32+
function run_go() {
33+
go get -t -d -v ./...
34+
go build -o webapp *.go
35+
./webapp
36+
echo "$check_message"
37+
}
38+
39+
function run_php() {
40+
sudo mv -f /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
41+
sudo cp webapp/php/php-nginx.conf /etc/nginx/nginx.conf
42+
sudo service nginx reload
43+
echo "$check_message"
44+
}
45+
46+
function run_crystal() {
47+
shards install
48+
crystal app.cr
49+
echo "$check_message"
50+
}
51+
52+
echo "run $app_lang app..."
53+
cd "/home/ishocon/webapp/$app_lang"
54+
55+
"run_$app_lang"

0 commit comments

Comments
 (0)