build(agent): migrate from Poetry to Rye #116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11.3' | |
- name: Cache poetry install | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local | |
key: poetry | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ${{ env.VENV_PATH }} | |
- name: Cache deps | |
id: cache-deps | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.VENV_PATH }} | |
key: venv-api-${{ hashFiles('**/poetry.lock') }} | |
- 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 | |
- uses: taiki-e/install-action@dprint | |
- name: Lint | |
# currently cli is not-maintained | |
run: | | |
just fmt-check | |
just lint | |
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: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache poetry install | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local | |
key: poetry | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
virtualenvs-path: ${{ env.VENV_PATH }} | |
- name: Cache deps | |
id: cache-deps | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.VENV_PATH }} | |
key: venv-api-${{ hashFiles('**/poetry.lock') }} | |
- 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 |