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

Commit

Permalink
Merge pull request #37 from lyz-code/feat/update-cruft
Browse files Browse the repository at this point in the history
feat/update cruft
  • Loading branch information
lyz-code committed Mar 11, 2022
2 parents 8a598c0 + 7f9ba4f commit e3d5f2d
Show file tree
Hide file tree
Showing 23 changed files with 3,182 additions and 3,265 deletions.
4 changes: 2 additions & 2 deletions .cruft.json
@@ -1,7 +1,7 @@
{
"template": "https://github.com/lyz-code/cookiecutter-python-project",
"commit": "3e344547a9bb3d1719f3f88206fdcd2291b586c6",
"checkout": "3e34454",
"commit": "bcd6dcee41eb8d74c5134cf24e5a74256eba8c4c",
"checkout": null,
"context": {
"cookiecutter": {
"project_name": "pynbox",
Expand Down
8 changes: 0 additions & 8 deletions .github/dependabot.yml

This file was deleted.

16 changes: 7 additions & 9 deletions .github/workflows/build.yml
Expand Up @@ -5,21 +5,18 @@ on: # yamllint disable-line rule:truthy
push:
branches:
- master
workflow_dispatch:

jobs:
PyPI:
name: Build and publish Python distributions to PyPI and TestPyPI
name: Build and publish Python distributions to TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v1
- uses: pdm-project/setup-pdm@main
name: Setup Python and PDM
with:
python-version: 3.9
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install
- name: Build package
run: make build-package
- name: Publish distribution to Test PyPI
Expand All @@ -37,11 +34,12 @@ jobs:
# Number of commits to fetch. 0 indicates all history.
# Default: 1
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: pdm-project/setup-pdm@main
name: Setup Python and PDM
with:
python-version: 3.9
- name: Install dependencies
run: poetry install
run: make install
- name: Build the Documentation
run: make build-docs
- name: Deploy
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/install.yml
Expand Up @@ -3,6 +3,7 @@ name: Install
on: # yamllint disable-line rule:truthy
schedule:
- cron: 21 08 * * *
workflow_dispatch:

jobs:
Install:
Expand Down
38 changes: 33 additions & 5 deletions .github/workflows/tests.yml
Expand Up @@ -7,11 +7,13 @@ on: # yamllint disable-line rule:truthy
- master
pull_request:
types: [opened, synchronize]
workflow_dispatch:

jobs:
Tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 3
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
steps:
Expand All @@ -20,10 +22,16 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install
- name: Install program
run: |
# All these steps are required so that mypy behaves equally than the
# local environment, once mypy supports __pypackages__ try to use the
# github action
pip install virtualenv pdm
virtualenv .venv
source .venv/bin/activate
pdm config use_venv True
make install
- name: Test linters
run: make lint
- name: Test type checkers
Expand All @@ -32,7 +40,27 @@ jobs:
run: make security
- name: Test with pytest
run: make test
- name: Upload Coverage
run: |
pip3 install 'coveralls[toml]'
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
COVERALLS_PARALLEL: true
- name: Test documentation
run: make build-docs
- name: Build the package
run: make build-package
Coveralls:
name: Finish Coveralls
needs: Tests
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install 'coveralls[toml]'
coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 11 additions & 5 deletions .github/workflows/update.yml
Expand Up @@ -3,6 +3,7 @@ name: Update
on: # yamllint disable-line rule:truthy
schedule:
- cron: 11 08 * * *
workflow_dispatch:

jobs:
Update:
Expand All @@ -16,10 +17,15 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install
- name: Install program
run: |
# All these steps are required so that mypy behaves equally than the
# local environment, once mypy supports __pypackages__ try to use the
# github action
pip install virtualenv pdm
virtualenv .venv
source .venv/bin/activate
pdm config use_venv True
- name: Update requirements
run: make update
- name: Run tests
Expand All @@ -29,7 +35,7 @@ jobs:
rm -r .git/hooks
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add requirements.txt docs/requirements.txt requirements-dev.txt
git add pdm.lock
git diff-index --quiet HEAD \
|| git commit -m "chore: update dependency requirements"
- name: Push changes
Expand Down
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.pdm.toml

# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python
Expand Down
61 changes: 22 additions & 39 deletions Makefile
@@ -1,30 +1,20 @@
.DEFAULT_GOAL := test
flakehell = poetry run flakehell lint src/ tests/
isort = poetry run isort src tests
black = poetry run black --target-version py37 src tests
isort = pdm run isort src tests
black = pdm run black --target-version py39 src tests

.PHONY: install
install:
poetry install --remove-untracked
pre-commit install
pdm install --dev
pdm run pre-commit install

.PHONY: update
update:
@echo "-------------------------"
@echo "- Updating dependencies -"
@echo "-------------------------"

poetry update

@echo ""

.PHONY: upgrade
upgrade:
@echo "-------------------------"
@echo "- Upgrading dependencies -"
@echo "-------------------------"

poetryup
pdm update --no-sync
pdm sync --clean

@echo ""

Expand All @@ -45,7 +35,7 @@ lint:
@echo "- Testing the lint -"
@echo "--------------------"

$(flakehell)
pdm run flakeheaven lint src/ tests/
$(isort) --check-only --df
$(black) --check --diff

Expand All @@ -57,20 +47,20 @@ mypy:
@echo "- Testing mypy -"
@echo "----------------"

poetry run mypy src tests
pdm run mypy src tests

@echo ""

.PHONY: test
test: test-code
test: test-code test-examples

.PHONY: test-code
test-code:
@echo "----------------"
@echo "- Testing code -"
@echo "----------------"

poetry run pytest --cov-report term-missing --cov src tests ${ARGS}
pdm run pytest --cov-report term-missing --cov src tests ${ARGS}

@echo ""

Expand All @@ -80,7 +70,10 @@ test-examples:
@echo "- Testing examples -"
@echo "--------------------"

@find docs/examples -type f -name '*.py' | xargs -I'{}' sh -c 'python {} >/dev/null 2>&1 || (echo "{} failed" ; exit 1)'
@find docs/examples -type f -name '*.py' | xargs -I'{}' sh -c 'echo {}; pdm run python {} >/dev/null 2>&1 || (echo "{} failed" ; exit 1)'
@echo ""

# pdm run pytest docs/examples/*

@echo ""

Expand Down Expand Up @@ -117,12 +110,12 @@ clean:
@echo ""

.PHONY: docs
docs:
docs: test-examples
@echo "-------------------------"
@echo "- Serving documentation -"
@echo "-------------------------"

poetry run mkdocs serve
pdm run mkdocs serve

@echo ""

Expand All @@ -146,7 +139,7 @@ build-package: clean
@echo "- Building the package -"
@echo "------------------------"

poetry build
pdm build

@echo ""

Expand All @@ -156,7 +149,7 @@ build-docs:
@echo "- Building documentation -"
@echo "--------------------------"

poetry run mkdocs build
pdm run mkdocs build

@echo ""

Expand All @@ -166,17 +159,7 @@ upload-pypi:
@echo "- Uploading package to pypi -"
@echo "-----------------------------"

poetry publish

@echo ""

.PHONY: upload-testing-pypi
upload-testing-pypi:
@echo "-------------------------------------"
@echo "- Uploading package to pypi testing -"
@echo "-------------------------------------"

poetry publish -r test-pypi
twine upload -r pypi dist/*

@echo ""

Expand All @@ -186,7 +169,7 @@ bump-version:
@echo "- Bumping program version -"
@echo "---------------------------"

poetry run cz bump --changelog --no-verify
pdm run cz bump --changelog --no-verify
git push
git push --tags

Expand All @@ -198,9 +181,9 @@ security:
@echo "- Testing security -"
@echo "--------------------"

poetry run safety check
pdm run safety check
@echo ""
poetry run bandit -r src
pdm run bandit -r src

@echo ""

Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Expand Up @@ -45,9 +45,9 @@ giants, namely:
[Mypy](https://mypy.readthedocs.io/en/stable/)
: Python static type checker.

[Flakehell](https://github.com/life4/flakehell)
[Flakeheaven](https://github.com/flakeheaven/flakeheaven)
: Python linter with [lots of
checks](https://lyz-code.github.io/blue-book/devops/flakehell/#plugins).
checks](https://lyz-code.github.io/blue-book/devops/flakeheaven#plugins).

[Black](https://black.readthedocs.io/en/stable/)
: Python formatter to keep a nice style without effort.
Expand Down
6 changes: 5 additions & 1 deletion mkdocs.yml
Expand Up @@ -55,7 +55,11 @@ markdown_extensions:
- pymdownx.magiclink
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.superfences
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
- pymdownx.tabbed:
alternate_style: true
- pymdownx.tasklist:
Expand Down

0 comments on commit e3d5f2d

Please sign in to comment.