Skip to content

added fiction test

added fiction test #1

name: Publish Python Package
on:
push:
tags:
- "v*.*.*"
jobs:
check-tag-from-main-branch:
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
- name: Check if tag is on main branch
run: |
git fetch origin main
if git merge-base --is-ancestor $(git rev-parse ${{ github.ref }}) $(git rev-parse refs/remotes/origin/main); then
echo "Tag is from main branch"
else
echo "Tag is not from main branch"
exit 1
fi
check-version-already-exist:
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/setup_python_and_poetry
- name: Check if version already exists
run: |
PACKAGE_VERSION=$(poetry version -s)
STATUS_CODE=$(curl -o /dev/null -s -w "%{http_code}\n" https://pypi.org/project/dddjango/$PACKAGE_VERSION/)
if [ "$STATUS_CODE" -eq 200 ]; then
echo "Version $PACKAGE_VERSION already exists"
exit 1
else
echo "Version $PACKAGE_VERSION doesn't exists"
fi
linters:
runs-on: ubuntu-20.04
strategy:
matrix:
command: [
"ruff . --config ruff.toml",
"ruff format . --check --config ruff.toml",
"mypy --config mypy.toml"
]
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/setup_python_and_poetry
- uses: ./.github/actions/linters
with:
command: ${{ matrix.command }}
tests:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
pydantic-version: [ "2.1", "2.8", "2.9" ]
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/setup_python_and_poetry
with:
python-version: ${{ matrix.python-version }}
- uses: ./.github/actions/tests
with:
pydantic-version: ${{ matrix.pydantic-version }}
publish-package:
runs-on: ubuntu-20.04
needs:
- check-tag-from-main-branch
- check-version-already-exist
- linters
- tests
environment:
name: pypi
url: https://pypi.org/p/dddjango
permissions:
contents: write
id-token: write
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/setup_python_and_poetry
- name: Build release distributions
run: poetry build
- name: Publish release distributions
uses: pypa/gh-action-pypi-publish@release/v1
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
upload-results-to-codecov:
runs-on: ubuntu-20.04
needs:
- publish-package
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/setup_python_and_poetry
- name: Install dependencies
run: poetry install --with test
shell: bash
- name: Tests
run: pytest --cov=dddjango --cov-report=xml
shell: bash
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
file: ./coverage.xml
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}