|
| 1 | +name: Runs E2E API Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - dev |
| 8 | + pull_request: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }} |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubicloud-standard-8 |
| 17 | + env: |
| 18 | + NODE_ENV: test |
| 19 | + STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes |
| 20 | + STACK_DIRECT_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:6728/stackframe" |
| 21 | + STACK_PORT_PREFIX: "67" |
| 22 | + |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + node-version: [22.x] |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v3 |
| 29 | + |
| 30 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 31 | + uses: actions/setup-node@v3 |
| 32 | + with: |
| 33 | + node-version: ${{ matrix.node-version }} |
| 34 | + |
| 35 | + - name: Setup pnpm |
| 36 | + uses: pnpm/action-setup@v3 |
| 37 | + with: |
| 38 | + version: 9.1.2 |
| 39 | + |
| 40 | + # Even just starting the Docker Compose as a daemon is slow because we have to download and build the images |
| 41 | + # so, we run it in the background |
| 42 | + - name: Start Docker Compose in background |
| 43 | + uses: JarvusInnovations/background-action@v1.0.7 |
| 44 | + with: |
| 45 | + run: docker compose -f docker/dependencies/docker.compose.yaml up -d & |
| 46 | + # we don't need to wait on anything, just need to start the daemon |
| 47 | + wait-on: /dev/null |
| 48 | + tail: true |
| 49 | + wait-for: 3s |
| 50 | + log-output-if: true |
| 51 | + |
| 52 | + - name: Install dependencies |
| 53 | + run: pnpm install --frozen-lockfile |
| 54 | + |
| 55 | + - name: Create .env.test.local file for apps/backend |
| 56 | + run: cp apps/backend/.env.development apps/backend/.env.test.local |
| 57 | + |
| 58 | + - name: Create .env.test.local file for apps/dashboard |
| 59 | + run: cp apps/dashboard/.env.development apps/dashboard/.env.test.local |
| 60 | + |
| 61 | + - name: Create .env.test.local file for apps/e2e |
| 62 | + run: cp apps/e2e/.env.development apps/e2e/.env.test.local |
| 63 | + |
| 64 | + - name: Create .env.test.local file for docs |
| 65 | + run: cp docs/.env.development docs/.env.test.local |
| 66 | + |
| 67 | + - name: Create .env.test.local file for examples/cjs-test |
| 68 | + run: cp examples/cjs-test/.env.development examples/cjs-test/.env.test.local |
| 69 | + |
| 70 | + - name: Create .env.test.local file for examples/demo |
| 71 | + run: cp examples/demo/.env.development examples/demo/.env.test.local |
| 72 | + |
| 73 | + - name: Create .env.test.local file for examples/docs-examples |
| 74 | + run: cp examples/docs-examples/.env.development examples/docs-examples/.env.test.local |
| 75 | + |
| 76 | + - name: Create .env.test.local file for examples/e-commerce |
| 77 | + run: cp examples/e-commerce/.env.development examples/e-commerce/.env.test.local |
| 78 | + |
| 79 | + - name: Create .env.test.local file for examples/middleware |
| 80 | + run: cp examples/middleware/.env.development examples/middleware/.env.test.local |
| 81 | + |
| 82 | + - name: Create .env.test.local file for examples/partial-prerendering |
| 83 | + run: cp examples/partial-prerendering/.env.development examples/partial-prerendering/.env.test.local |
| 84 | + |
| 85 | + - name: Create .env.test.local file for examples/supabase |
| 86 | + run: cp examples/supabase/.env.development examples/supabase/.env.test.local |
| 87 | + |
| 88 | + - name: Create .env.test.local file for examples/convex |
| 89 | + run: cp examples/convex/.env.development examples/convex/.env.test.local |
| 90 | + |
| 91 | + - name: Build |
| 92 | + run: pnpm build |
| 93 | + |
| 94 | + - name: Wait on Postgres |
| 95 | + run: pnpm run wait-until-postgres-is-ready:pg_isready |
| 96 | + |
| 97 | + - name: Wait on Inbucket |
| 98 | + run: npx wait-on tcp:localhost:8129 |
| 99 | + |
| 100 | + - name: Wait on Svix |
| 101 | + run: npx wait-on tcp:localhost:8113 |
| 102 | + |
| 103 | + - name: Initialize database |
| 104 | + run: pnpm run db:init |
| 105 | + |
| 106 | + - name: Start stack-backend in background |
| 107 | + uses: JarvusInnovations/background-action@v1.0.7 |
| 108 | + with: |
| 109 | + run: pnpm run start:backend --log-order=stream & |
| 110 | + wait-on: | |
| 111 | + http://localhost:8102 |
| 112 | + tail: true |
| 113 | + wait-for: 30s |
| 114 | + log-output-if: true |
| 115 | + - name: Start stack-dashboard in background |
| 116 | + uses: JarvusInnovations/background-action@v1.0.7 |
| 117 | + with: |
| 118 | + run: pnpm run start:dashboard --log-order=stream & |
| 119 | + wait-on: | |
| 120 | + http://localhost:8102 |
| 121 | + tail: true |
| 122 | + wait-for: 30s |
| 123 | + log-output-if: true |
| 124 | + - name: Start mock-oauth-server in background |
| 125 | + uses: JarvusInnovations/background-action@v1.0.7 |
| 126 | + with: |
| 127 | + run: pnpm run start:mock-oauth-server --log-order=stream & |
| 128 | + wait-on: | |
| 129 | + http://localhost:8102 |
| 130 | + tail: true |
| 131 | + wait-for: 30s |
| 132 | + log-output-if: true |
| 133 | + |
| 134 | + - name: Wait 10 seconds |
| 135 | + run: sleep 10 |
| 136 | + |
| 137 | + - name: Run tests |
| 138 | + run: pnpm test |
| 139 | + |
| 140 | + - name: Run tests again, to make sure they are stable (attempt 1) |
| 141 | + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' |
| 142 | + run: pnpm test |
| 143 | + |
| 144 | + - name: Run tests again, to make sure they are stable (attempt 2) |
| 145 | + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' |
| 146 | + run: pnpm test |
| 147 | + |
| 148 | + - name: Verify data integrity |
| 149 | + run: pnpm run verify-data-integrity |
| 150 | + |
| 151 | + - name: Print Docker Compose logs |
| 152 | + if: always() |
| 153 | + run: docker compose -f docker/dependencies/docker.compose.yaml logs |
0 commit comments