Skip to content

build: rye needs python-version #121

build: rye needs python-version

build: rye needs python-version #121

Workflow file for this run

name: CI (API)
env:
VENV_PATH: "~/.venv-api"
on:
push:
paths:
- api/**
- .github/workflows/ci_api.yml
pull_request:
paths:
- api/**
- .github/workflows/ci_api.yml
defaults:
run:
working-directory: api
jobs:
code_quality:
name: Code Quality
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install the latest version of rye
uses: eifinger/setup-rye@v4
with:
enable-cache: true
- name: Install confluent-kafka prerequisites
run: |
sudo apt-get install --yes librdkafka-dev python3-dev
- name: Install psycopg2 prerequisites
run: |
sudo apt-get install --yes build-essential libpq-dev
- name: Sync dependencies
run: rye sync
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@dprint
- name: Lint
# currently cli is not-maintained
run: just check
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.11.3']
# container operations are only supported on Linux runners
os: [ubuntu-22.04]
services:
# it is hard to setup locally installed postgres,
# such as setting the password.
# TravisCI and build.sr.ht use empty password as default
# but that doesn't work with Github action.
# you need to work with `pg_hba.conf` or using `sudo -u postgres`
# but the latter force you to install every dependency in in root PATH.
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
# set the password without messing with `pg_hba.conf`
POSTGRES_PASSWORD: postgres
# create default db
POSTGRES_DB: knotdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install the latest version of rye
uses: eifinger/setup-rye@v4
with:
enable-cache: true
- name: Install confluent-kafka prerequisites
run: |
sudo apt-get install --yes librdkafka-dev python3-dev
- name: Install psycopg2 prerequisites
run: |
sudo apt-get install --yes build-essential libpq-dev
- name: Install dependencies
run: |
poetry install --no-interaction --no-root
- uses: taiki-e/install-action@just
- name: Unit tests
run: |
just test-unit
- name: Check DB version
# pass `-h localhost` to use TCP connection. Otherwise, it will talk to locally installed postgres
run: psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -U postgres --version
env:
# to avoid having password prompt
PGPASSWORD: postgres
- name: Create DB schema
run: |
psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -U postgres knotdb < tests/integration/test_schema.sql
env:
PGPASSWORD: postgres
- name: Prepare for Integration tests
run: |
# use default location, instead setting the `RESTKNOT_CONFIG_FILE`
cp config.example.yml config.yml
- name: Integration tests
run: |
just test