add max parallel to hyperband example #163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| workflow_dispatch: # Manually trigger the workflow | |
| # Triggers with push to main | |
| push: | |
| branches: | |
| - main | |
| - development | |
| # Triggers with push to a PR aimed at main | |
| pull_request: | |
| branches: | |
| - main | |
| - development | |
| env: | |
| package-name: "hypersweeper" | |
| test-dir: tests | |
| UV_SYSTEM_PYTHON: 1 | |
| CI: false | |
| jobs: | |
| # General unit tests | |
| source-test: | |
| name: test | |
| runs-on: "ubuntu-latest" | |
| defaults: | |
| run: | |
| shell: bash # Default to using bash on all | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| # Install a specific version of uv. | |
| version: "0.6.14" | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install ${{ env.package-name }} | |
| run: make install-dev | |
| - name: Store git status | |
| id: status-before | |
| shell: bash | |
| run: | | |
| BEFORE="$(git status --porcelain -b)" | |
| # save multi-line output correctly to GITHUB_OUTPUT | |
| echo "BEFORE<<EOF" >> $GITHUB_OUTPUT | |
| echo "$BEFORE" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Tests (with crash diagnostics) | |
| shell: bash | |
| env: | |
| PYTHONFAULTHANDLER: "1" | |
| run: | | |
| set -o pipefail | |
| echo "Running pytest with faulthandler; output saved to pytest.log" | |
| python -X faulthandler -m pytest -vv -s --disable-pytest-warnings tests --durations=20 2>&1 | tee pytest.log | |
| rc=${PIPESTATUS[0]} | |
| echo "pytest exit code: $rc" | |
| if [ "$rc" -ne 0 ]; then | |
| echo "===== Last 500 lines of pytest.log =====" | |
| tail -n 500 pytest.log || true | |
| echo "===== Python faulthandler / thread info =====" | |
| python - <<'PY' | |
| import faulthandler, threading | |
| print('faulthandler enabled:', faulthandler.is_enabled()) | |
| print('thread count:', len(threading.enumerate())) | |
| PY | |
| if command -v dmesg >/dev/null 2>&1; then | |
| echo "===== dmesg tail (possible OOM/kernel kills) =====" | |
| sudo dmesg | tail -n 200 || true | |
| fi | |
| mkdir -p artifacts | |
| cp pytest.log artifacts/ | |
| exit $rc | |
| fi | |
| - name: Upload pytest log | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pytest-log | |
| path: artifacts/pytest.log | |
| - name: Diagnostics and cleanup check | |
| if: always() | |
| shell: bash | |
| run: | | |
| echo "=== GIT status before tests ===" | |
| echo "${{ steps.status-before.outputs.BEFORE }}" | |
| echo "=== GIT status after tests ===" | |
| git status --porcelain -b | |
| echo "=== Running processes (ps) ===" | |
| ps auxf || true | |
| echo "=== Open files in repo (lsof) ===" | |
| lsof +D . || true | |
| echo "=== disk usage (du) at repo root ===" | |
| du -sh . || true | |
| before="${{ steps.status-before.outputs.BEFORE }}" | |
| after="$(git status --porcelain -b)" | |
| if [[ "$before" != "$after" ]]; then | |
| echo "git status from before: $before" | |
| echo "git status from after: $after" | |
| echo "Not all generated files have been deleted!" | |
| exit 1 | |
| fi | |
| - name: Kill leftover test processes (best-effort) | |
| if: always() | |
| shell: bash | |
| run: | | |
| pkill -f uv || true | |
| pkill -f pytest || true | |
| sleep 1 | |
| ps auxf || true |