|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +permissions: {} |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + name: Lint |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 10 |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 23 | + with: |
| 24 | + persist-credentials: false |
| 25 | + - uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 |
| 26 | + - run: golangci-lint run |
| 27 | + |
| 28 | + build: |
| 29 | + name: Build |
| 30 | + runs-on: ubuntu-latest |
| 31 | + timeout-minutes: 10 |
| 32 | + permissions: |
| 33 | + contents: read |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 36 | + with: |
| 37 | + persist-credentials: false |
| 38 | + - uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 |
| 39 | + - run: go build -o server ./cmd/server |
| 40 | + |
| 41 | + unit-test: |
| 42 | + name: Unit Test |
| 43 | + runs-on: ubuntu-latest |
| 44 | + timeout-minutes: 10 |
| 45 | + permissions: |
| 46 | + contents: read |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 49 | + with: |
| 50 | + persist-credentials: false |
| 51 | + - uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 |
| 52 | + - run: go test ./... |
| 53 | + |
| 54 | + e2e-test: |
| 55 | + name: E2E Test |
| 56 | + runs-on: ubuntu-latest |
| 57 | + timeout-minutes: 15 |
| 58 | + permissions: |
| 59 | + contents: read |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 62 | + with: |
| 63 | + persist-credentials: false |
| 64 | + - uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 |
| 65 | + - name: Start sandbox service |
| 66 | + run: docker compose up --build -d |
| 67 | + - name: Wait for service to be ready |
| 68 | + run: | |
| 69 | + for i in $(seq 1 30); do |
| 70 | + if curl -s -o /dev/null http://localhost:8080/; then |
| 71 | + echo "Service is ready" |
| 72 | + exit 0 |
| 73 | + fi |
| 74 | + echo "Waiting for service... ($i/30)" |
| 75 | + sleep 2 |
| 76 | + done |
| 77 | + echo "Service failed to start" |
| 78 | + exit 1 |
| 79 | + - name: Run E2E tests |
| 80 | + run: go test -tags e2e ./e2e/... |
| 81 | + - name: Show logs on failure |
| 82 | + if: failure() |
| 83 | + run: docker compose logs |
0 commit comments