Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 85 additions & 0 deletions .github/workflows/experiment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI
on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
# =========================================================
# 1. DISCOVERY
# =========================================================
discover:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.parse.outputs.packages }}
steps:
- uses: actions/checkout@v4
- id: changes
uses: tj-actions/changed-files@v44
with:
files: packages/**

# Bulletproof directory extraction (ignores file names)
- id: parse
name: Extract Package Directories
env:
ALL_FILES: ${{ steps.changes.outputs.all_changed_files }}
run: |
PKGS=$(echo "$ALL_FILES" | tr ' ' '\n' | cut -d'/' -f1,2 | sort -u | tr '\n' ' ')
echo "packages=$PKGS" >> $GITHUB_OUTPUT

# =========================================================
# 2. EXECUTION (Parallelized internally via xargs)
# =========================================================
unit:
needs: discover
if: ${{ needs.discover.outputs.packages != '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Exactly 5 Jobs total. Never violates GitHub limits.
python: ["3.9", "3.10", "3.11", "3.12", "3.14"]

name: Unit (Python ${{ matrix.python }})
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
enable-cache: true

- name: Run Tests Concurrently
run: |
export NOX_DEFAULT_VENV_BACKEND=uv
export UV_PRERELEASE=allow

# Dropped -n 1 to fix the xargs warning.
echo "${{ needs.discover.outputs.packages }}" | tr ' ' '\n' | xargs -P 4 -I {} sh -c '
if [ -f "{}/noxfile.py" ]; then
cd {}

# Run test and capture output
uvx --with "nox[uv]" nox -s "unit-${{ matrix.python }}" > nox_output.log 2>&1
STATUS=$?

# Print output cleanly inside a GitHub group
echo "::group::Testing {} (Python ${{ matrix.python }})"
cat nox_output.log

if [ $STATUS -ne 0 ]; then
# Check if it failed just because the Python version isn"t supported by this package
if grep -q "Sessions not found:" nox_output.log; then
echo "⏭️ Session unit-${{ matrix.python }} is not defined for this package. Safely skipping."
else
echo "❌ Tests failed in {}!"
echo "::endgroup::"
# Exit 1 allows other packages to finish testing, but ensures the workflow fails
exit 1
fi
fi

echo "::endgroup::"
fi
'
Loading
Loading