From 16fafe1a301ea961c2e6af7c30e498a6fa4ddc36 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 14 Dec 2023 04:22:47 +0100 Subject: [PATCH] to-database: Add CI configuration --- .github/dependabot.yml | 12 ++++++ .github/workflows/main.yml | 69 ++++++++++++++++++++++++++++++++ docker-compose.yml | 15 +++++++ to-database/init.sql => init.sql | 0 to-database/README.md | 6 +-- to-database/meltano.yml | 7 ++++ 6 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/main.yml create mode 100644 docker-compose.yml rename to-database/init.sql => init.sql (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..12d2c2d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 + +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e56c325 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,69 @@ +--- +name: "Tests" + +on: + pull_request: ~ + push: + branches: [ main ] + + # Allow job to be triggered manually. + workflow_dispatch: + + # Run job each night after CrateDB nightly has been published. + schedule: + - cron: '0 3 * * *' + +# Cancel in-progress jobs when pushing to the same branch. +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + + tests: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest"] + python-version: ["3.8", "3.11"] + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python-version }} + + name: Python ${{ matrix.python-version }} on OS ${{ matrix.os }} + steps: + + - name: Acquire sources + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + cache: 'pip' + cache-dependency-path: + requirements.txt + + - name: Set up PostgreSQL container. + run: | + docker compose -f docker-compose.yml up -d + + - name: Set up project + run: | + + # `setuptools 0.64.0` adds support for editable install hooks (PEP 660). + # https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6400 + pip install "setuptools>=64" --upgrade + + # Install requirements. + pip install -r requirements.txt + + - name: Verify "to-database" + run: | + cd to-database + meltano install + meltano run test diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ea31320 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +# Docker Compose file for pgvector -- open-source vector similarity search for PostgreSQL. +# https://github.com/pgvector/pgvector +--- +# docker compose -f docker-compose.yml up +version: "2.1" +services: + postgres: + image: ankane/pgvector:latest + command: postgres -c log_statement=all + environment: + POSTGRES_HOST_AUTH_METHOD: trust + volumes: + - ./init.sql:/docker-entrypoint-initdb.d/init.sql + ports: + - "5432:5432" diff --git a/to-database/init.sql b/init.sql similarity index 100% rename from to-database/init.sql rename to init.sql diff --git a/to-database/README.md b/to-database/README.md index f6b1118..effb32e 100644 --- a/to-database/README.md +++ b/to-database/README.md @@ -8,10 +8,7 @@ within `meltano.yml`. Run a PostgreSQL server with pgvector extension. ```shell -docker run --rm -it --publish=5432:5432 \ - --env "POSTGRES_HOST_AUTH_METHOD=trust" \ - --volume "$(pwd)/init.sql:/docker-entrypoint-initdb.d/init.sql" \ - ankane/pgvector postgres -c log_statement=all +docker compose -f docker-compose.yml up ``` In another shell, before running any `psql` command, define the authentication @@ -48,6 +45,7 @@ psql postgresql://postgres@localhost/ --command '\d load_jsonl_array_jsonb.array psql postgresql://postgres@localhost/ --command 'SELECT * from load_jsonl_array_jsonb.array_float;' ``` +Run smoke tests. ```shell meltano run tap-smoke-test target-postgres psql postgresql://postgres@localhost/ --command '\dt tap_smoke_test.*' diff --git a/to-database/meltano.yml b/to-database/meltano.yml index b359d8a..a66c9dc 100644 --- a/to-database/meltano.yml +++ b/to-database/meltano.yml @@ -78,3 +78,10 @@ plugins: config: sqlalchemy_url: postgresql://postgres@localhost/ add_record_metadata: true + +jobs: + - name: test + tasks: + - tap-smoke-test target-postgres + - load-jsonl-array-jsonb target-postgres + - load-jsonl-array-vector target-postgres