|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build-and-test: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Checkout |
| 12 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 13 | + with: |
| 14 | + persist-credentials: false |
| 15 | + |
| 16 | + - name: Set up Docker Buildx |
| 17 | + uses: docker/setup-buildx-action@v3 |
| 18 | + |
| 19 | + - name: Cache Docker layers |
| 20 | + uses: actions/cache@v4 |
| 21 | + with: |
| 22 | + path: /tmp/.buildx-cache |
| 23 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 24 | + restore-keys: | |
| 25 | + ${{ runner.os }}-buildx- |
| 26 | +
|
| 27 | + - name: Build Docker image |
| 28 | + uses: docker/build-push-action@v6 |
| 29 | + with: |
| 30 | + context: . |
| 31 | + push: false |
| 32 | + load: true |
| 33 | + tags: juno-api:test |
| 34 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 35 | + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max |
| 36 | + |
| 37 | + - name: Run container |
| 38 | + run: | |
| 39 | + docker run -d --name juno-api-test \ |
| 40 | + -p 3000:3000 \ |
| 41 | + -e GITHUB_CLIENT_ID=test-client-id \ |
| 42 | + -e GITHUB_CLIENT_SECRET=test-client-secret \ |
| 43 | + -e GITHUB_AUTH_ISSUER=https://api.juno.build/auth/github \ |
| 44 | + juno-api:test |
| 45 | +
|
| 46 | + - name: Wait for container to be ready |
| 47 | + run: | |
| 48 | + timeout 30 sh -c 'until curl -f http://localhost:3000/v1/auth/certs 2>/dev/null; do sleep 1; done' |
| 49 | +
|
| 50 | + - name: Test JWKS endpoint |
| 51 | + run: | |
| 52 | + response=$(curl -s http://localhost:3000/v1/auth/certs) |
| 53 | + echo "$response" | jq -e '.keys[0].kid' | grep -q "juno-api-" |
| 54 | + echo "$response" | jq -e '.keys[0].n' |
| 55 | + echo "$response" | jq -e '.keys[0].e == "AQAB"' |
| 56 | + echo "✅ JWKS endpoint working" |
| 57 | +
|
| 58 | + - name: Check container logs |
| 59 | + if: always() |
| 60 | + run: docker logs juno-api-test |
| 61 | + |
| 62 | + - name: Cleanup |
| 63 | + if: always() |
| 64 | + run: docker rm -f juno-api-test |
| 65 | + |
| 66 | + # Move cache to avoid unbounded growth |
| 67 | + - name: Move cache |
| 68 | + run: | |
| 69 | + rm -rf /tmp/.buildx-cache |
| 70 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments