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
98 changes: 0 additions & 98 deletions .github/workflows/ci.yaml

This file was deleted.

41 changes: 18 additions & 23 deletions .github/workflows/ci_pr.yaml → .github/workflows/python-pr.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
name: Python package on pull request
name: Python

on: [pull_request]
on:
pull_request:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Poetry
uses: descope/.github/.github/actions/python/poetry/setup@main
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Build coverage file
run: |
python -m pytest --junitxml=/tmp/pytest.xml --cov-report=term-missing:skip-covered --cov=descope tests/ | tee /tmp/pytest-coverage.txt
poetry run pytest --junitxml=/tmp/pytest.xml --cov-report=term-missing:skip-covered --cov=descope tests/ | tee /tmp/pytest-coverage.txt

- name: Pytest coverage comment
id: coverageComment
Expand All @@ -46,13 +40,14 @@ jobs:
echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}"
echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}"

#- name: Create the Badge
# uses: schneegans/dynamic-badges-action@v1.4.0
# with:
# auth: ${{ secrets.CI_READ_COMMON }}
# gistID: 277ec23e4e70728824362a0d24fbd0f9
# filename: pytest-coverage-comment.json
# label: Coverage Report
# message: ${{ steps.coverageComment.outputs.coverage }}
# color: ${{ steps.coverageComment.outputs.color }}
# namedLogo: pytest
pkg:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker build and push
uses: descope/.github/.github/actions/docker/build@main
with:
push: true
token: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/python-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python Publish

on:
release:
types: [created]

permissions:
contents: read
pull-requests: read # to detect changes files

jobs:
pypi:
name: Pypi
runs-on: ubuntu-latest
steps:
- name: Setup
uses: descope/.github/.github/actions/python/poetry/setup@main
- name: Autobump version
run: |
poetry version $(git describe --tags --abbrev=0)
- name: Build
uses: descope/.github/.github/actions/python/poetry/build@main
- name: Publish
uses: descope/.github/.github/actions/python/poetry/publish@main
with:
test: true
token: ${{ secrets.PYPI_TEST_TOKEN }}
98 changes: 58 additions & 40 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,60 @@
exclude: 'docs/'
exclude: "docs/"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/dhatim/python-license-check
rev: 0.7.2
hooks:
- id: liccheck
language: system
args: ["-r./requirements-dev.txt", "-lparanoid"]
- repo: local
hooks:
- id: print_statement
name: Check that print statement isnt in source code
types: [python]
entry: 'print'
language: pygrep
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/dhatim/python-license-check
rev: 0.7.2
hooks:
- id: liccheck
language: system
args: ["-r./requirements-dev.txt", "-lparanoid"]
- repo: https://github.com/python-poetry/poetry
rev: 1.2.0 # add version here
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements.txt"]
- id: poetry-export
args:
[
"-f",
"requirements.txt",
"-o",
"requirements-dev.txt",
"--only",
"dev",
]
- repo: local
hooks:
- id: print_statement
name: Check that print statement isnt in source code
types: [python]
entry: "print"
language: pygrep
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
ARG PYTHON_VERSION=3.9

FROM python:${PYTHON_VERSION}-slim as python-base
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"

ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"

FROM python-base as builder-base
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
curl \
build-essential \
libpq-dev \
git

# Install Poetry - respects $POETRY_VERSION & $POETRY_HOME
ENV POETRY_VERSION=1.2.0
RUN curl -sSL https://install.python-poetry.org | python

# We copy our Python requirements here to cache them
# and install only runtime deps using poetry
WORKDIR $PYSETUP_PATH
COPY . .
RUN poetry install

FROM python-base as production
ENV FASTAPI_ENV=production

COPY --from=builder-base $VENV_PATH $VENV_PATH

COPY . /app
WORKDIR /app

CMD python samples/otp_web_sample_app.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Replace any instance of `<ProjectID>` in the code below with your company's Proj
Run the following code in your project. These commands will add the Descope ExpresSDK for Python as a project dependency, and set the `DESCOPE_PROJECT_ID` variable to a valid \<ProjectID\>.

```code
pip install Descope-Auth
pip install descope
export DESCOPE_PROJECT_ID=<ProjectID>
```

## What do you want to implement?

Click one of the following links to open the documentation for that specific functionality.
Click one of the following links to open the documentation for that specific functionality.

- [x] [One time passwords (OTP)](./docs/otp.md)
- [x] [Magic Links](./docs/magiclink.md)
Expand Down
Loading