Skip to content
Merged
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
108 changes: 23 additions & 85 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,33 @@
# # .github/workflows/docs.yml
# name: Deploy Documentation

# on:
# push:
# tags:
# - 'v*.*.*'
# workflow_dispatch: # Allow manual triggering

# permissions:
# contents: write # This is the key addition - explicitly grant write permission

# jobs:
# deploy:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0 # fetch all history for proper versioning

# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'

# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -e ".[dev]"

# - name: Set up Git user
# run: |
# git config --local user.email "github-actions[bot]@users.noreply.github.com"
# git config --local user.name "github-actions[bot]"

# - name: Extract version from tag
# id: get_version
# run: |
# echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

# - name: Deploy docs
# run: |
# mike deploy --push --update-aliases ${{ env.VERSION }} latest

# .github/workflows/docs.yml
name: Deploy Documentation

name: Documentation
on:
workflow_run:
workflows: ["Publish Package"]
types:
- completed
push:
branches:
- master
- main
workflow_dispatch: # Allow manual triggering

permissions:
contents: write

contents: read
pages: write
id-token: write
jobs:
deploy:
# Only run if the package publish was successful
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/configure-pages@v5
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
fetch-depth: 0 # fetch all history for proper versioning

- name: Set up Python
uses: actions/setup-python@v4
enable-cache: true
- name: Install Python 3.14
run: uv python install 3.14
- name: Generate API reference pages
run: uv run --python 3.14 --group dev python scripts/gen_ref_pages.py
- run: uv run --python 3.14 --group dev zensical build --clean
- uses: actions/upload-pages-artifact@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Set up Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

- name: Get latest tag
id: get_tag
run: |
# Get the latest tag
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Deploy docs
run: |
mike deploy --push --update-aliases ${{ env.VERSION }} latest
path: site
- uses: actions/deploy-pages@v4
id: deployment
104 changes: 83 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,97 @@ name: Publish Package

on:
push:
tags:
- 'v*' # Trigger on version tags (v0.1.0, v1.0.0, etc.)
branches: ["main"] # Run tests on every push to main
tags: ["v*"] # Run tests AND publish on tags
pull_request:
branches: ["main"] # Run tests on PRs

# Add this permissions block
permissions:
contents: read
id-token: write # This is needed for PyPI's trusted publishing
id-token: write

jobs:
build-and-publish:
test:
name: "Test (Python ${{ matrix.python-version }})"
runs-on: ubuntu-latest
environment: pypi
strategy:
matrix:
python-version: ["3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
- name: Checkout
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Run unit tests
run: uv run --python ${{ matrix.python-version }} --group dev pytest

- name: Generate coverage report
if: matrix.python-version == '3.14' && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: uv run --python ${{ matrix.python-version }} --group dev pytest --cov=stochas --cov-report=xml

- name: Generate coverage badge
if: matrix.python-version == '3.14' && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: uv run --python ${{ matrix.python-version }} --group dev genbadge coverage -i coverage.xml -o docs/assets/coverage-badge.svg

- name: Commit coverage badge
if: matrix.python-version == '3.14' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update coverage badge"
file_pattern: docs/assets/coverage-badge.svg

publish:
name: "Build and Publish"
needs: [test]
# ONLY run this job if the push was actually a tag
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write # Required for PyPI Trusted Publishing
contents: write # Required to create GitHub Release and upload assets
steps:
- name: Checkout
uses: actions/checkout@v6
with:
python-version: '3.11'

- name: Install build dependencies
# Fetch all history so we can see other branches
fetch-depth: 0

- name: Verify Tag is on Main
# Only perform this check if we were triggered by a tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
python -m pip install --upgrade pip
pip install build

- name: Build package
run: python -m build

# Check if 'main' branch contains the current commit
if ! git branch -r --contains ${{ github.sha }} | grep -q "origin/main"; then
echo "::error::Tag ${{ github.ref_name }} was pushed on a non-main branch. Skipping workflow."
exit 1
fi

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install Python 3.14
run: uv python install 3.14

- name: Build
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# No need to specify token when using trusted publishing
run: uv publish --check-url https://pypi.org/simple

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/*.whl
dist/*.tar.gz
30 changes: 0 additions & 30 deletions .github/workflows/test.yml

This file was deleted.

49 changes: 34 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
**/workdir/
**/__pycache__/**/*
**/*.egg*/
**/*.egg-info/**
**/*.pyc
**/*.pyo
**/*.pyd
**/*.pyz
**/*.code-workspace
dist/
# Python-generated files
__pycache__/
*.py[oc]
build/
trendify.log
dist/
wheels/
*.egg-info

# Virtual environments
.venv

mojo.log
mojo.log.*

site
docs/reference/
mojo-models
textures

typings

# TypeScript build artifacts (node_modules is dev-only; compiled .js files ARE committed)
node_modules/
*.js.map

.coverage

**/*.code-workspace

trendify.log*

# Test output files
discriminator_tests.json
discriminator_tests.log
.coverage
coverage.xml
# MkDocs build directory
site/

/**/.DS_Store

*.prof
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=500"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.17
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.21
hooks:
- id: uv-lock
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.21
hooks:
- id: uv-export
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.411
hooks:
- id: pyright
- id: pyright
name: Pyright (docs examples)
args: [docs]
pass_filenames: false
always_run: true
stages: [pre-commit]
- repo: local
hooks:
- id: act-test
name: Run GitHub Actions locally (act)
entry: act -j test
language: system
stages: [pre-push]
pass_filenames: false
files: ^(src/|tests/|pyproject\.toml|uv\.lock)
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14
Loading
Loading