test: stress benchmarks for concurrent rate limit and fanout (closes … #1062
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| compile: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - name: copy backend env | |
| run: cp .env.example .env | |
| working-directory: example/backend | |
| - name: copy frontend env | |
| run: cp .env.example .env | |
| working-directory: example/frontend | |
| - run: bun install | |
| - name: compile frontend | |
| run: bun run build | |
| working-directory: example/frontend | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: bun lint | |
| test-package: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2] | |
| services: | |
| redis: | |
| image: redis | |
| ports: | |
| - 6379:6379 | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: keryx-test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: cp packages/keryx/.env.example packages/keryx/.env | |
| - name: Run test shard ${{ matrix.shard }}/2 | |
| run: | | |
| cd packages/keryx | |
| files=$(find __tests__ -name '*.test.ts' | sort) | |
| shard_files=$(echo "$files" | awk "NR % 2 == (${{ matrix.shard }} - 1)") | |
| echo "Running: $shard_files" | |
| bun test $shard_files | |
| env: | |
| DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/keryx-test | |
| test-plugin-resque-admin: | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis | |
| ports: | |
| - 6379:6379 | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: keryx-test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: cp packages/keryx/.env.example packages/keryx/.env | |
| - run: cp packages/plugins/resque-admin/.env.example packages/plugins/resque-admin/.env | |
| - name: Run resque-admin tests | |
| run: cd packages/plugins/resque-admin && bun test | |
| env: | |
| DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/keryx-test | |
| test-example-backend: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2] | |
| services: | |
| redis: | |
| image: redis | |
| ports: | |
| - 6379:6379 | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: keryx-test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: cp example/backend/.env.example example/backend/.env | |
| - name: Run test shard ${{ matrix.shard }}/2 | |
| run: | | |
| cd example/backend | |
| files=$(find __tests__ -name '*.test.ts' | sort) | |
| shard_files=$(echo "$files" | awk "NR % 2 == (${{ matrix.shard }} - 1)") | |
| echo "Running: $shard_files" | |
| bun test $shard_files | |
| env: | |
| DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/keryx-test | |
| test-plugin-tracing: | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis | |
| ports: | |
| - 6379:6379 | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: keryx-test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: cp packages/keryx/.env.example packages/keryx/.env | |
| - run: cp packages/plugins/tracing/.env.example packages/plugins/tracing/.env | |
| - name: Run tracing tests | |
| run: cd packages/plugins/tracing && bun test | |
| env: | |
| DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/keryx-test | |
| test-plugin-csrf: | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis | |
| ports: | |
| - 6379:6379 | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: keryx-test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: cp packages/keryx/.env.example packages/keryx/.env | |
| - run: cp packages/plugins/csrf/.env.example packages/plugins/csrf/.env | |
| - name: Run csrf tests | |
| run: cd packages/plugins/csrf && bun test | |
| env: | |
| DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/keryx-test | |
| test-example-frontend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: cp example/backend/.env.example example/backend/.env | |
| - run: bun test-example-frontend | |
| test-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: bun test-docs | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis | |
| ports: | |
| - 6379:6379 | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: keryx-test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install | |
| - run: cp example/backend/.env.example example/backend/.env | |
| - name: Run transport benchmarks | |
| run: bun benchmark | |
| env: | |
| DATABASE_URL_TEST: postgres://postgres:postgres@localhost:5432/keryx-test | |
| docker-build-backend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build backend Docker image | |
| run: docker build -f example/backend/Dockerfile . | |
| docker-build-frontend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build frontend Docker image | |
| run: docker build -f example/frontend/Dockerfile --build-arg VITE_API_URL=http://localhost:8080 . | |
| complete: | |
| runs-on: ubuntu-latest | |
| if: always() | |
| needs: [compile, lint, test-package, test-plugin-tracing, test-plugin-resque-admin, test-plugin-csrf, test-example-backend, test-example-frontend, test-docs, benchmark, docker-build-backend, docker-build-frontend] | |
| steps: | |
| - run: | | |
| if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then | |
| echo "One or more jobs failed or were cancelled" | |
| exit 1 | |
| fi | |
| echo "All jobs passed!" |