-
-
Notifications
You must be signed in to change notification settings - Fork 59
Refactor python code, add publish workflows, add docs website #17
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
Open
JohnCHarrington
wants to merge
6
commits into
main
Choose a base branch
from
refactor-python-code
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,34 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| echo "[pre-commit] Running ruff (fix), pytest, and mypy..." | ||
|
|
||
| # Only run if Python files changed; otherwise skip quickly | ||
| changed_py=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.py$' || true) | ||
| if [[ -z "$changed_py" ]]; then | ||
| echo "[pre-commit] No Python changes detected. Skipping checks." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if ! command -v uv >/dev/null 2>&1; then | ||
| echo "[pre-commit] 'uv' not found. Install from https://github.com/astral-sh/uv" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Lint and auto-fix Python code | ||
| echo "[pre-commit] Ruff: check & fix" | ||
| uvx ruff check --fix | ||
|
|
||
| # Re-stage any auto-fixed files so the commit includes updates | ||
| git add -A | ||
|
|
||
| # Run tests | ||
| echo "[pre-commit] Pytest" | ||
| uv run pytest -q python/ | ||
|
|
||
| # Type checking | ||
| echo "[pre-commit] Mypy" | ||
| uv run mypy | ||
|
|
||
| echo "[pre-commit] All checks passed. Proceeding with commit." | ||
| exit 0 |
This file contains hidden or 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,45 @@ | ||
| name: Publish Docs to GitHub Pages | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'documentation/**' | ||
| - '_config.yml' | ||
| - 'Gemfile' | ||
| - 'README.md' | ||
|
|
||
|
|
||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Pages | ||
| uses: actions/configure-pages@v5 | ||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4' # Not needed with a .ruby-version, .tool-versions or mise.toml | ||
| bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
| - name: Build with Jekyll | ||
| run: bundle exec jekyll build | ||
| env: | ||
| JEKYLL_ENV: production | ||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
This file contains hidden or 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,37 @@ | ||
| name: Publish to PyPI | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| test-lint-typecheck: | ||
| uses: ./.github/workflows/python-ci.yml | ||
| build-and-publish: | ||
JohnCHarrington marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| needs: test-lint-typecheck | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v3 | ||
|
|
||
| - name: Build package (sdist and wheel) | ||
| run: uv build | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| password: ${{ secrets.PYPI_TOKEN }} | ||
|
||
| # Uncomment to be verbose or skip existing versions | ||
| # verbose: true | ||
| # skip-existing: true | ||
This file contains hidden or 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,41 @@ | ||
| name: Python CI | ||
|
|
||
| on: | ||
| workflow_call: | ||
| push: | ||
| branches: ["**"] | ||
| paths: | ||
| - '**/*.py' | ||
| - 'pyproject.toml' | ||
| pull_request: | ||
| branches: ["**"] | ||
| paths: | ||
| - '**/*.py' | ||
| - 'pyproject.toml' | ||
|
|
||
| jobs: | ||
| test-lint-typecheck: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v3 | ||
|
|
||
| - name: Sync dependencies (including dev) | ||
| run: uv sync --all-extras --dev | ||
JohnCHarrington marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Run tests (pytest) | ||
| run: uv run pytest | ||
|
|
||
| - name: Lint (ruff) | ||
| run: uvx ruff check | ||
|
|
||
| - name: Type check (mypy) | ||
| run: uv run mypy | ||
This file contains hidden or 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,3 +1,8 @@ | ||
| __pycache__/ | ||
| .* | ||
| !.gitignore | ||
| !.githooks | ||
| !.github | ||
| __about__.py | ||
| _site | ||
| *.lock |
This file contains hidden or 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,33 @@ | ||
| source "https://rubygems.org" | ||
| # Hello! This is where you manage which Jekyll version is used to run. | ||
| # When you want to use a different version, change it below, save the | ||
| # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: | ||
| # | ||
| # bundle exec jekyll serve | ||
| # | ||
| # This will help ensure the proper Jekyll version is running. | ||
| # Happy Jekylling! | ||
| gem "jekyll", "~> 4.4.1" | ||
| # This is the default theme for new Jekyll sites. You may change this to anything you like. | ||
| gem "just-the-docs" | ||
| # If you have any plugins, put them here! | ||
| group :jekyll_plugins do | ||
| gem "jekyll-feed", "~> 0.12" | ||
| gem "jekyll-readme-index" | ||
| gem "jekyll-gfm-admonitions" | ||
| gem "jekyll-relative-links" | ||
| end | ||
|
|
||
| # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem | ||
| # and associated library. | ||
| platforms :mingw, :x64_mingw, :mswin, :jruby do | ||
| gem "tzinfo", ">= 1", "< 3" | ||
| gem "tzinfo-data" | ||
| end | ||
|
|
||
| # Performance-booster for watching directories on Windows | ||
| gem "wdm", "~> 0.1", :platforms => [:mingw, :x64_mingw, :mswin] | ||
|
|
||
| # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem | ||
| # do not have a Java counterpart. | ||
| gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.