From 23fa62eaaa728d05855f8e277cdaf8816d11fac5 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Sun, 12 Jul 2026 18:17:58 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20ci:=20add=20matrix=20testing,=20?= =?UTF-8?q?typecheck/lint/format=20gates,=20and=20docker=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50253aa..868d866 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,19 +3,31 @@ name: CI on: push: branches: ["main"] + tags: ["v*.*.*"] pull_request: branches: ["main"] jobs: test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + bun-version: ["latest", "1.2"] steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v2 with: - bun-version: latest - - run: bun install - - run: bun test + bun-version: ${{ matrix.bun-version }} + - run: bun install --frozen-lockfile + - name: Typecheck + run: bun run typecheck + - name: Lint + run: bun run lint + - name: Format check + run: bunx biome format . + - name: Unit tests + run: bun test docker: runs-on: ubuntu-latest @@ -27,16 +39,52 @@ jobs: - uses: actions/checkout@v4 - name: Set lowercase owner id: owner - run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT + run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" + + - name: Compute image tags + id: meta + run: | + TAGS="ghcr.io/${{ steps.owner.outputs.owner }}/test-ip:latest" + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + VERSION="${{ github.ref_name }}" + TAGS="ghcr.io/${{ steps.owner.outputs.owner }}/test-ip:${VERSION},ghcr.io/${{ steps.owner.outputs.owner }}/test-ip:latest" + fi + echo "tags=$TAGS" >> "$GITHUB_OUTPUT" + + - name: Build image (local, for smoke test) + uses: docker/build-push-action@v6 + with: + context: . + load: true + tags: test-ip:ci + + - name: Smoke test image + run: | + docker run -d --name test-ip -p 3000:3000 test-ip:ci + for i in $(seq 1 20); do + if curl -fsS -H "Accept: application/json" http://localhost:3000/ > response.json; then + break + fi + sleep 1 + done + cat response.json + grep -q '"ip"' response.json + grep -q '"headers"' response.json + docker logs test-ip + docker stop test-ip + - name: Log in to Container Registry + if: github.event_name == 'push' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ steps.owner.outputs.owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + + - name: Push image + if: github.event_name == 'push' uses: docker/build-push-action@v6 with: context: . push: true - tags: ghcr.io/${{ steps.owner.outputs.owner }}/test-ip:latest \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }}