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
9 changes: 9 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"permissions": {
"allow": [
"Bash(python:*)"
],
"deny": [],
"ask": []
}
}
164 changes: 164 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: Build and Test

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
check-version:
runs-on: ubuntu-latest
outputs:
version-exists: ${{ steps.check-release.outputs.exists }}
version: ${{ steps.get-version.outputs.version }}
files-changed: ${{ steps.check-changes.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Install dependencies
run: |
pip install tomli
# GitHub CLI is pre-installed on GitHub runners

- name: Get version from pyproject.toml
id: get-version
run: |
VERSION=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Current version: $VERSION"

- name: Check if release exists
id: check-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view "v${{ steps.get-version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Release v${{ steps.get-version.outputs.version }} already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Release v${{ steps.get-version.outputs.version }} does not exist"
fi

- name: Check if Python files changed
id: check-changes
if: steps.check-release.outputs.exists == 'true'
run: |
# Get the tag for this version
TAG="v${{ steps.get-version.outputs.version }}"

# Check if any Python files or pyproject.toml changed since the tag
if git diff --name-only $TAG HEAD | grep -E '\.(py|toml)$'; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "Python files have changed since release $TAG"
exit 1
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "No Python files changed since release $TAG"
fi

format-check:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

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

- name: Install Black
run: |
python -m pip install --upgrade pip
pip install black

- name: Check formatting with Black
id: black_check
continue-on-error: true
run: |
black --check trademan tests/

- name: Format code with Black and commit (if needed)
if: steps.black_check.outcome == 'failure' && github.event_name == 'pull_request'
run: |
black trademan tests/
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
if git diff --staged --quiet; then
echo "No changes to commit after formatting"
else
git commit -m "Auto-format code with Black"
# Pull any changes that might have been pushed by other jobs
git pull origin ${{ github.head_ref }} --rebase
git push origin HEAD:${{ github.head_ref }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


build:
needs: [check-version]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

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

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build tomli

- name: Install package with dev dependencies
run: |
pip install -e .[dev]


- name: Test with pytest
run: |
pytest tests/ -v --cov=trademan --cov-report=xml

- name: Upload coverage to Codecov
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella

- name: Build package
run: |
python -m build

- name: Check package
run: |
pip install twine
twine check dist/*

- name: Upload build artifacts
if: matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
60 changes: 60 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Documentation

on:
push:
branches: [ main ]
paths:
- 'docs/**'
- 'trademan/**'
- 'README.md'
- 'pyproject.toml'
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

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

- name: Build documentation
run: |
cd docs
make html

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/_build/html'

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Loading