Skip to content
This repository was archived by the owner on Mar 7, 2023. It is now read-only.

Commit 829f3ed

Browse files
committed
Initial revision.
0 parents  commit 829f3ed

24 files changed

+4964
-0
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
filename = *.py,src/
3+
max-line-length = 88
4+
extend-ignore = D105, D107, D401, E203, E402

.github/workflows/tests.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
name: tests
3+
4+
on:
5+
push:
6+
paths-ignore:
7+
- "**.md"
8+
- "LICENSE"
9+
- ".gitignore"
10+
- ".pre-commit-config.yaml"
11+
12+
env:
13+
CACHE_DIR: /tmp/.workflow_cache
14+
POETRY_CACHE_DIR: /tmp/.workflow_cache/.pip_packages
15+
POETRY_VIRTUALENVS_PATH: /tmp/.workflow_cache/.venvs
16+
POETRY_HOME: /tmp/.workflow_cache/.poetry
17+
PIP_CACHE_DIR: /tmp/.workflow_cache/.pip_packages
18+
MYPY_CACHE_DIR: /tmp/.workflow_cache/.mypy
19+
20+
jobs:
21+
tests:
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
os: ["ubuntu-latest"]
27+
python-version: ["3.x", "3.8", "3.9", "3.10"]
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v3
31+
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
37+
- name: Cache dependencies
38+
uses: actions/cache@v3
39+
id: cache
40+
with:
41+
path: ${{ env.CACHE_DIR }}
42+
key: tests-${{ matrix.os }}-${{ matrix.python-version }}--${{ hashFiles('**/poetry.lock') }}
43+
44+
- name: Install dependencies
45+
run: |
46+
curl -sSL https://install.python-poetry.org | python -
47+
$POETRY_HOME/bin/poetry install -n -E "all"
48+
if: steps.cache.outputs.cache-hit != 'true'
49+
50+
- name: Python code style
51+
run: $POETRY_HOME/bin/poetry run black . --check --diff --preview
52+
if: ${{ matrix.python-version == '3.x' }}
53+
54+
- name: Python code quality
55+
run: $POETRY_HOME/bin/poetry run flake8 --docstring-convention google
56+
if: ${{ matrix.python-version == '3.x' }}
57+
58+
- name: Python code typing
59+
run: $POETRY_HOME/bin/poetry run mypy --strict --install-types --non-interactive .
60+
if: ${{ matrix.python-version == '3.x' }}
61+
62+
- name: Python code complexity
63+
run: $POETRY_HOME/bin/poetry run radon cc -n C aio_lambda_api 1>&2
64+
if: ${{ matrix.python-version == '3.x' }}
65+
66+
- name: Python code maintainability
67+
run: $POETRY_HOME/bin/poetry run radon mi -n B aio_lambda_api 1>&2
68+
if: ${{ matrix.python-version == '3.x' }}
69+
70+
- name: Python code security
71+
run: $POETRY_HOME/bin/poetry run bandit aio_lambda_api -rs B404,B603
72+
if: ${{ matrix.python-version == '3.x' }}
73+
74+
- name: YAML code style
75+
run: $POETRY_HOME/bin/poetry run yamllint -s .
76+
if: ${{ matrix.python-version == '3.x' }}
77+
78+
- name: Test
79+
run: $POETRY_HOME/bin/poetry run pytest --junitxml=test-results.xml --cov-report xml
80+
if: ${{ always() }}
81+
82+
- name: Collect coverage report
83+
uses: codecov/codecov-action@v3
84+
85+
publish:
86+
runs-on: ${{ matrix.os }}
87+
strategy:
88+
matrix:
89+
os: ["ubuntu-latest"]
90+
python-version: ["3.x"]
91+
if: ${{ github.repository == 'JGoutin/aio_lambda_api' && github.ref_type == 'tag' }}
92+
needs: [tests]
93+
environment: PyPI
94+
permissions:
95+
contents: write
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v3
99+
100+
- name: Set up Python ${{ matrix.python-version }}
101+
uses: actions/setup-python@v4
102+
with:
103+
python-version: ${{ matrix.python-version }}
104+
105+
- name: Cache dependencies
106+
uses: actions/cache@v3
107+
id: cache
108+
with:
109+
path: ${{ env.CACHE_DIR }}
110+
key: tests-${{ matrix.os }}-${{ matrix.python-version }}--${{ hashFiles('**/poetry.lock') }}
111+
112+
- name: Build packages
113+
run: $POETRY_HOME/bin/poetry version $(echo -e "${{ github.ref_name }}" | tr -d 'v')
114+
115+
- name: Publish packages on PyPI
116+
run: $POETRY_HOME/bin/poetry publish --build
117+
env:
118+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
119+
120+
- name: Publish release on GitHub
121+
run: |
122+
go install github.com/tcnksm/ghr@latest
123+
~/go/bin/ghr -generatenotes $PRERELEASE -c ${{ github.sha }} ${{ github.ref_name }}
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
PRERELEASE: ${{ contains(github.ref_name, '-') && '-prerelease' || '' }}

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Python compiled files
2+
__pycache__/
3+
*.py[cd]
4+
5+
# OS generated files
6+
.DS_Store
7+
.DS_Store?
8+
._*
9+
.Spotlight-V100
10+
.Trashes
11+
ehthumbs.db
12+
[Dd]esktop.ini
13+
Thumbs.db
14+
*~
15+
*.bak
16+
17+
# IDE generated files
18+
.project
19+
.pydevproject
20+
.spyproject
21+
.spyderproject
22+
.settings/
23+
.idea/
24+
.vscode/
25+
26+
# Tests generated files
27+
.cache/
28+
.coverage
29+
.coverage.*
30+
.mypy_cache/
31+
.pytest_cache/
32+
33+
# Build
34+
dist/

.pre-commit-config.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
repos:
3+
- repo: local
4+
hooks:
5+
- id: black
6+
name: Black (Formatting)
7+
entry: poetry run black . --preview
8+
language: system
9+
pass_filenames: false
10+
- id: mypy
11+
name: Mypy (Typing)
12+
entry: poetry run mypy --strict .
13+
language: system
14+
pass_filenames: false
15+
- id: flake8
16+
name: Flake8 (Quality)
17+
entry: poetry run flake8 --docstring-convention google
18+
language: system
19+
pass_filenames: false
20+
- id: radon_cc
21+
name: Radon (Cyclomatic complexity)
22+
entry: poetry run radon cc -n C aio_lambda_api
23+
language: system
24+
pass_filenames: false
25+
verbose: true
26+
- id: radon_mi
27+
name: Radon (Maintainability index)
28+
entry: poetry run radon mi -n B aio_lambda_api
29+
language: system
30+
pass_filenames: false
31+
verbose: true
32+
- id: bandit
33+
name: Bandit (Security)
34+
entry: poetry run bandit aio_lambda_api -qrs B404,B603
35+
language: system
36+
pass_filenames: false

.yamllint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
extends: default
3+
rules:
4+
line-length: disable
5+
truthy: disable

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright 2022 Accelize
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)