Skip to content

Add unit tests for user-related models CRUD operations #104

Add unit tests for user-related models CRUD operations

Add unit tests for user-related models CRUD operations #104

name: Publish Python 🐍 distribution πŸ“¦ to PyPI and TestPyPI
on:
push
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
# Active un cache pip automatique + expose python-version
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install Poetry with pipx
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pipx
pipx install "poetry==2.0.0"
poetry --version
- name: Configure Poetry (no virtualenvs in-project)
run: |
poetry config virtualenvs.in-project false
poetry config installer.max-workers 4
- name: Install deps
run: |
poetry install --no-interaction --no-root
- name: Run tests
env:
PYTHONPATH: welearn_database
run: |
# Utilise le venv de Poetry
poetry run python -m unittest discover -s tests -p "test_*.py"
build:
name: Build distribution πŸ“¦
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Poetry with pipx
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pipx
pipx install "poetry==2.0.0"
poetry --version
- name: Configure Poetry (no virtualenvs in-project)
run: |
poetry config virtualenvs.in-project false
poetry config installer.max-workers 4
- name: Build a binary wheel and a source tarball
run: poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: >-
Publish Python 🐍 distribution πŸ“¦ to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/welearn-database
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-to-testpypi:
name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/welearn-database
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution πŸ“¦ to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true