Skip to content

Commit

Permalink
feat: add ci config
Browse files Browse the repository at this point in the history
  • Loading branch information
jgpruitt committed Oct 8, 2024
1 parent 09883c9 commit 2cf59a2
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on: [push, pull_request, workflow_dispatch]
permissions:
contents: read

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Verify Docker installation
run: |
docker --version
docker info
- name: Build Docker image
run: make docker-build

- name: Run Docker container
run: make docker-run

- name: Build
run: docker exec pgai make build

- name: Lint SQL and Python
run: docker exec pgai make lint

#- name: Check Python Formatting
# run: docker exec pgai make format-py

- name: Install extension and vectorizer
run: |
docker exec pgai make install
docker exec pgai make install-vec
- name: Run test server
run: docker exec -d pgai make test-server

- name: Run tests
run: docker exec pgai make test

- name: Stop and remove Docker container
run: |
make docker-stop
make docker-rm
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RUN set -e; \
rm -rf /build/timescaledb

# install pgvectorscale
ARG RUSTFLAGS
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN set -e; \
Expand All @@ -44,7 +45,10 @@ RUN set -e; \
mkdir -p /build/pgvectorscale; \
git clone --branch 0.3.0 https://github.com/timescale/pgvectorscale /build/pgvectorscale; \
cd /build/pgvectorscale/pgvectorscale; \
cargo pgrx install --release; \
if [ -n "$RUSTFLAGS" ]; then \
export RUSTFLAGS=${RUSTFLAGS}; \
fi; \
cargo pgrx install --release --features pg${PG_MAJOR}; \
rm -rf /build/pgvectorscale

# install pgspot
Expand Down
9 changes: 7 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import os
import platform
import subprocess
import shutil
import sys
Expand Down Expand Up @@ -59,7 +60,7 @@ def prior_versions() -> list[str]:
return versions()[1:] if len(versions()) > 1 else []


def pg_major() -> str:
def pg_major() -> str | None:
return os.getenv("PG_MAJOR")


Expand Down Expand Up @@ -556,8 +557,12 @@ def format_py() -> None:


def docker_build() -> None:
if platform.machine().lower() in {'i386', 'i686', 'x86_64'}:
rust_flags = "--build-arg RUSTFLAGS='-C target-feature=+avx2,+fma'"
else:
rust_flags = ""
subprocess.run(
f"""docker build --build-arg PG_MAJOR={pg_major()} -t pgai .""",
f"""docker build --build-arg PG_MAJOR={pg_major()} {rust_flags} -t pgai .""",
shell=True,
check=True,
env=os.environ,
Expand Down
2 changes: 1 addition & 1 deletion src/vectorizer/test/test_vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from psycopg.rows import namedtuple_row

from src.vectorizer.vectorizer import cli, vectorizer
from src.vectorizer.vectorizer import cli

# skip tests in this module if disabled
enable_vectorizer_tool_tests = os.getenv("ENABLE_VECTORIZER_TOOL_TESTS")
Expand Down

0 comments on commit 2cf59a2

Please sign in to comment.