|
| 1 | +name: CI Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + tags: |
| 8 | + - "v*" |
| 9 | + |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + - uses: actions/setup-python@v5 |
| 16 | + with: |
| 17 | + python-version: "3.12" |
| 18 | + - run: pip install black isort ruff |
| 19 | + - run: black --check . |
| 20 | + - run: isort --check-only . |
| 21 | + - run: ruff check . |
| 22 | + |
| 23 | + build: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + needs: lint |
| 26 | + outputs: |
| 27 | + image_tag: ${{ steps.meta.outputs.sha_tag }} |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - name: Generate tag |
| 31 | + id: meta |
| 32 | + run: echo "sha_tag=sha-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT |
| 33 | + - name: Build and tag Docker image |
| 34 | + uses: docker/build-push-action@v5 |
| 35 | + with: |
| 36 | + context: . |
| 37 | + file: ./Containerfile |
| 38 | + load: true |
| 39 | + tags: test-image:${{ steps.meta.outputs.sha_tag }} |
| 40 | + |
| 41 | + test: |
| 42 | + needs: [lint, build] |
| 43 | + runs-on: ubuntu-latest |
| 44 | + strategy: |
| 45 | + matrix: |
| 46 | + db: [pgvector, redis, elasticsearch, qdrant] |
| 47 | + services: |
| 48 | + pgvector: |
| 49 | + image: ankane/pgvector |
| 50 | + ports: |
| 51 | + - 5432:5432 |
| 52 | + env: |
| 53 | + POSTGRES_USER: user |
| 54 | + POSTGRES_PASSWORD: pass |
| 55 | + POSTGRES_DB: mydb |
| 56 | + redis: |
| 57 | + image: redis/redis-stack-server:6.2.6-v19 |
| 58 | + ports: |
| 59 | + - 6379:6379 |
| 60 | + elasticsearch: |
| 61 | + image: elasticsearch:8.11.1 |
| 62 | + ports: |
| 63 | + - 9200:9200 |
| 64 | + env: |
| 65 | + discovery.type: single-node |
| 66 | + xpack.security.enabled: true |
| 67 | + ELASTIC_PASSWORD: changeme |
| 68 | + ES_JAVA_OPTS: "-Xms512m -Xmx512m" |
| 69 | + qdrant: |
| 70 | + image: qdrant/qdrant |
| 71 | + ports: |
| 72 | + - 6333:6333 |
| 73 | + |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v4 |
| 76 | + - name: Wait for DB to start |
| 77 | + run: sleep 30 |
| 78 | + - name: Run embed job |
| 79 | + run: docker run --rm --network host test-image:latest |
| 80 | + |
| 81 | + release: |
| 82 | + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') |
| 83 | + runs-on: ubuntu-latest |
| 84 | + needs: [lint, build, test] |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v4 |
| 87 | + - name: Log in to Quay.io |
| 88 | + uses: docker/login-action@v3 |
| 89 | + with: |
| 90 | + registry: quay.io |
| 91 | + username: ${{ secrets.QUAY_USERNAME }} |
| 92 | + password: ${{ secrets.QUAY_PASSWORD }} |
| 93 | + - name: Tag and push image |
| 94 | + run: | |
| 95 | + docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/dminnear/vector-embedder:${{ needs.build.outputs.image_tag }} |
| 96 | +
|
| 97 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 98 | + docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/dminnear/vector-embedder:${GITHUB_REF#refs/tags/} |
| 99 | + docker push quay.io/dminnear/vector-embedder:${GITHUB_REF#refs/tags/} |
| 100 | + elif [[ $GITHUB_REF == refs/heads/main ]]; then |
| 101 | + docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/dminnear/vector-embedder:latest |
| 102 | + docker push quay.io/dminnear/vector-embedder:latest |
| 103 | + fi |
| 104 | +
|
| 105 | + docker push quay.io/dminnear/vector-embedder:${{ needs.build.outputs.image_tag }} |
0 commit comments