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

Standardize development dependencies / refactor GHA workflow #153

Merged
merged 6 commits into from
Jun 18, 2024
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
32 changes: 9 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,20 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Show ref
run: echo "$GITHUB_REF"
- name: Build/pull Docker images
run: |
echo "$GITHUB_REF"
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
env:
DEBIAN_FRONTEND: noninteractive
BOTO_CONFIG: /dev/null
AWS_ACCESS_KEY_ID: banana
AWS_SECRET_ACCESS_KEY: bananacake
run: |
sudo rm -f /etc/boto.cfg
sudo apt-get -qq update
sudo apt-get install -y libicu-dev
make dev
pip install -e ".[dev]"
docker compose build shell
docker compose pull rabbitmq
- name: Run the code format check
run: make format-check
run: docker compose run --rm shell make format-check
- name: Run the linter
run: make lint
run: docker compose run --rm shell make lint
- name: Run the tests
run: |
make test
# Some tests rely on the package being installed
run: docker compose run --rm shell bash -c "make install && make test-local"
- name: Build a distribution
run: |
python setup.py sdist bdist_wheel
run: docker compose run --rm shell python3 setup.py sdist bdist_wheel
- name: Publish a Python distribution to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
20 changes: 5 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
FROM python:3.12-slim

RUN apt-get -qq -y update \
&& apt-get -qq -y install python3-pip \
pkg-config libicu-dev \
&& apt-get -qq -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN pip3 install --no-binary=:pyicu: pyicu

ENV LANG='en_US.UTF-8'
RUN apt-get update
RUN apt-get install make

COPY . /opt/servicelayer
WORKDIR /opt/servicelayer
RUN pip3 install -q --no-cache-dir -e /opt/servicelayer[dev]
RUN pip3 install -r requirements.txt
RUN make dev

CMD /bin/bash
CMD /bin/bash
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ build-docker:

install:
pip install -q -e .
pip install -q twine coverage nose moto boto3

dev:
python3 -m pip install --upgrade pip setuptools
python3 -m pip install -q -r requirements.txt
python3 -m pip install -q -r requirements-dev.txt

test:
docker-compose run --rm shell pytest --cov=servicelayer
docker compose run --rm shell make test-local

test-local:
pytest --cov=servicelayer
Copy link
Contributor

Choose a reason for hiding this comment

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

test:
	docker-compose run --rm shell pytest --cov=servicelayer
test-local:
	pytest --cov=servicelayer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


lint:
ruff check .
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ pytest-env==1.1.3
pytest-cov==5.0.0
pytest-mock==3.14.0
wheel==0.43.0
twine==4.0.2
moto==4.2.14
boto3==1.34.32
8 changes: 0 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@
"grpcio >= 1.32.0, <2.0.0",
"google-cloud-storage >= 1.31.0, < 3.0.0",
],
"dev": [
"twine",
"moto < 5",
"boto3 >= 1.11.9, <2.0.0",
"pytest >= 3.6",
"coverage",
"pytest-cov",
],
},
test_suite="tests",
entry_points={
Expand Down
2 changes: 2 additions & 0 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

class ExtensionTest(TestCase):
def test_extensions(self):
# This relies on the servicelayer package being installed as `get_extensions`
# ultimately reads entrypoints from the egg info
exts = get_extensions("servicelayer.test")
assert len(exts), exts
assert get_extensions in exts, exts