Skip to content

Commit

Permalink
Merge pull request auredentan#7 from aureldent/chore/update-ci
Browse files Browse the repository at this point in the history
chore(ci): update
  • Loading branch information
auredentan authored Oct 29, 2022
2 parents 51ea98e + 0b64c91 commit 40eeb19
Show file tree
Hide file tree
Showing 7 changed files with 903 additions and 858 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2.2.2
with:
python-version: 3.9
python-version: '3.10'
- name: Run image
uses: abatilo/actions-poetry@v2.0.0
uses: abatilo/actions-poetry@v2.1.6
with:
poetry-version: 1.1.11
poetry-version: 1.2.2
- name: Configure poetry
run: poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
- name: Build and publish package
Expand Down
75 changes: 35 additions & 40 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,65 @@ on:
types: [opened, synchronize, ready_for_review]

jobs:

quality:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v2.2.2
with:
python-version: 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v2.2.2
with:
python-version: "3.10"

- name: Set up the cache
uses: actions/cache@v1
with:
path: .venv
key: cache-python-packages
- name: Set up the cache
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-pip-${{ hashFiles('poetry.lock') }}

- name: Set up the project
run: |
pip install poetry safety
poetry config virtualenvs.in-project true
make setup
- name: Check if the documentation builds correctly
run: make check-docs
- name: Set up the project
run: |
pip install poetry safety
poetry config virtualenvs.in-project true
make setup
- name: Check the code quality
run: make check-code-quality
- name: Check if the documentation builds correctly
run: make check-docs

- name: Check if the code is correctly typed
run: make check-types
- name: Check if the code is correctly typed
run: make check-types

test:
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
poetry-version: [1.0.10, 1.1.11]
os: [ubuntu-18.04, macos-latest, windows-latest]
python-version: [3.9, "3.10", "3.11"]
poetry-version: [1.2.2]
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2.2.2
with:
python-version: ${{ matrix.python-version }}
- name: Setup poetry
uses: abatilo/actions-poetry@v2.0.0
uses: abatilo/actions-poetry@v2.1.6
with:
poetry-version: ${{ matrix.poetry-version }}
poetry-version: ${{ matrix.poetry-version }}

- name: Install dependencies
run: poetry install
- name: Run tests
run: poetry run pytest --cov starlette_session --cov-report=xml tests/
run: poetry run pytest --cov starlette_session --cov-report=xml tests/

- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
fail_ci_if_error: true
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 3.10.4
36 changes: 16 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,23 @@ docs-deploy: doc-regen ## Deploy the documentation on GitHub pages.

.PHONY: changelog
changelog: ## Update the changelog in-place with latest commits.
@poetry run failprint -t "Updating changelog" -- python scripts/update_changelog.py \
@poetry run python scripts/update_changelog.py \
CHANGELOG.md "<!-- insertion marker -->" "^## \[(?P<version>[^\]]+)"

##
# Checks
##

.PHONY: check
check: check-docs check-code-quality check-types ## Check it all!

.PHONY: check-code-quality
check-code-quality: ## Check the code quality.
@poetry run failprint -t "Checking code quality" -- flake8 --config=config/flake8.ini $(PY_SRC)
check: check-docs check-types ## Check it all!

.PHONY: check-docs
check-docs: ## Check if the documentation builds correctly.
@poetry run failprint -t "Building documentation" -- mkdocs build -s
@poetry run mkdocs build

.PHONY: check-types
check-types: ## Check that the code is correctly typed.
@poetry run failprint -t "Type-checking" -- mypy --config-file config/mypy.ini $(PY_SRC)
@poetry run mypy --config-file=./config/mypy.ini $(PY_SRC)

##
# Setup
Expand All @@ -88,28 +84,28 @@ setup: ## Setup the development environment (install dependencies).

.PHONY: format
format: ## Run formatting tools on the code.
@poetry run failprint -t "Formatting code" -- black $(PY_SRC)
@poetry run failprint -t "Ordering imports" -- isort -rc $(PY_SRC)
@poetry run black $(PY_SRC)
@poetry run isort -rc $(PY_SRC)


.PHONY: release
release: ## Create a new release (commit, tag, push, build, publish, deploy docs).
ifndef v
$(error Pass the new version with 'make release v=0.0.0')
endif
@poetry run failprint -t "Bumping version" -- poetry version $(v)
@poetry run failprint -t "Staging files" -- git add pyproject.toml CHANGELOG.md
@poetry run failprint -t "Committing changes" -- git commit -m ":package: Prepare release $(v) :package:"
@poetry run failprint -t "Tagging commit" -- git tag v$(v)
@poetry run failprint -t "Building dist/wheel" -- poetry build
@poetry run poetry version $(v)
@poetry run git add pyproject.toml CHANGELOG.md
@poetry run git commit -m ":package: Prepare release $(v) :package:"
@poetry run git tag v$(v)
@poetry run poetry build
-@if ! $(CI) && ! $(TESTING); then \
poetry run failprint -t "Pushing commits" -- git push; \
poetry run failprint -t "Pushing tags" -- git push --tags; \
poetry run failprint -t "Publishing version" -- poetry publish; \
poetry run failprint -t "Deploying docs" -- poetry run mkdocs gh-deploy; \
poetry run git push; \
poetry run git push --tags; \
poetry run poetry publish; \
poetry run poetry run mkdocs gh-deploy; \
fi


.PHONY: test
test: ## Run the test suite and report coverage.
@poetry run pytest --cov starlette_session
@poetry run pytest --cov starlette_session
5 changes: 4 additions & 1 deletion config/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[mypy]
ignore_missing_imports = true
ignore_missing_imports = true

[mypy-redis.*]
ignore_missing_imports = True
Loading

0 comments on commit 40eeb19

Please sign in to comment.