Skip to content

Commit

Permalink
Ci: refactor pip install logic for test and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong0618 authored and rdunklau committed Nov 4, 2022
1 parent 15dc2a4 commit af3673c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ jobs:
run: |
# Must be installed via the system
sudo apt install python3-bpfcc python3-pip
pip install setuptools toml
# Install requirements from pyproject.toml
python -c 'import toml; open("requirements.txt.tmp", "w").write("\n".join(toml.load(open("pyproject.toml"))["project"]["dependencies"]) + "\n")'
# Install lint requirements
python -c 'import toml; open("requirements.txt.tmp", "a").write("\n".join(toml.load(open("pyproject.toml"))["project"]["optional-dependencies"]["lint"]) + "\n")'
pip install -r requirements.txt.tmp
python -c "import bcc; print(bcc.__file__)"
pip install -U pip toml
pip install '.[lint]'
- id: pylint
run: pylint --rcfile .pylintrc src/ || pylint-exit $? -efail
Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,14 @@ jobs:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-${{ matrix.repo }} main ${{ matrix.postgresql_version }}" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt install postgresql-${{matrix.postgresql_version}} postgresql-${{matrix.postgresql_version}}-dbgsym
sudo pip install setuptools toml
sudo pip install -U pip toml
# Install requirements from pyproject.toml
python -c 'import toml; open("requirements.txt.tmp", "w").write("\n".join(toml.load(open("pyproject.toml"))["project"]["dependencies"]) + "\n")'
# Install lint requirements
python -c 'import toml; open("requirements.txt.tmp", "a").write("\n".join(toml.load(open("pyproject.toml"))["project"]["optional-dependencies"]["lint"]) + "\n")'
sudo pip install -r requirements.txt.tmp
sudo pip install '.[test]'
python -c "import bcc; print(bcc.__file__)"
- id: tests
run: |
sudo PYTHONPATH=$(pwd)/src pytest --postgresql-exec /usr/lib/postgresql/${{matrix.postgresql_version}}/bin/pg_ctl --cov --cov-report=xml
sudo pytest --postgresql-exec /usr/lib/postgresql/${{matrix.postgresql_version}}/bin/pg_ctl --cov --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand Down Expand Up @@ -85,15 +81,12 @@ jobs:
sudo apt install python3-bpfcc python3-pip libunwind-dev linux-headers-$(uname -r)
# Also install it in the host, for the tests running outside the
# container
sudo pip install setuptools toml
python -c 'import toml; open("requirements.txt.tmp", "w").write("\n".join(toml.load(open("pyproject.toml"))["project"]["dependencies"]) + "\n")'
# Install lint requirements
python -c 'import toml; open("requirements.txt.tmp", "a").write("\n".join(toml.load(open("pyproject.toml"))["project"]["optional-dependencies"]["lint"]) + "\n")'
sudo pip install -r requirements.txt.tmp
sudo pip install -U pip toml
sudo pip install '.[test]'
- id: fedora_tests
run: |
sudo PYTHONPATH=$(pwd)/src pytest --postgresql-host 172.16.0.1 --container fedora --cov --cov-report=xml
sudo pytest --postgresql-host 172.16.0.1 --container fedora --cov --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ lint = [
'black',
'isort',
'mypy',
'psycopg',
'pylint',
'pylint-exit',
]

test = [
'psycopg',
'pytest',
'pytest-coverage',
'pytest-postgresql',
Expand Down

0 comments on commit af3673c

Please sign in to comment.