|
| 1 | +name: Blacksmith PR Testbox |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + testbox_id: |
| 7 | + type: string |
| 8 | + description: "Testbox session ID" |
| 9 | + required: true |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + pr-testbox: |
| 16 | + runs-on: blacksmith-8vcpu-ubuntu-2404 |
| 17 | + env: |
| 18 | + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Begin Testbox |
| 22 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 23 | + uses: useblacksmith/begin-testbox@233448af4bfdc6fca509a7f0974411ac6d8a8043 # v2 |
| 24 | + with: |
| 25 | + testbox_id: ${{ inputs.testbox_id }} |
| 26 | + |
| 27 | + - name: 🔧 Disable IPv6 |
| 28 | + run: | |
| 29 | + sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 |
| 30 | + sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 |
| 31 | + sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1 |
| 32 | +
|
| 33 | + - name: 🔧 Configure docker address pool |
| 34 | + run: | |
| 35 | + CONFIG='{ |
| 36 | + "default-address-pools" : [ |
| 37 | + { |
| 38 | + "base" : "172.17.0.0/12", |
| 39 | + "size" : 20 |
| 40 | + }, |
| 41 | + { |
| 42 | + "base" : "192.168.0.0/16", |
| 43 | + "size" : 24 |
| 44 | + } |
| 45 | + ] |
| 46 | + }' |
| 47 | + sudo mkdir -p /etc/docker |
| 48 | + echo "$CONFIG" | sudo tee /etc/docker/daemon.json |
| 49 | +
|
| 50 | + - name: 🔧 Restart docker daemon |
| 51 | + run: sudo systemctl restart docker |
| 52 | + |
| 53 | + - name: ⬇️ Checkout repo |
| 54 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 55 | + with: |
| 56 | + fetch-depth: 0 |
| 57 | + persist-credentials: false |
| 58 | + |
| 59 | + - name: ⎔ Setup pnpm |
| 60 | + uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 |
| 61 | + with: |
| 62 | + version: 10.33.2 |
| 63 | + |
| 64 | + - name: ⎔ Setup Node 22 for SDK compatibility checks |
| 65 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 66 | + with: |
| 67 | + node-version: 22.12 |
| 68 | + |
| 69 | + - name: ⎔ Setup active Node 20 |
| 70 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 71 | + with: |
| 72 | + node-version: 20.20.2 |
| 73 | + cache: "pnpm" |
| 74 | + |
| 75 | + - name: 🥟 Setup Bun |
| 76 | + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 77 | + with: |
| 78 | + bun-version: latest |
| 79 | + |
| 80 | + - name: 🦕 Setup Deno |
| 81 | + uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4 |
| 82 | + with: |
| 83 | + deno-version: v2.x |
| 84 | + |
| 85 | + - name: 🐳 Login to DockerHub |
| 86 | + if: ${{ env.DOCKERHUB_USERNAME }} |
| 87 | + uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 |
| 88 | + with: |
| 89 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 90 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 91 | + |
| 92 | + - name: 🐳 Skipping DockerHub login (no secrets available) |
| 93 | + if: ${{ !env.DOCKERHUB_USERNAME }} |
| 94 | + run: echo "DockerHub login skipped because secrets are not available." |
| 95 | + |
| 96 | + - name: 🐳 Pre-pull testcontainer images |
| 97 | + if: ${{ env.DOCKERHUB_USERNAME }} |
| 98 | + run: | |
| 99 | + pull() { |
| 100 | + for attempt in 1 2 3; do |
| 101 | + docker pull "$1" && return 0 |
| 102 | + echo "::warning::docker pull $1 failed (attempt ${attempt}/3); retrying in 10s" |
| 103 | + sleep 10 |
| 104 | + done |
| 105 | + echo "::error::docker pull $1 failed after 3 attempts" |
| 106 | + return 1 |
| 107 | + } |
| 108 | +
|
| 109 | + echo "Pre-pulling Docker images with authenticated session..." |
| 110 | + pull postgres:14 |
| 111 | + pull clickhouse/clickhouse-server:26.2.19.43-alpine@sha256:c6ad6a7eb2fb5999df3adfb8b69a0c7222c68fa9b8f6b04a088564ebbc959251 |
| 112 | + pull redis:7.2 |
| 113 | + pull testcontainers/ryuk:0.11.0 |
| 114 | + pull testcontainers/ryuk:0.14.0 |
| 115 | + pull electricsql/electric:1.2.4 |
| 116 | + pull minio/minio:latest |
| 117 | + echo "Image pre-pull complete" |
| 118 | +
|
| 119 | + - name: 📥 Download deps |
| 120 | + run: pnpm install --frozen-lockfile |
| 121 | + |
| 122 | + - name: 📀 Generate Prisma Client |
| 123 | + run: pnpm run generate |
| 124 | + |
| 125 | + - name: Run Testbox |
| 126 | + uses: useblacksmith/run-testbox@5ca05834db1d3813554d1dd109e5f2087a8d7cbc # v2 |
| 127 | + if: ${{ always() && github.event_name == 'workflow_dispatch' }} |
0 commit comments