Skip to content

Add note about tome tests requiring a virtual environment to pass #117

Add note about tome tests requiring a virtual environment to pass

Add note about tome tests requiring a virtual environment to pass #117

Workflow file for this run

name: Testing Tome
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.11", "3.13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip globally
run: python -m pip install --upgrade pip --no-cache-dir
- name: Install dependencies and run tests in venv
run: |
python -m venv venv
${{ matrix.os == 'windows-latest' && '.\\venv\\Scripts\\Activate.ps1' || 'source venv/bin/activate' }}
python -m pip install --upgrade pip --no-cache-dir
pip install .[dev]
coverage run -m pytest -v tests/
coverage report
docs:
needs: test
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 docs dependencies
run: pip install .[docs]
- name: Build documentation
run: mkdocs build --strict --verbose
static-analysis:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install tools
run: pip install ruff vulture bandit[toml] detect-secrets
- name: Run Ruff
run: |
ruff format --check --no-cache || echo "::warning file=Ruff::Formatting issues detected."
- name: Run Vulture
run: |
vulture tome/ || echo "::warning file=Vulture::Potential dead code detected."
- name: Run Bandit
run: |
bandit -c pyproject.toml tome -r -lll || echo "::warning file=Bandit::Security vulnerabilities detected."
- name: Run Detect-Secrets
run: |
detect-secrets -C tome scan || echo "::warning file=Detect-Secrets::Secrets detected."
publish-to-pypitest:
name: Publish Development Build to TestPyPI
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: test-pypi-release
url: https://test.pypi.org/p/tomescripts
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install build tools
run: python -m pip install --upgrade pip build
- name: Add date to version
run: |
DATE=$(date +%Y%m%d)
sed -i "s/^version = \"\(.*\)\"/version = \"\1.dev${DATE}\"/" pyproject.toml
- name: Build the package
run: python -m build
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
skip_existing: true
releaseDraft:
name: Create Release Draft
if: github.ref == 'refs/heads/main'
needs: [test, publish-to-pypitest, docs]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DRAFT_IDS=$(gh api repos/${{ github.repository }}/releases --jq '.[] | select(.draft == true) | .id')
if [[ -n "$DRAFT_IDS" ]]; then
echo "Deleting old drafts..."
echo "$DRAFT_IDS" | xargs -I '{}' gh api -X DELETE repos/${{ github.repository }}/releases/'{}'
else
echo "No old drafts found. Skipping delete step."
fi
- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ env.VERSION }}" --draft --title "v${{ env.VERSION }}" --generate-notes
deploy-dev-docs:
needs: releaseDraft
uses: ./.github/workflows/deploy-docs.yml
with:
version: dev
permissions:
contents: write