|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pull-requests: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + changes: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + go: ${{ steps.filter.outputs.go }} |
| 18 | + web: ${{ steps.filter.outputs.web }} |
| 19 | + website: ${{ steps.filter.outputs.website }} |
| 20 | + docker: ${{ steps.filter.outputs.docker }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v6 |
| 23 | + - uses: dorny/paths-filter@v3 |
| 24 | + id: filter |
| 25 | + with: |
| 26 | + filters: | |
| 27 | + go: |
| 28 | + - '**/*.go' |
| 29 | + - 'go.mod' |
| 30 | + - 'go.sum' |
| 31 | + - 'Makefile' |
| 32 | + web: |
| 33 | + - 'web/**' |
| 34 | + website: |
| 35 | + - 'website/**' |
| 36 | + docker: |
| 37 | + - 'docker/**' |
| 38 | + - '**/*.go' |
| 39 | + - 'go.mod' |
| 40 | + - 'go.sum' |
| 41 | + - 'web/**' |
| 42 | + - 'website/**' |
| 43 | +
|
| 44 | + go-checks: |
| 45 | + needs: changes |
| 46 | + if: needs.changes.outputs.go == 'true' |
| 47 | + runs-on: ubuntu-latest |
| 48 | + services: |
| 49 | + postgres: |
| 50 | + image: postgres:16 |
| 51 | + env: |
| 52 | + POSTGRES_USER: codesearch |
| 53 | + POSTGRES_PASSWORD: codesearch |
| 54 | + POSTGRES_DB: codesearch |
| 55 | + ports: |
| 56 | + - 5432:5432 |
| 57 | + options: >- |
| 58 | + --health-cmd "pg_isready -U codesearch" |
| 59 | + --health-interval 10s |
| 60 | + --health-timeout 5s |
| 61 | + --health-retries 5 |
| 62 | + redis: |
| 63 | + image: redis:7 |
| 64 | + ports: |
| 65 | + - 6379:6379 |
| 66 | + options: >- |
| 67 | + --health-cmd "redis-cli ping" |
| 68 | + --health-interval 10s |
| 69 | + --health-timeout 5s |
| 70 | + --health-retries 5 |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v6 |
| 73 | + - uses: actions/setup-go@v6 |
| 74 | + with: |
| 75 | + go-version-file: go.mod |
| 76 | + - name: Install golangci-lint |
| 77 | + uses: golangci/golangci-lint-action@v9 |
| 78 | + with: |
| 79 | + args: ./... |
| 80 | + - name: Run go vet |
| 81 | + run: make vet |
| 82 | + - name: Run tests |
| 83 | + env: |
| 84 | + CS_DATABASE_URL: postgres://codesearch:codesearch@localhost:5432/codesearch?sslmode=disable |
| 85 | + CS_REDIS_ADDR: localhost:6379 |
| 86 | + run: make test |
| 87 | + |
| 88 | + web-checks: |
| 89 | + needs: changes |
| 90 | + if: needs.changes.outputs.web == 'true' |
| 91 | + runs-on: ubuntu-latest |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v6 |
| 94 | + - uses: oven-sh/setup-bun@v2 |
| 95 | + - name: Install dependencies |
| 96 | + run: cd web && bun install |
| 97 | + - name: Lint |
| 98 | + run: cd web && bun lint |
| 99 | + - name: Test |
| 100 | + run: cd web && bun run test:run |
| 101 | + |
| 102 | + website-checks: |
| 103 | + needs: changes |
| 104 | + if: needs.changes.outputs.website == 'true' |
| 105 | + runs-on: ubuntu-latest |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@v6 |
| 108 | + - uses: oven-sh/setup-bun@v2 |
| 109 | + - name: Install dependencies |
| 110 | + run: cd website && bun install |
| 111 | + - name: Build |
| 112 | + run: cd website && bun run build |
| 113 | + |
| 114 | + docker-build: |
| 115 | + needs: changes |
| 116 | + if: needs.changes.outputs.docker == 'true' |
| 117 | + runs-on: ubuntu-latest |
| 118 | + strategy: |
| 119 | + fail-fast: false |
| 120 | + matrix: |
| 121 | + include: |
| 122 | + - dockerfile: docker/api.Dockerfile |
| 123 | + image: code-search-api |
| 124 | + - dockerfile: docker/indexer.Dockerfile |
| 125 | + image: code-search-indexer |
| 126 | + - dockerfile: docker/web.Dockerfile |
| 127 | + image: code-search-web |
| 128 | + - dockerfile: docker/zoekt.Dockerfile |
| 129 | + image: code-search-zoekt |
| 130 | + - dockerfile: docker/zoekt-refresh.Dockerfile |
| 131 | + image: code-search-zoekt-refresh |
| 132 | + - dockerfile: docker/indexer-scip.Dockerfile |
| 133 | + image: code-search-indexer-scip |
| 134 | + - dockerfile: docker/website.Dockerfile |
| 135 | + image: code-search-website |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v6 |
| 138 | + with: |
| 139 | + lfs: ${{ matrix.image == 'code-search-website' }} |
| 140 | + - uses: docker/setup-buildx-action@v4 |
| 141 | + - name: Build ${{ matrix.image }} |
| 142 | + uses: docker/build-push-action@v7 |
| 143 | + with: |
| 144 | + context: . |
| 145 | + file: ${{ matrix.dockerfile }} |
| 146 | + push: false |
| 147 | + cache-from: type=gha |
| 148 | + cache-to: type=gha,mode=max |
0 commit comments