benchmark.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. name: Benchmark
  2. on:
  3. push:
  4. branches:
  5. - ci
  6. schedule:
  7. - cron: '0 */12 * * *'
  8. jobs:
  9. test:
  10. runs-on: ubuntu-latest
  11. services:
  12. redis:
  13. image: redis
  14. ports:
  15. - 6379:6379
  16. postgres:
  17. image: postgres:9.6
  18. ports:
  19. - 5432:5432
  20. env:
  21. POSTGRES_USER: peertube
  22. POSTGRES_HOST_AUTH_METHOD: trust
  23. env:
  24. PGUSER: peertube
  25. PGHOST: localhost
  26. steps:
  27. - uses: actions/checkout@v4
  28. - uses: './.github/actions/reusable-prepare-peertube-build'
  29. with:
  30. node-version: '18.x'
  31. - uses: './.github/actions/reusable-prepare-peertube-run'
  32. - name: Build
  33. run: |
  34. startClient=`date +%s`
  35. npm run build:server
  36. npm run build:client
  37. endClient=`date +%s`
  38. clientBuildTime=$((endClient-startClient))
  39. startServer=`date +%s`
  40. npm run build:server
  41. endServer=`date +%s`
  42. serverBuildTime=$((endServer-startServer))
  43. echo '{"clientBuildTime":'$clientBuildTime',"serverBuildTime":'$serverBuildTime'}'> build-time.json
  44. - name: Startup
  45. run: |
  46. npm run clean:server:test
  47. startCold=`date +%s%3N`
  48. NODE_APP_INSTANCE=1 NODE_ENV=test node dist/server --benchmark-startup
  49. endCold=`date +%s%3N`
  50. coldStartupTime=$(echo "scale=2; ($endCold-$startCold)/1000" | bc)
  51. startHot=`date +%s%3N`
  52. NODE_APP_INSTANCE=1 NODE_ENV=test node dist/server --benchmark-startup
  53. endHot=`date +%s%3N`
  54. hotStartupTime=$(echo "scale=2; ($endHot-$startHot)/1000" | bc)
  55. echo '{"coldStartupTime":'$coldStartupTime',"hotStartupTime":'$hotStartupTime'}'> startup-time.json
  56. - name: Run benchmark
  57. run: |
  58. npm run benchmark-server -- -o benchmark.json
  59. - name: Display result
  60. run: |
  61. cat benchmark.json build-time.json startup-time.json
  62. - name: Upload benchmark result
  63. uses: './.github/actions/reusable-deploy'
  64. with:
  65. source: benchmark.json build-time.json startup-time.json
  66. destination: peertube-stats
  67. knownHosts: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }}
  68. deployKey: ${{ secrets.STATS_DEPLOYEMENT_KEY }}
  69. deployUser: ${{ secrets.STATS_DEPLOYEMENT_USER }}
  70. deployHost: ${{ secrets.STATS_DEPLOYEMENT_HOST }}