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
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: matthewlee-dev
8 changes: 6 additions & 2 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Thin trigger wrapper, job logic lives in reusable-*.yml so ci-main and
# ci-release share it.
name: CI

on:
Expand All @@ -9,10 +11,12 @@ on:

jobs:

# Guarded so the template doesn't run these twice: template-ci.yml already
# runs static analysis, and Maya tests need a real project.
static-analysis:
if: github.repository != 'matthewlee-dev/MayaPythonProjectTemplate'
if: ${{ !github.event.repository.is_template }}
uses: ./.github/workflows/reusable-static-analysis.yml

tests:
if: github.repository != 'matthewlee-dev/MayaPythonProjectTemplate'
if: ${{ !github.event.repository.is_template }}
uses: ./.github/workflows/reusable-maya-tests.yml
43 changes: 36 additions & 7 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,57 @@
# Thin trigger wrapper, job logic lives in reusable-*.yml so ci-main and
# ci-release share it.
name: Release

on:
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. 1.2.3)"
required: true
type: string
platforms:
description: "Platforms to vendor runtime deps for (e.g: win64, linux, mac)"
required: false
type: string
# release.py never passes these, so the defaults are what ships. Keep
# in step with reusable-maya-tests.yml: a Maya version with no .mod row
# won't load the module, even though CI went green on it.
default: "win64,linux,mac"
maya_versions:
description: "Maya versions to vendor runtime deps for (e.g: 2024,2025,2026)"
required: false
type: string
default: "2024,2025,2026,2027"
vendor_deps:
description: "Vendor runtime dependencies into the module (uncheck to ship without them)"
required: false
type: boolean
default: true

jobs:

static-analysis:
if: github.repository != 'matthewlee-dev/MayaPythonProjectTemplate'
if: ${{ !github.event.repository.is_template }}
uses: ./.github/workflows/reusable-static-analysis.yml

tests:
if: github.repository != 'matthewlee-dev/MayaPythonProjectTemplate'
if: ${{ !github.event.repository.is_template }}
uses: ./.github/workflows/reusable-maya-tests.yml

do_release:
if: github.repository != 'matthewlee-dev/MayaPythonProjectTemplate'
needs: [tests]
uses: ./.github/workflows/reusable-semantic-release.yml
if: ${{ !github.event.repository.is_template }}
needs: [tests, static-analysis]
uses: ./.github/workflows/reusable-release.yml
with:
version: ${{ inputs.version }}
platforms: ${{ inputs.platforms }}
maya_versions: ${{ inputs.maya_versions }}
vendor_deps: ${{ inputs.vendor_deps }}
permissions:
contents: write
id-token: write

docs:
if: github.repository != 'matthewlee-dev/MayaPythonProjectTemplate'
if: ${{ !github.event.repository.is_template }}
needs: [tests, do_release] # only build docs when release is successful
uses: ./.github/workflows/reusable-build-and-deploy-docs.yml
permissions:
Expand Down
39 changes: 24 additions & 15 deletions .github/workflows/initial-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,55 @@ env:

jobs:
setup:
if: github.repository != 'matthewlee-dev/MayaPythonProjectTemplate'
# Only run on repos generated from the template, never on a template itself.
if: ${{ !github.event.repository.is_template }}
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Rename README.md and delete setup workflow
- name: Swap in the generated project's files
run: |
# Delete template LICENSE
rm -f LICENSE

# Delete existing README.md
rm -f README.md

# Rename _README.md to README.md
mv _README.md README.md

# Delete the template logo placeholder
rm -f docs/resources/images/maya_python_logo.png

# Rename template logo
mv docs/resources/images/_maya_python_logo.png docs/resources/images/maya_python_logo.png

# _new_project mirrors the repo layout. Add files there, not here.
cp -r _new_project/. .
rm -rf _new_project

# Drop the docs pages that only document the template itself.
rm -f docs/getting-started.md docs/project-layout.md \
docs/writing-your-tool.md docs/testing.md docs/ci.md \
docs/releasing.md docs/documentation.md

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

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

- name: Run initial setup script
run: |
python initial_setup.py

- name: Regenerate uv.lock for the renamed project
run: uv lock

- name: Remove setup files
run: |
rm -f initial_setup.py
rm -f .github/workflows/initial-setup.yml
rm -f .github/workflows/template-ci.yml
rm -f .github/workflows/template-release.yml
rm -f .github/workflows/reusable-template-tests.yml
rm -f .github/FUNDING.yml
rm -rf tests/template

- name: Commit and push changes
run: |
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/reusable-build-and-deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build and deploy docs
name: reusable / build and deploy docs

on:
workflow_dispatch: # Manual trigger
Expand All @@ -13,17 +13,19 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: 3.x
python-version: '3.13'

- uses: actions/cache@v4
- uses: actions/cache@v6
with:
key: ${{ github.ref }}
path: .cache

- run: |
pip install mkdocs-material mkdocstrings[python]
mkdocs gh-deploy --force
- name: Install dependencies
run: uv sync --only-group docs

- run: uv run --no-sync mkdocs gh-deploy --force
98 changes: 63 additions & 35 deletions .github/workflows/reusable-maya-tests.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,62 @@
name: maya tests
name: reusable / maya tests

on:
workflow_call:
workflow_dispatch: # Manual trigger

jobs:
# Cheap gate: skips the disk purge + multi-GB Maya image pull when there are
# no tests, the common case for freshly created template projects.
collect_tests:
runs-on: ubuntu-latest
outputs:
tests_collected: ${{ steps.check_tests.outputs.tests_collected }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: '3.x'
python-version: '3.13'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
run: uv sync --only-group test

- name: Check for tests
id: check_tests
run: |
#!/bin/bash
set +e # Disable exit on error
pytest --collect-only
set +e
# --ignore=tests/template: CI also fires on a generated repo's
# first commit, before setup has deleted the template's own tests.
output=$(uv run --no-sync pytest --collect-only --ignore=tests/template)
exit_code=$?
set -e # Re-enable exit on error

set -e
echo "$output"

# Exit 5 is the only non-zero status meaning "nothing to run". A
# collection error (exit 2) also prints "collected 0 items", so
# treating it as an empty suite would skip every test and stay green.
if [ $exit_code -eq 5 ]; then
echo "tests_collected=0" >> $GITHUB_OUTPUT
echo "No tests were collected."
else
collected=$(pytest --collect-only | grep -oP 'collected \K\d+')
echo "tests_collected=$collected" >> $GITHUB_OUTPUT
echo "Collected $collected tests."
exit 0
fi

if [ $exit_code -ne 0 ]; then
echo "::error::pytest --collect-only failed (exit $exit_code)." \
"Tests must import outside Maya: move 'from maya import ...'" \
"into a test or fixture, as tests/maya/conftest.py does."
exit 1
fi

collected=$(echo "$output" | grep -oP 'collected \K\d+')
if [ -z "$collected" ]; then
echo "::error::Could not parse a test count from pytest output."
exit 1
fi
echo "tests_collected=$collected" >> $GITHUB_OUTPUT
echo "Collected $collected tests."

no_tests_found:
needs: collect_tests
if: needs.collect_tests.outputs.tests_collected == '0'
Expand All @@ -58,28 +76,38 @@ jobs:
fail-fast: false

matrix:
# add or remove versions as needed, a job per version will be created
# supported tags here: https://github.com/mottosso/docker-maya/
maya_version: ["2024",]

container: mottosso/maya:${{ matrix.maya_version }} # ty mottosso!
# add/remove versions to match what you target; tags: https://github.com/mottosso/docker-maya/
maya_version: ["2024"]

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Install dependencies
# No job-level `container:`: that pulls before any step can free disk space first,
# and large Maya images can exceed the runner's free disk mid-pull.
- name: Free disk space
run: |
mayapy -m pip install --upgrade pip
mayapy -m pip install pip-tools
pip-compile requirements.in
pip-compile requirements-test.in
mayapy -m pip install --user -r requirements-test.txt
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc \
/usr/local/share/powershell /usr/share/swift /opt/hostedtoolcache/CodeQL
df -h /

- name: Set Maya environment variables
run: |
echo "XDG_RUNTIME_DIR=/var/tmp/runtime-root" >> $GITHUB_ENV
echo "MAYA_DISABLE_ADP=1" >> $GITHUB_ENV
- name: Pull Maya image
run: docker pull mottosso/maya:${{ matrix.maya_version }} # ty mottosso!

- name: Run tests
run: mayapy -m pytest tests
- name: Install test dependencies and run tests in Maya container
run: |
docker run --rm \
-e XDG_RUNTIME_DIR=/var/tmp/runtime-root \
-e MAYA_DISABLE_ADP=1 \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
mottosso/maya:${{ matrix.maya_version }} \
bash -c '
set -e
if command -v curl >/dev/null; then curl -LsSf https://astral.sh/uv/install.sh | sh
else wget -qO- https://astral.sh/uv/install.sh | sh
fi
export PATH="$HOME/.local/bin:$PATH"
uv pip install --python "$(command -v mayapy)" --group test .
mayapy -m pytest tests --ignore=tests/template
'
Loading