9 #100
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
# taking as reference: https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml | |
name: Module Tests | |
on: [push, merge_group] | |
env: | |
PG_USER: test_user | |
PGPASSWORD: password | |
PG_DATABASE: test_database | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.10", "3.11"] | |
services: | |
postgres: | |
image: postgres:14.1-alpine | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_USER: ${{ env.PG_USER }} | |
POSTGRES_PASSWORD: ${{ env.PGPASSWORD }} | |
POSTGRES_DB: ${{ env.PG_DATABASE }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
clickhouse: | |
image: clickhouse/clickhouse-server | |
env: | |
CLICKHOUSE_DB: ${{ env.PG_DATABASE }} | |
CLICKHOUSE_USER: ${{ env.PG_USER }} | |
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1 | |
CLICKHOUSE_PASSWORD: ${{ env.PGPASSWORD }} | |
ports: | |
- "8123:8123" | |
- "9000:9000" | |
steps: | |
- uses: actions/checkout@v3 | |
# Install ClickHouse client | |
- name: Install ClickHouse client | |
run: curl https://clickhouse.com/ | sh | |
- name: Init psql database with .sql | |
run: | | |
psql -h localhost -U ${{ env.PG_USER }} -d ${{ env.PG_DATABASE }} -a -f sql/docker_init_postgresql_test_db.sql | |
- name: Init clickhouse database with .sql | |
run: | | |
./clickhouse client --user ${{ env.PG_USER }} --password ${{ env.PG_PASSWORD }} --multiquery < sql/docker_init_clickhouse_test_db.sql | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install flake8 | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Test with unittest | |
run: | | |
python -m unittest tests/test_module.py | |