Skip to content

Commit

Permalink
ci: add workflow to run PyTest
Browse files Browse the repository at this point in the history
  • Loading branch information
mkindahl committed Sep 26, 2023
1 parent 4c9e843 commit 31f4826
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file contains checks to run unit tests.
#
# Special thank you to pylint-dev project at GitHub where inspiration
# was taken.
name: unit tests

on:
pull_request:
branches:
- main
push:

jobs:
tests-linux:
name: run / ${{ matrix.python-version }} / Linux
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
services:
timescale:
image: timescale/timescaledb:latest-pg15
env:
POSTGRES_PASSWORD: xyzzy
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

timeout-minutes: 25
steps:
- uses: actions/[email protected]
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then
pip install -r requirements.txt
else
echo "No requirements.txt file found"
fi
- name: Run PyTest
env:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: xyzzy
PGPORT: 5432
run: python -m pytest
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
psycopg2>=2.9.2
9 changes: 6 additions & 3 deletions src/doctor/rules/compression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ class TestCompressionRules(unittest.TestCase):

def setUp(self):
"""Set up unit tests for compression rules."""
user = (os.getenv("PGUSER") or os.getlogin())
user = os.getenv("PGUSER")
host = os.getenv("PGHOST")
port = os.getenv("PGPORT") or "5432"
dbname = (os.getenv("PGDATABASE") or os.getlogin())
self.__conn = psycopg2.connect(dbname=dbname, user=user, host=host, port=port,
dbname = os.getenv("PGDATABASE")
password = os.getenv("PGPASSWORD")
print(f"connecting to {host}:{port} database {dbname}")
self.__conn = psycopg2.connect(dbname=dbname, user=user, host=host,
password=password, port=port,
cursor_factory=RealDictCursor)
table = Hypertable("conditions", "time", {
'time': "timestamptz not null",
Expand Down

0 comments on commit 31f4826

Please sign in to comment.