diff --git a/.github/actions/generate/action.yml b/.github/actions/generate/action.yml index c8b9a01..e5beda5 100644 --- a/.github/actions/generate/action.yml +++ b/.github/actions/generate/action.yml @@ -26,19 +26,35 @@ runs: using: "composite" steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch the entire history to avoid shallow repository issues - name: Download ETP file run : wget http://geosiris.com/wp-content/uploads/2022/09/etp/${{ inputs.etp-file-name }} -P ${{ github.workspace }} shell: bash - - name: Install dependencies - uses: ./.github/actions/prepare-poetry + - name: 🐍 Set up Python + uses: actions/setup-python@v4 with: python-version: ${{ inputs.python-version }} + - name: 📦 Install poetry + uses: abatilo/actions-poetry@v4 + with: + poetry-version: '2.1.1' + + - name: 💾 Cache Poetry dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pypoetry + key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + poetry-${{ runner.os }}- + - name: Install avro-to-python-etp run: | - poetry run python -m pip install avro-to-python-etp + poetry self add avro-to-python-etp + poetry install --no-interaction --no-root shell: bash - name: Translate avpr to avsc diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 70b7a8b..d3c981d 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -5,7 +5,8 @@ name: Tests on: - pull_request: + workflow_dispatch: + env: GENERATED_CODE_FOLDER: etptypes @@ -40,7 +41,7 @@ jobs: - name: Run pytest run: | cd ${{ env.GENERATED_CODE_FOLDER }} - poetry add pytest + poetry add -D pytest poetry run pytest --cov=etptypes --cov-report=xml --junitxml=pytest.xml shell: bash diff --git a/.github/workflows/pypi-test.yml b/.github/workflows/pypi-test.yml index 0cc762c..73670be 100644 --- a/.github/workflows/pypi-test.yml +++ b/.github/workflows/pypi-test.yml @@ -16,11 +16,14 @@ env: jobs: build: - name: Building generated code + name: Building and push generated code runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: 📥 Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch the entire history to avoid shallow repository issues - name: Generate code from avro-to-python-etp uses: ./.github/actions/generate @@ -29,66 +32,66 @@ jobs: dest-folder: ${{ env.GENERATED_CODE_FOLDER }} etp-file-name: ${{ secrets.ETP_FILE_NAME }} - - name: Install dependencies - uses: ./.github/actions/prepare-poetry + - name: 🐍 Set up Python + uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - toml-path: ${{ env.GENERATED_CODE_FOLDER }} + + - name: 💾 Cache Poetry dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pypoetry + key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + poetry-${{ runner.os }}- + + - name: 📦 Install poetry + uses: abatilo/actions-poetry@v4 + with: + poetry-version: '2.1.1' - name: Python Black run: | cd ${{ env.GENERATED_CODE_FOLDER }} + poetry add -D black poetry run black etptypes - - name: Build Etptypes-python + - name: 📦 Install poetry-dynamic-versioning + run: poetry self add "poetry-dynamic-versioning[plugin]" + + - name: 📥 Install dependencies + run: poetry install --no-interaction --no-root + + - name: Configure Poetry with PyPI repository and token + run: | + poetry config repositories.test-pypi https://test.pypi.org/legacy/ + poetry config pypi-token.test-pypi ${{ secrets.POETRY_PYPI_TEST_TOKEN_VALUE }} + + - name: 🛠️ Build the package run: | cd ${{ env.GENERATED_CODE_FOLDER }} + rm -rf dist rm pyproject.toml cp ${{ github.workspace }}/pyproject.toml . cp ${{ github.workspace }}/LICENSE . cp ${{ github.workspace }}/README.md . + if [ ! -f pyproject.toml ]; then echo "pyproject.toml not found"; exit 1; fi + if [ ! -f LICENSE ]; then echo "LICENSE not found"; exit 1; fi + if [ ! -f README.md ]; then echo "README.md not found"; exit 1; fi + poetry version $(poetry version | awk '{print $2}') poetry build - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - with: - name: dist-artifact - retention-days: 1 - path: | - ${{ env.GENERATED_CODE_FOLDER }}/dist - ${{ env.GENERATED_CODE_FOLDER }}/pyproject.toml - ${{ env.GENERATED_CODE_FOLDER }}/LICENSE - ${{ env.GENERATED_CODE_FOLDER }}/README.md - - publish: - needs: build - - name: Publish to PyPI-test - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Get build artifacts - uses: actions/download-artifact@v4 - with: - name: dist-artifact - path: ${{ env.GENERATED_CODE_FOLDER }} - - - name: Install dependencies - uses: ./.github/actions/prepare-poetry - with: - python-version: ${{ matrix.python-version }} - toml-path: ${{ env.GENERATED_CODE_FOLDER }} + # - name: Debug Publish Step + # run: | + # cd ${{ env.GENERATED_CODE_FOLDER }} + # pwd + # ls dist + # poetry version + # poetry config --list - - name: Upload to PyPI TEST + - name: 🚀 Publish to PyPI run: | cd ${{ env.GENERATED_CODE_FOLDER }} - poetry config repositories.test https://test.pypi.org/legacy/ - poetry config http-basic.test ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} ${{ secrets.POETRY_TEST_PYPI_TOKEN_PASSWORD}} - poetry publish --repository test \ No newline at end of file + # poetry version + # poetry publish --build --repository test-pypi + poetry publish --repository test-pypi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 927cef6..e2c43ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: 📥 Checkout repository + uses: actions/checkout@v4 - name: Generate code from avro-to-python-etp uses: ./.github/actions/generate @@ -29,18 +30,37 @@ jobs: dest-folder: ${{ env.GENERATED_CODE_FOLDER }} etp-file-name: ${{ secrets.ETP_FILE_NAME }} - - name: Install dependencies - uses: ./.github/actions/prepare-poetry + - name: 🐍 Set up Python + uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - toml-path: ${{ env.GENERATED_CODE_FOLDER }} + + - name: 💾 Cache Poetry dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pypoetry + key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + poetry-${{ runner.os }}- + + - name: 📦 Install poetry + uses: abatilo/actions-poetry@v4 + with: + poetry-version: '2.1.1' - name: Python Black run: | cd ${{ env.GENERATED_CODE_FOLDER }} + poetry add -D black poetry run black etptypes - - name: Build Etptypes-python + - name: 📦 Install poetry-dynamic-versioning + run: poetry self add "poetry-dynamic-versioning[plugin]" + + - name: 📥 Install dependencies + run: poetry install --no-interaction --no-root + + - name: 🛠️ Build the package run: | cd ${{ env.GENERATED_CODE_FOLDER }} rm pyproject.toml @@ -49,44 +69,8 @@ jobs: cp ${{ github.workspace }}/README.md . poetry build - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - with: - name: dist-artifact - retention-days: 1 - path: | - ${{ env.GENERATED_CODE_FOLDER }}/dist - ${{ env.GENERATED_CODE_FOLDER }}/pyproject.toml - ${{ env.GENERATED_CODE_FOLDER }}/LICENSE - ${{ env.GENERATED_CODE_FOLDER }}/README.md - - publish: - needs: build - - name: Publish to PyPI-test - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Get build artifacts - uses: actions/download-artifact@v4 - with: - name: dist-artifact - path: ${{ env.GENERATED_CODE_FOLDER }} - - - name: Install dependencies - uses: ./.github/actions/prepare-poetry - with: - python-version: ${{ matrix.python-version }} - toml-path: ${{ env.GENERATED_CODE_FOLDER }} - - - name: Upload to PyPI TEST + - name: 🚀 Publish to PyPI run: | cd ${{ env.GENERATED_CODE_FOLDER }} - poetry publish --username ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} --password ${{ secrets.POETRY_PYPI_TOKEN_PASSWORD}} \ No newline at end of file + poetry config pypi-token.pypi ${{ secrets.POETRY_PYPI_TOKEN_PASSWORD }} + poetry publish \ No newline at end of file diff --git a/.gitignore b/.gitignore index f5e74fa..c9e8178 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist/ output/ dist/ -tmp/ \ No newline at end of file +tmp/ +*.txt \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d793757..cb61a6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,48 +1,44 @@ -[tool.poetry] +[project] name = "etptypes" -version = "0.0.0" +dynamic = [ "version", "dependencies" ] description = "ETP python dev kit" authors = [ - "Lionel Untereiner ", - "Valentin Gauthier " + {name = "Lionel Untereiner", email = "lionel.untereiner@geosiris.com"} , + {name = "Valentin Gauthier", email = "valentin.gauthier@geosiris.com"} +] +maintainers = [ + {name = "Valentin Gauthier", email = "valentin.gauthier@geosiris.com"} ] license = "Apache-2.0" readme = "README.md" repository = "https://github.com/geosiris-technologies/etptypes-python" homepage = "http://www.geosiris.com" -classifiers = [ - "Intended Audience :: Information Technology", - "Intended Audience :: System Administrators", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python", - "Topic :: Internet", - "Topic :: Software Development :: Libraries :: Application Frameworks", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: Libraries", - "Topic :: Software Development", - "Typing :: Typed", - "Development Status :: 4 - Beta", - "Environment :: Web Environment", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Internet :: WWW/HTTP", -] keywords = ["ETP"] +requires-python = ">=3.9, <4.0" + +[tool.poetry] +version = "0.0.0" [tool.poetry.dependencies] -python = "^3.9, <4.0" pydantic = "<2.0.0" typingx = "^0.6.0" +[tool.poetry.group.dev.dependencies] +avro-to-python-etp = "^1.0.11" +poetry-dynamic-versioning = {extras = ["plugin"], version = "^1.8.2"} + [build-system] -requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] +requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.1"] build-backend = "poetry_dynamic_versioning.backend" +# [build-system] +# requires = ["poetry-core>=1.0.0"] +# build-backend = "poetry.core.masonry.api" + +[project.entry-points."poetry.plugin"] +"dynamic-versioning" = "poetry_dynamic_versioning.plugin" + +[tool.dunamai] +version_strategy = "post-release" [tool.poetry-dynamic-versioning] enable = true