-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework module, rework build, add docs, swap to poetry for build (#20)
* rework module, rework build, add docs * remove archives check * fix more actions * more tweaks * install poetry? * fix poetry run
- Loading branch information
1 parent
5e1a2e8
commit 2314371
Showing
26 changed files
with
1,816 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
watch_file ./poetry.lock | ||
use nix | ||
export _SITE_PKGS="$(dirname $(dirname $(which python)))/lib/python3.11/site-packages" | ||
export PYTHONPATH="$_SITE_PKGS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,20 +9,21 @@ jobs: | |
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: set up python | ||
uses: actions/setup-python@v2 | ||
- uses: actions/[email protected] | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
- name: install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
sed -i -E "s#VERSION#${GITHUB_REF/refs\/tags\//}#g" ./setup.py | ||
python-version: '3.11' | ||
- name: build and publish | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USER }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
twine upload dist/* | ||
run: poetry publish --build -n -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }} | ||
docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: cachix/install-nix-action@v25 | ||
- run: nix run -f . scripts.docs | ||
- uses: actions/configure-pages@v4 | ||
- uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: 'docs/build/html' | ||
- id: deployment | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,70 @@ | ||
{ pkgs ? import | ||
(fetchTarball { | ||
name = "jpetrucciani-2023-10-17"; | ||
url = "https://github.com/jpetrucciani/nix/archive/d944b2ed0e17f5e8e12332d21d226038ccb77ccb.tar.gz"; | ||
sha256 = "0dzcqs7614pd0z0n17d3y6n6w1snk0x54pj8m740w4657i538g7s"; | ||
name = "jpetrucciani-2024-03-07"; | ||
url = "https://github.com/jpetrucciani/nix/archive/b063a2ae8e915ef8047fc2c3c486a6ec46f22c38.tar.gz"; | ||
sha256 = "0r9x2ghcvi4nrh4g8qf73616972g13b82k3zj3ij77rx3cs7p81q"; | ||
}) | ||
{ } | ||
}: | ||
let | ||
name = "gamble"; | ||
|
||
python = (pkgs.poetry2nix.mkPoetryEnv { | ||
projectDir = ./.; | ||
python = pkgs.python311; | ||
overrides = pkgs.poetry2nix.overrides.withDefaults (final: prev: { }); | ||
editablePackageSources = { | ||
"gamble" = ./gamble; | ||
}; | ||
preferWheels = true; | ||
}); | ||
|
||
tools = with pkgs; { | ||
cli = [ | ||
nixpkgs-fmt | ||
]; | ||
python = [ | ||
ruff | ||
(python311.withPackages (p: with p; [ | ||
colorama | ||
pytest | ||
pytest-cov | ||
setuptools | ||
tox | ||
])) | ||
]; | ||
scripts = [ | ||
(writeShellScriptBin "test_actions" '' | ||
export DOCKER_HOST=$(${pkgs.docker-client}/bin/docker context inspect --format '{{.Endpoints.docker.Host}}') | ||
${pkgs.act}/bin/act --container-architecture linux/amd64 -r --rm | ||
'') | ||
poetry | ||
python | ||
]; | ||
scripts = pkgs.lib.attrsets.attrValues scripts; | ||
}; | ||
|
||
scripts = | ||
let | ||
inherit (pkgs.writers) writeBashBin; | ||
repo = "$(${pkgs.git}/bin/git rev-parse --show-toplevel)"; | ||
in | ||
{ | ||
test_actions = writeBashBin "test_actions" '' | ||
export DOCKER_HOST=$(${pkgs.docker-client}/bin/docker context inspect --format '{{.Endpoints.docker.Host}}') | ||
${pkgs.act}/bin/act --container-architecture linux/amd64 -r --rm | ||
''; | ||
_test = writeBashBin "_test" '' | ||
export PYTEST_RUNNING=1 | ||
${python}/bin/pytest ./tests \ | ||
-s \ | ||
--cov ${name} \ | ||
--cov-report term \ | ||
--cov-report html \ | ||
--cov-report xml:coverage.xml \ | ||
--junitxml=report.xml \ | ||
"$@" | ||
''; | ||
docs = writeBashBin "docs" '' | ||
cd "${repo}/docs" || exit 1 | ||
rm -rf ./build | ||
${python}/bin/sphinx-build -M html source build | ||
''; | ||
}; | ||
paths = pkgs.lib.flatten [ (builtins.attrValues tools) ]; | ||
env = python.env.overrideAttrs (_: { | ||
buildInputs = paths; | ||
}); | ||
in | ||
pkgs.buildEnv { | ||
inherit name paths; | ||
buildInputs = paths; | ||
} | ||
(env.overrideAttrs (_: { | ||
inherit name; | ||
NIXUP = "0.0.6"; | ||
})) // { inherit scripts; } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# docs | ||
|
||
This directory configures [sphinx](https://www.sphinx-doc.org/en/master/) documentation for gamble | ||
|
||
--- | ||
|
||
## In this directory | ||
|
||
### [source/](./source/) | ||
|
||
This contains the configuration and source files for the documentation that will be generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import 'theme.css'; | ||
.wy-nav-content { | ||
max-width: 100% !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
sphinx config | ||
""" | ||
|
||
import os | ||
import sys | ||
from datetime import date | ||
|
||
|
||
sys.path.insert(0, os.path.abspath("../../")) | ||
|
||
project = "gamble" | ||
copyright = f"{date.today().year} jpetrucciani" | ||
author = "jpetrucciani" | ||
master_doc = "index" | ||
|
||
extensions = [ | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.autosummary", | ||
"sphinx.ext.doctest", | ||
"sphinx.ext.intersphinx", | ||
"sphinx.ext.mathjax", | ||
"sphinx.ext.napoleon", | ||
"sphinx.ext.todo", | ||
"sphinx.ext.viewcode", | ||
"sphinx_rtd_theme", | ||
] | ||
autodoc_type_aliases = {} | ||
autodoc_typehints = "both" | ||
autodoc_typehints_format = "fully-qualified" | ||
autodoc_default_options = { | ||
"show-inheritance": True, | ||
"members": True, | ||
} | ||
|
||
autosummary_generate = True | ||
napoleon_google_docstring = True | ||
napoleon_numpy_docstring = True | ||
napoleon_include_init_with_doc = True | ||
napoleon_include_special_with_doc = True | ||
napoleon_use_admonition_for_examples = False | ||
napoleon_use_admonition_for_notes = False | ||
napoleon_use_admonition_for_references = False | ||
napoleon_use_ivar = False | ||
napoleon_use_param = True | ||
napoleon_use_rtype = True | ||
|
||
pygments_style = "sphinx" | ||
show_sphinx = False | ||
|
||
templates_path = ["_templates"] | ||
exclude_patterns = [] | ||
|
||
html_theme = "sphinx_rtd_theme" | ||
html_static_path = ["_static"] | ||
html_style = "css/overrides.css" | ||
|
||
html_theme_options = { | ||
"logo_only": False, | ||
"display_version": True, | ||
"prev_next_buttons_location": "bottom", | ||
"style_external_links": False, | ||
"vcs_pageview_mode": "", | ||
# Toc options | ||
"collapse_navigation": True, | ||
"sticky_navigation": True, | ||
"navigation_depth": 4, | ||
"includehidden": True, | ||
"titles_only": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
gamble documentation | ||
=================================== | ||
|
||
.. autosummary:: | ||
:toctree: gamble | ||
:recursive: | ||
|
||
gamble | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,49 @@ | ||
""" | ||
@author jacobi petrucciani | ||
@desc gamble module | ||
gamble module | ||
""" | ||
from gamble.models import * # noqa | ||
|
||
from gamble.models import ( | ||
# cards | ||
BlackJackDeck, | ||
Card, | ||
Deck, | ||
EuchreDeck, | ||
Hand, | ||
MultiDeck, | ||
Rank, | ||
Suit, | ||
Value, | ||
# dice | ||
Die, | ||
Dice, | ||
RiggedDie, | ||
# golf | ||
Course, | ||
Group, | ||
HCC, | ||
Hole, | ||
Player, | ||
) | ||
|
||
__all__ = [ | ||
# cards | ||
"BlackJackDeck", | ||
"Card", | ||
"Deck", | ||
"EuchreDeck", | ||
"Hand", | ||
"MultiDeck", | ||
"Rank", | ||
"Suit", | ||
"Value", | ||
# dice | ||
"Die", | ||
"Dice", | ||
"RiggedDie", | ||
# golf | ||
"Course", | ||
"Group", | ||
"HCC", | ||
"Hole", | ||
"Player", | ||
] |
Oops, something went wrong.