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
176 changes: 176 additions & 0 deletions .github/workflows/test_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Tests

on:
push:
branches:
- main
- '*.*.*'

pull_request:
branches:
- main
- '*.*.*'

release:
types: [ published ]

jobs:

black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: '3.13'

- name: Install packages
run: pip install -r requirements_dev.txt

- name: Black
run: |
black --check -l 120 simple_oauth2/ tests/

isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: '3.13'

- name: Install packages
run: pip install -r requirements_dev.txt

- name: Isort
run: |
isort --check simple_oauth2/ tests/

pycodestyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: '3.13'

- name: Install packages
run: pip install -r requirements_dev.txt

- name: Pycodestyle
run: |
pycodestyle simple_oauth2/ tests/

pydocstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: '3.13'

- name: Install packages
run: pip install -r requirements_dev.txt

- name: Pydocstyle
run: |
pydocstyle --count simple_oauth2/

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: '3.13'

- name: Install packages
run: pip install -r requirements_dev.txt

- name: Mypy
run: |
mypy simple_oauth2 --disallow-untyped-def

bandit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: '3.13'

- name: Install packages
run: pip install -r requirements_dev.txt

- name: Bandit
run: |
bandit --ini=setup.cfg -ll 2> /dev/null


test:
needs: [black, isort, pycodestyle, pydocstyle, bandit]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10', '3.11', '3.12', '3.13']
django-version: [ 42, 51, 52 ]
exclude:
- python-version: 3.13
django-version: 42

steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install Tox and any other packages
run: |
pip install tox
- name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }},
run: tox -e py-django${{ matrix.django-version }}

- name: Upload coverage to Codecov
if: matrix.python-version == 3.13 && matrix.django-version == 52
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

publish:
needs: test
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@master

- name: Set up Python 3.13
uses: actions/setup-python@v4
with:
python-version: '3.13'

- name: Creating Built Distributions
run: |
pip install setuptools
python setup.py sdist

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_password }}
skip_existing: true
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# OS generated files
.DS_Store

# IDEs and editors
.vscode/
.idea/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
Expand Down Expand Up @@ -50,6 +57,7 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
junit.xml

# Translations
*.mo
Expand Down Expand Up @@ -182,9 +190,9 @@ cython_debug/
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/

Expand Down
85 changes: 85 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
image: docker:latest

services:
- docker:dind

stages:
- checks
- test
- build
- deploy

variables:
BUILD_TOOLS_PATH: /home/gitlab-runner/codoc-tools/docker_build
DOCKERFILE_DIR_PATH: $GITLAB_PROJECT_DIR

################################################################################
################################# TEMPLATES ####################################
################################################################################

.checks: &checks
stage: checks
only:
- merge_requests
before_script:
- python3.11 -m venv venv
- source venv/bin/activate
- python3.11 -m pip install -U pip setuptools wheel

.test: &test
stage: test
only:
- merge_requests
before_script:
- python3.11 -m venv venv
- source venv/bin/activate
- python3.11 -m pip install -U pip setuptools wheel
- python3.11 -m pip install -r requirements_dev.txt

################################################################################
################################### CHECKS #####################################
################################################################################

job:flake8:
<<: *checks
script:
- python3.11 -m pip install flake8 flake8-junit-report
- flake8 . --output-file=flake8.txt
after_script:
- flake8_junit flake8.txt flake8_junit.xml
artifacts:
reports:
junit: flake8_junit.xml

job:isort:
<<: *checks
script:
- python3.11 -m pip install "isort==5.10.1"
- isort --check django_test/ {{ app_name }}/

job:black:
<<: *checks
script:
- python3.11 -m pip install "black==22.3.0"
- black --check --exclude="^.*\b((migrations))\b.*$" -l 120 test_project/ {{ app_name }}/

job:pydocstyle:
<<: *checks
script:
- python3.11 -m pip install pydocstyle
- ./bin/pydocstyle.sh


################################################################################
################################### TESTS ######################################
################################################################################

job:unittest:
<<: *test
script:
- python3.11 -m pytest --create-db -vvv -s --color=yes --durations=0 --durations-min=1.0 --cov=. --cov-report term
artifacts:
reports:
junit: junit.xml
coverage: '/TOTAL.*\s+(\d+%)$/'
resource_group: {{ app_name }}_unittest
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changelog
=========

## 0.1.0 {% now "SHORT_DATE_FORMAT" %}
Loading
Loading