Skip to content
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
81 changes: 0 additions & 81 deletions .github/actions/unittests/action.yml

This file was deleted.

25 changes: 8 additions & 17 deletions .github/workflows/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- 'feature/*'

permissions:
contents: read
checks: write

jobs:
pre-commit:
name: Run pre-commit
Expand All @@ -16,25 +20,12 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.9'

- name: Run pre-commit
uses: pre-commit/action@v3.0.1

unittests:
name: Run tests
runs-on: ubuntu-22.04

strategy:
matrix:
python-version: [3.7.16, 3.8.18, 3.9.18, "3.10.13", 3.11.5, 3.12.0, 3.13.4]
fail-fast: false

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

- name: Run unittests
uses: ./.github/actions/unittests
with:
python-version: ${{ matrix.python-version }}
uses: ./.github/workflows/run-unittests.yml
with:
python-versions: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
92 changes: 9 additions & 83 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,102 +6,28 @@ on:
- 'master'
workflow_dispatch:

permissions:
contents: write
id-token: write
checks: write

jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-22.04

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

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.9'

- name: Run pre-commit
uses: pre-commit/action@v3.0.1

unittests:
name: Run unittests
runs-on: ubuntu-22.04

strategy:
matrix:
python-version: [3.7.16, 3.8.18, 3.9.18, "3.10.13", 3.11.5, 3.12.0, 3.13.4]
fail-fast: false

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

- name: Run unittests
uses: ./.github/actions/unittests
with:
python-version: ${{ matrix.python-version }}

prerelease:
name: Pre-release (test-pypi)
needs: unittests
if: success()
runs-on: ubuntu-22.04

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

- name: Build package
run: python setup.py sdist bdist_wheel

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: py-dependency-injection
path: dist/

- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

release:
name: Release (pypi)
needs: prerelease
if: success() && (github.event_name == 'workflow_dispatch')
runs-on: ubuntu-22.04

steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: py-dependency-injection
path: dist/

- name: Extract version from setup.py
id: extract-version
run: |
version=$(grep -Eo "version=['\"]([^'\"]+)['\"]" setup.py | awk -F"'" '{print $2}')
echo "Using version: $version"
echo "::set-output name=RELEASE_VERSION::$version"

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
repository_url: https://upload.pypi.org/legacy/
skip_existing: false

- name: Set up Git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"

- name: Create and push tag
run: |
git tag -a v${{ steps.extract-version.outputs.RELEASE_VERSION }} -m "Release version v${{ steps.extract-version.outputs.RELEASE_VERSION }}"
git push origin v${{ steps.extract-version.outputs.RELEASE_VERSION }}
uses: ./.github/workflows/run-unittests.yml
with:
python-versions: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
55 changes: 55 additions & 0 deletions .github/workflows/run-unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run Unittests

on:
workflow_call:
inputs:
python-versions:
required: true
type: string

permissions:
contents: read
checks: write

jobs:
unittests:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ${{ fromJson(inputs.python-versions) }}
fail-fast: false

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "2.1.4"

- name: Install dependencies
run: poetry install --with dev

- name: Run unittests
run: |
mkdir -p reports
PYTHONPATH=./src:./tests poetry run pytest ./tests/unit_test --junitxml=reports/report.xml

- name: Upload JUnit report
uses: actions/upload-artifact@v4
with:
name: junit-report-${{ matrix.python-version }}
path: reports/report.xml

- name: Publish test report
uses: dorny/test-reporter@v1
with:
name: Unit Tests Report (${{ matrix.python-version }})
path: reports/report.xml
reporter: java-junit
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
hooks:
- id: black
args: ["--line-length=88"] # Adjust line length as needed
language_version: python3.7
language_version: python3.9
- repo: https://github.com/pycqa/flake8
rev: 4.0.1 # Use the latest version
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7
3.9
Loading