]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - .github/workflows/benchmark.yml
Add startup time benchmark
[github/Chocobozzz/PeerTube.git] / .github / workflows / benchmark.yml
CommitLineData
2abaa3f2
C
1name: Benchmark
2
3on:
4 push:
5 branches:
6 - ci
7 schedule:
9514bb3b 8 - cron: '0 */12 * * *'
2abaa3f2
C
9
10jobs:
11
12 test:
13 runs-on: ubuntu-latest
14
15 services:
16 redis:
17 image: redis
18 ports:
19 - 6379:6379
20
21 postgres:
22 image: postgres:9.6
23 ports:
24 - 5432:5432
25 env:
26 POSTGRES_USER: peertube
27 POSTGRES_HOST_AUTH_METHOD: trust
28
29 env:
30 PGUSER: peertube
31 PGHOST: localhost
32 NODE_PENDING_JOB_WAIT: 500
33
34 steps:
35 - uses: actions/checkout@v2
36
37 - name: Use Node.js
38 uses: actions/setup-node@v1
39 with:
40 node-version: '12.x'
41
42 - name: Setup system dependencies
43 run: |
44 sudo apt-get install postgresql-client-common redis-tools parallel
45 wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.3.1-64bit-static.tar.xz"
46 tar xf ffmpeg-release-4.3.1-64bit-static.tar.xz
47 mkdir -p $HOME/bin
48 cp ffmpeg-*/{ffmpeg,ffprobe} $HOME/bin
49 echo "$HOME/bin" >> $GITHUB_PATH
50
51 - name: Cache Node.js modules
52 uses: actions/cache@v2
53 with:
54 path: |
55 **/node_modules
56 key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
57 restore-keys: |
58 ${{ runner.OS }}-node-
59 ${{ runner.OS }}-
60
61 - name: Cache fixtures
62 uses: actions/cache@v2
63 with:
64 path: |
65 fixtures
66 key: ${{ runner.OS }}-fixtures-${{ matrix.test_suite }}-${{ hashFiles('fixtures/*') }}
67 restore-keys: |
68 ${{ runner.OS }}-fixtures-${{ matrix.test_suite }}-
69 ${{ runner.OS }}-fixtures-
70 ${{ runner.OS }}-
71
72 - name: Install dependencies
73 run: yarn install --frozen-lockfile
74
75 - name: Build
76 run: |
77 startClient=`date +%s`
78 npm run build:client
79 endClient=`date +%s`
80 clientBuildTime=$((endClient-startClient))
81
82 startServer=`date +%s`
83 npm run build:server
84 endServer=`date +%s`
85 serverBuildTime=$((endServer-startServer))
86
87 echo '{"clientBuildTime":'$clientBuildTime',"serverBuildTime":'$serverBuildTime'}'> build-time.json
88
82c21206
C
89 - name: Startup
90 run: |
91 npm run clean:server:tests
92
93 startCold=`date +%s`
94 NODE_APP_INSTANCE=1 NODE_ENV=test node dist/server --benchmark-startup
95 endCold=`date +%s`
96 coldStartupTime=$((endCold-startCold))
97
98 startHot=`date +%s`
99 NODE_APP_INSTANCE=1 NODE_ENV=test node dist/server --benchmark-startup
100 endHot=`date +%s`
101 hotStartupTime=$((endHot-startHot))
102
103 echo '{"coldStartupTime":'$coldStartupTime',"hotStartupTime":'$hotStartupTime'}'> startup-time.json
104
2abaa3f2
C
105 - name: Run benchmark
106 run: |
107 node dist/scripts/benchmark.js benchmark.json
108
109 - name: Display result
110 run: |
82c21206 111 cat benchmark.json build-time.json startup-time.json
2abaa3f2
C
112
113 - name: Upload benchmark result
114 env:
115 STATS_DEPLOYEMENT_KNOWN_HOSTS: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }}
116 STATS_DEPLOYEMENT_KEY: ${{ secrets.STATS_DEPLOYEMENT_KEY }}
117 STATS_DEPLOYEMENT_USER: ${{ secrets.STATS_DEPLOYEMENT_USER }}
118 STATS_DEPLOYEMENT_HOST: ${{ secrets.STATS_DEPLOYEMENT_HOST }}
119 run: |
120 mkdir -p ~/.ssh
121 chmod 700 ~/.ssh
122 if [ ! -z ${STATS_DEPLOYEMENT_KNOWN_HOSTS+x} ]; then
123 echo "Adding ssh key to known hosts"
124 echo -e "${STATS_DEPLOYEMENT_KNOWN_HOSTS}" > ~/.ssh/known_hosts;
125 fi
126
127 eval `ssh-agent -s`
128
129 if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then
130 echo "Adding ssh reployement key"
131 ssh-add <(echo "${STATS_DEPLOYEMENT_KEY}");
132 fi
133
134 if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then
135 echo "Uploading files"
82c21206 136 scp benchmark.json build-time.json startup-time.json ${STATS_DEPLOYEMENT_USER}@${STATS_DEPLOYEMENT_HOST}:../../web/peertube-stats;
2abaa3f2 137 fi