Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Sep 27, 2024
0 parents commit b24389e
Show file tree
Hide file tree
Showing 36 changed files with 2,970 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-complexity = 12
max-line-length = 120
exclude =
.*/
__pycache__
docs
~build
dist
*.md

per-file-ignores =
src/**/migrations/*.py:E501
34 changes: 34 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This is used by the action https://github.com/dorny/paths-filter
dependencies: &dependencies
- 'pdm.lock'
- 'pyproject.toml'

python: &python
- added|modified: 'src/**'
- added|modified: 'tests/**'
- 'manage.py'

changelog:
- added|modified: 'changes/**'
- 'CHANGELOG.md'

mypy:
- *python
- 'mypy.ini'

run_tests:
- *python
- *dependencies
- 'pytest.ini'
- '.github/workflows/test.yml'
- '.github/file-filters.yml'

migrations:
- added|modified: 'src/**/migrations/*'

lint:
- *python
- '.flake8'
- 'pyproject.toml'
- '.github/file-filters.yml'
- '.github/workflows/lint.yml'
67 changes: 67 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Documentation"

on:
push:
branches:
- develop
- master
schedule:
- cron: '37 23 * * 2'

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
generate:
name: Generate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
sudo apt-get install libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev
pip install \
"cairosvg>=2.7.1"\
"markupsafe>=2.1.5"\
"mdx-gh-links>=0.4"\
"mkdocs-autolinks-plugin>=0.7.1"\
"mkdocs-awesome-pages-plugin>=2.9.3"\
"mkdocs-click>=0.8.1"\
"mkdocs-ezglossary-plugin>=1.6.10"\
"mkdocs-ezlinks-plugin>=0.1.14"\
"mkdocs-gen-files>=0.5.0"\
"mkdocs-get-deps>=0.2.0"\
"mkdocs-include-markdown-plugin>=6.2.2"\
"mkdocs-link-marker>=0.1.3"\
"mkdocs-macros-plugin>=1.0.5"\
"mkdocs-material[imaging]>=9.5.15"\
"mkdocs-minify-plugin"\
"mkdocs-redirects"\
"mkdocs-simple-hooks>=0.1.5"\
"mkdocs>=1.5.3"\
"mkdocstrings[python]>=0.24.1"\
"pymdown-extensions>=10.7.1"
mkdocs build -d ./docs-output
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs-output

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: generate
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
62 changes: 62 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Lint

on:
push:
branches:
- '**' # matches every branch

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}-lint"
cancel-in-progress: true

defaults:
run:
shell: bash

permissions:
id-token: write
attestations: write


jobs:
changes:
runs-on: ubuntu-latest
timeout-minutes: 1
defaults:
run:
shell: bash
outputs:
lint: ${{steps.changes.outputs.lint }}
steps:
- name: Checkout code
uses: actions/[email protected]
- id: changes
name: Check for file changes
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
with:
base: ${{ github.ref }}
token: ${{ github.token }}
filters: .github/file-filters.yml

lint:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [ changes ]
if: needs.changes.outputs.lint
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: 'x64'
- uses: yezz123/setup-uv@v4
- name: lint
if: needs.changes.outputs.lint
run: |
uv run isort src/ --check-only
uv run flake8 src/
114 changes: 114 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Test

on:
push:
branches:
- '**' # matches every branch

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}-test"
cancel-in-progress: true

defaults:
run:
shell: bash

permissions:
id-token: write
attestations: write


jobs:
changes:
runs-on: ubuntu-latest
timeout-minutes: 1
defaults:
run:
shell: bash
outputs:
run_tests: ${{steps.changes.outputs.run_tests }}
lint: ${{steps.changes.outputs.lint }}
steps:
- name: Checkout code
uses: actions/[email protected]
- id: changes
name: Check for file changes
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
with:
base: ${{ github.ref }}
token: ${{ github.token }}
filters: .github/file-filters.yml

ci:
runs-on: ubuntu-latest
name: Test py${{ matrix.python-version }}/dj${{matrix.django-version}}
defaults:
run:
shell: bash
strategy:
max-parallel: 1
matrix:
python-version: [ "3.9", "3.12" ]
django-version: [ "4.2", "5.1" ]
fail-fast: true
needs: [ changes ]
if: needs.changes.outputs.run_tests || needs.changes.outputs.lint
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Restore cached venv
id: cache-venv-restore
uses: actions/cache/restore@v4
with:
path: |
.cache-uv/
.venv/
key: ${{ matrix.python-version }}-${{matrix.django-version}}-venv

- uses: yezz123/setup-uv@v4
# with:
# uv-venv: ".venv"

- name: Test
if: needs.changes.outputs.run_tests
run: |
/root/.cargo/bin/uv run --cache-dir .cache-uv/ --frozen \
pytest tests \
--junit-xml junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml \
--cov --cov-report xml
- name: Cache venv
if: steps.cache-venv-restore.outputs.cache-hit != 'true'
id: cache-venv-save
uses: actions/cache/save@v4
with:
path: |
.cache-uv/
.venv/
key: ${{ matrix.python-version }}-${{matrix.django-version}}-venv

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}-${{matrix.django-version}}
path: junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml
if: ${{ always() }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == 3.12
continue-on-error: true
with:
env_vars: OS,PYTHON
fail_ci_if_error: true
flags: unittests
files: ./coverage.xml
verbose: false
token: ${{ secrets.CODECOV_TOKEN }}
name: codecov-${{env.GITHUB_REF_NAME}}
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.*
~*
*.sh
dist/
build/
*.py[cod]
*.patch
*.egg-info
*.sqlite*
!.git
!tests/.coveragerc
!.github
!.flake8
!.gitignore
!.github/
!.mypy.ini
!.pre-commit-config.yaml
!bandit.yaml
coverage.xml
32 changes: 32 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[mypy]
python_version = 3.12
files = src/
exclude = (management/|manage.py)

install_types = true
show_error_codes = true
mypy_path = "$MYPY_CONFIG_FILE_DIR/stubs/:$MYPY_CONFIG_FILE_DIR/src/:"
strict = false
ignore_missing_imports = True
namespace_packages = true
;plugins =
; mypy_django_plugin.main

;[mypy.plugins.django-stubs]
;django_settings_module = "bitcaster.config.settings"

[mypy-smart_env.*]
ignore_missing_imports = True
follow_imports = skip
disable_error_code = type-var,
attr-defined,
truthy-function,
union-attr,
var-annotated,
valid-type,
misc,
attr-defined,
no-any-return,
return,
[mypy-environ.*]
ignore_errors = True
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 unicef

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added README.md
Empty file.
9 changes: 9 additions & 0 deletions docs/src/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Reference


::: celery_model.models.CeleryTaskModel
handler: python
options:
show_root_heading: true
show_source: true
heading_level: 2
Loading

0 comments on commit b24389e

Please sign in to comment.