Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci: refactor pip install logic for test and lint fix #26 #27

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install the latest pip contains setuptools

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great I didn't know about this !

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need set PYTHONPATH here since we install the pgtracer package


- 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