From 00bd386ea01dacd3f6592fce9bbac5f233d9df5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Linhart?= Date: Wed, 26 Jun 2024 21:12:31 +0200 Subject: [PATCH] Improve and streamline Python development --- .github/workflows/python.yml | 15 ++++++--------- pyproject.toml | 3 +++ python/requirements.txt | 4 ---- requirements-dev.txt | 6 ++++++ 4 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 python/requirements.txt create mode 100644 requirements-dev.txt diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index f7ed8ab..e2e344f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -21,23 +21,18 @@ jobs: python-version: ${{ matrix.python-version }} cache: pip - name: Install dependencies - run: | - pip install ruff pytest - (cd python && pip install -r requirements.txt) + run: pip install -r requirements-dev.txt - name: Check formatting with Ruff run: ruff format --check . - name: Lint with Ruff run: ruff check . - name: Test with pytest - run: pytest python + run: pytest publish: name: Build and publish package needs: test if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest - defaults: - run: - working-directory: python steps: - uses: actions/checkout@v3 - name: Set up Python 3.x @@ -46,11 +41,13 @@ jobs: python-version: "3.x" cache: pip - name: Install dependencies - run: pip install --upgrade build twine + run: pip install -r requirements-dev.txt - name: Build package run: python -m build + working-directory: python - name: Publish package + run: twine upload dist/* + working-directory: python env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - run: twine upload dist/* diff --git a/pyproject.toml b/pyproject.toml index b3f6f91..2a0d69c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,3 +11,6 @@ split-on-trailing-comma = false [tool.ruff.format] skip-magic-trailing-comma = true + +[tool.pytest.ini_options] +addopts = ["--import-mode=importlib"] diff --git a/python/requirements.txt b/python/requirements.txt deleted file mode 100644 index a0ecc34..0000000 --- a/python/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -pulumi>=3.0.0,<4.0.0 -pulumi_aws>=5.0.0,<7.0.0 - --e . \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..49774c5 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,6 @@ +build==1.2.1 +pytest==8.2.2 +ruff==0.4.10 +twine==5.1.1 + +-e python \ No newline at end of file