Skip to content

Commit

Permalink
feat!: use poetry instead of setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Jul 3, 2024
1 parent 847ef5a commit f8bcfa1
Show file tree
Hide file tree
Showing 18 changed files with 1,795 additions and 1,161 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,31 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
runs-on: ${{ matrix.os }}
name: Run tests on Python ${{ matrix.python-version }}, on ${{ matrix.os }}
name: Test on Python ${{ matrix.python-version }}, on ${{ matrix.os }}
timeout-minutes: 45
concurrency:
group: ${{ github.workflow }}-run-unit-tests-${{ matrix.python-version }}-${{ matrix.os }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Checkout code
- name: Checkout Code
uses: actions/checkout@v4

- name: Restore Python dependencies
run: |
pip install -r requirements-dev.txt
- name: Install Poetry
run: pip install -r requirements.txt

- name: Restore Development Environment
run: poetry install

- name: Test
run: python -m unittest discover -s test -t .
shell: bash
run: poetry run poe test

deploy:
needs:
- test
uses: ./.github/workflows/deploy.yml
if: github.ref_name == 'master' || github.ref_name == 'main'
secrets: inherit
15 changes: 7 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
group: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # all history
Expand All @@ -21,13 +21,11 @@ jobs:
id: get-python-version
run: echo version=$(python setup.py get_minimum_python_version | tail -n 1) >> $GITHUB_OUTPUT

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ steps.get-python-version.outputs.version }}
- name: Install Poetry
run: pip install -r requirements.txt

- name: Restore Python dependencies
run: pip install -r requirements-dev.txt
- name: Restore Development Environment
run: poetry install

- name: Change default logging level
run: sed -i -e 's/DEBUG/WARN/g' my_project/__init__.py
Expand All @@ -48,4 +46,5 @@ jobs:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
RELEASE_DRY_RUN: ${{ contains(github.repository, 'template') }}
RELEASE_TEST_PYPI: ${{ contains(github.repository, 'template') }}
RELEASE_DRY_RUN: ${{ github.ref_name != 'master' && github.ref_name != 'main' }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION
node_modules/

tmp/
.idea/
Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./test",
"-p",
"*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"python.testing.autoTestDiscoverOnSaveEnabled": true,
}
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

8 changes: 8 additions & 0 deletions my_project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ def my_method(self):
return "Hello World"


def main():
# this is the main module of your app
# it is only required if your project must be runnable
# this is the script to be executed whenever some users writes `python -m my_project` on the command line, eg.
x = MyClass().my_method()
print(x)


# let this be the last line of this file
logger.info("my_project loaded")
6 changes: 1 addition & 5 deletions my_project/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import my_project

# this is the main module of your app
# it is only required if your project must be runnable
# this is the script to be executed whenever some users writes `python -m my_project` on the command line, eg.
x = my_project.MyClass().my_method()
print(x)
my_project.main()
Loading

0 comments on commit f8bcfa1

Please sign in to comment.