diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b25537736..f8c9acc9a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,13 @@ on: description: 'Run perf test times' required: true default: '0' + schedule: + - cron: '0 0 * * *' # every day at midnight + filters: + branches: + include: + - 'main' + permissions: actions: 'write' @@ -22,7 +29,7 @@ permissions: name: Build jobs: build: - runs-on: ${{ github.event_name == 'push' && 'macos-11' || github.event.inputs.run-on-runner }} + runs-on: ${{ github.event_name == 'push' && 'macos-11' || (github.event.inputs.run-on-runner || 'self-hosted') }} steps: - name: validate agent run: | @@ -42,7 +49,7 @@ jobs: uses: actions/setup-go@v1 with: go-version: '~1.20.8' - if: github.event.inputs.run-on-runner != 'self-hosted' + if: github.event.inputs.run-on-runner != 'self-hosted' && github.event_name != 'schedule' - name: Setup GO run: | go version @@ -58,7 +65,7 @@ jobs: git fetch git checkout db6184738b77fbd5089e5fa1112177f391c91b24 go install github.com/mitchellh/gox - if: github.event.inputs.run-on-runner != 'self-hosted' + if: github.event.inputs.run-on-runner != 'self-hosted' && github.event_name != 'schedule' - name: Install brew and node deps run: | curl https://raw.githubusercontent.com/Homebrew/homebrew-core/31b24d65a7210ea0a5689d5ad00dd8d1bf5211db/Formula/protobuf.rb --output protobuf.rb @@ -69,7 +76,7 @@ jobs: brew tap --custom-remote filosottile/musl-cross https://github.com/anyproto/homebrew-musl-cross.git HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install filosottile/musl-cross/musl-cross npm i -g node-gyp - if: github.event.inputs.run-on-runner != 'self-hosted' + if: github.event.inputs.run-on-runner != 'self-hosted' && github.event_name != 'schedule' - name: Checkout uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -126,21 +133,25 @@ jobs: - name: run perf tests run: | echo "Running perf tests" + RUN_COUNT=${{ github.event.inputs.perf-test }} + if [[ "${{ github.event_name }}" == "schedule" ]]; then + RUN_COUNT=10 + fi cd cmd/perftester/ - go run main.go ${{ github.event.inputs.perf-test }} + go run main.go $RUN_COUNT env: ANYTYPE_REPORT_MEMORY: 'true' TEST_MNEMONIC: ${{ secrets.TEST_MNEMONIC }} PROM_KEY: ${{ secrets.PROMETHEUS_USERNAME }} PROM_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }} - if: github.event.inputs.perf-test != '0' + if: github.event.inputs.perf-test != '0' || github.event_name == 'schedule' - name: Archive perf tests results uses: actions/upload-artifact@v4 with: name: pprofs path: | *.pprof - if: github.event.inputs.perf-test != '0' + if: github.event.inputs.perf-test != '0' || github.event_name == 'schedule' - name: end run perf tests run: | rm -rf *.pprof @@ -149,7 +160,7 @@ jobs: gh run watch ${{ github.run_id }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: github.event.inputs.perf-test != '0' + if: github.event.inputs.perf-test != '0' || github.event_name == 'schedule' - name: Make JS protos run: | make protos-js diff --git a/docs/PerfTests.md b/docs/PerfTests.md new file mode 100644 index 000000000..7604875cb --- /dev/null +++ b/docs/PerfTests.md @@ -0,0 +1,30 @@ +# Perf tests + +## Test results + +grafana/d/mHq4sS2Sk/middleware-perf-tests + +Memory and cpu pprof is collected for each test run and stored in the build artifacts. + +## Run tests + +https://github.com/anyproto/anytype-heart/actions/workflows/build.yml + +Runner: `self-hosted` + +Run perf test times: `> 0` + +## Run tests locally + +``` +cd cmd/perftester/ +go run main.go +``` + +You'll get the artifacts locally. + +You must have the prometheus key PROM_KEY and password PROM_PASSWORD in your environment variables or just comment sending metrics in grpc.go. + +## Perf tests schedule + +Main branch every day at midnight \ No newline at end of file