Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: poetry, github action overhaul, pyenv / asdf versions #137

Closed
wants to merge 7 commits into from
Closed
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
88 changes: 60 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,80 @@
name: Test
name: tests

on: [push, pull_request]

jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']

python-version: [ '3.9' ]
django-version: [ '2.2', '3.1', '3.2', '4.0', '4.1' ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install "poetry==1.2.1"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v1-
cache: 'poetry'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions
poetry install -E "docs test coverage lint format"
poetry run pip install DJANGO~=${{ matrix.django-version }}

- name: Tox tests
- name: Print python versions
run: |
tox -v
python -V
poetry run python -V

- name: Lint with flake8
run: poetry run flake8

- name: Lint with mypy
run: poetry run mypy .

- name: Upload coverage
uses: codecov/codecov-action@v1
- name: Test with pytest
run: poetry run py.test --cov=./ --cov-report=xml

- uses: codecov/codecov-action@v2
with:
name: Python ${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}

release:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install "poetry==1.2.1"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: Build package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: poetry build

- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
Comment on lines +74 to +80
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be done here but in the release.yml file instead. Please don't push to PyPI directly, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true ☝️ And I know why that'd be. This is copied from my own project's workflows (it wasn't meant to be added)

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.7 3.9.13 3.8.13 3.7.12
24 changes: 24 additions & 0 deletions .tmuxp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
session_name: django-robots
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems not needed here.

start_directory: ./ # load session relative to config location (project root).
shell_command_before:
- '[ -f .venv/bin/activate ] && source .venv/bin/activate && reset'
windows:
- window_name: django-robots
focus: True
layout: main-horizontal
options:
main-pane-height: 35
panes:
- focus: true
- pane
- make watch_test
- window_name: docs
layout: main-horizontal
options:
main-pane-height: 35
start_directory: docs/
panes:
- focus: true
- pane
- pane
- make start
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
poetry 1.2.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed for development should be kept on your machine.

python 3.10.7 3.9.13 3.8.13 3.7.12
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
WATCH_FILES= find . -type f -not -path '*/\.*' | grep -i '.*[.]py$$' 2> /dev/null
PY_FILES= find . -type f -not -path '*/\.*' -and -not -path '*/settings\/*' -and -not -path '*/migrations\/*' | grep -i '.*[.]py$$'
SHELL := /bin/bash


entr_warn:
@echo "----------------------------------------------------------"
@echo " ! File watching functionality non-operational ! "
@echo " "
@echo "Install entr(1) to automatically run tasks on file change."
@echo "See http://entrproject.org/ "
@echo "----------------------------------------------------------"

build_docs:
pushd docs; $(MAKE) html; popd

watch_docs:
pushd docs; $(MAKE) watch_docs; popd

start:
$(MAKE) test; poetry run ptw .

test:
poetry run py.test $(test)

watch_test:
if command -v entr > /dev/null; then ${WATCH_FILES} | entr -c $(MAKE) test; else $(MAKE) test entr_warn; fi

start_docs:
$(MAKE) -C docs start

design_docs:
$(MAKE) -C docs design

black:
poetry run black `${PY_FILES}`

isort:
poetry run isort `${PY_FILES}`

flake8:
poetry run flake8

watch_flake8:
if command -v entr > /dev/null; then ${WATCH_FILES} | entr -c $(MAKE) flake8; else $(MAKE) flake8 entr_warn; fi

mypy:
poetry run mypy `${PY_FILES}`

watch_mypy:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) mypy; else $(MAKE) mypy entr_warn; fi

format_markdown:
prettier --parser=markdown -w *.md docs/*.md docs/**/*.md CHANGES
67 changes: 61 additions & 6 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Makefile for Sphinx documentation
#
SHELL := /bin/bash
WATCH_FILES= find .. -type f -not -path '*/\.*' | grep -i '.*[.]\(rst\|md\)\$\|.*[.]py\$\|CHANGES\|TODO\|.*conf\.py' 2> /dev/null
HTTP_PORT = 8034

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXBUILD = poetry run sphinx-build
PAPER =
BUILDDIR = _build

Expand All @@ -29,17 +32,20 @@ help:
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
-rm -rf $(BUILDDIR)/*
rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
Expand Down Expand Up @@ -77,17 +83,17 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-robots.qhcp"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-robots.qhc"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/django-robots"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/django-robots"
@echo "# mkdir -p $$HOME/.local/share/devhelp/complexity"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity"
@echo "# devhelp"

epub:
Expand All @@ -108,6 +114,12 @@ latexpdf:
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
Expand Down Expand Up @@ -151,3 +163,46 @@ doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."

pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

redirects:
$(SPHINXBUILD) -b rediraffewritediff $(ALLSPHINXOPTS) $(BUILDDIR)/redirects
@echo
@echo "Build finished. The redirects are in rediraffe_redirects."

checkbuild:
rm -rf $(BUILDDIR)
$(SPHINXBUILD) -n -q ./ $(BUILDDIR)

watch:
if command -v entr > /dev/null; then ${WATCH_FILES} | entr -c $(MAKE) html; else $(MAKE) html; fi

serve:
@echo '================================================================='
@echo
@echo 'docs server running at http://localhost:${HTTP_PORT}'
@echo
@echo '================================================================='
@$(MAKE) serve_py3

serve_py3:
python -m http.server ${HTTP_PORT} --directory _build/html

dev:
$(MAKE) -j watch serve

start:
poetry run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} $(O)

design:
# This adds additional watch directories (for _static file changes) and disable incremental builds
poetry run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} --watch "." -a $(O)
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# 'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
Expand Down
Loading