[core] Add auto dispatch + Extend the mgit example
#240
Workflow file for this run
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: ArgMojo Unit Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| # ── Job 1: Format + Package ──────────────────────────────────────────── | |
| # If this job fails, the later test jobs will be skipped, | |
| # so we can save time by checking formatting and packaging first. | |
| build: | |
| name: Build & Format | |
| runs-on: macos-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: prefix-dev/setup-pixi@v0.9.5 | |
| with: | |
| cache: true | |
| - name: Format check | |
| run: | | |
| pixi run format | |
| if ! git diff --exit-code; then | |
| echo "::error::Code is not formatted. Run 'pixi run format' locally." | |
| exit 1 | |
| fi | |
| - name: Build package (with retry) | |
| run: | | |
| for attempt in 1 2 3; do | |
| echo "=== package attempt $attempt ===" | |
| if pixi run package; then | |
| echo "=== package succeeded on attempt $attempt ===" | |
| break | |
| fi | |
| if [ "$attempt" -eq 3 ]; then | |
| echo "=== package failed after 3 attempts ===" | |
| exit 1 | |
| fi | |
| echo "=== package crashed, retrying in 5s... ===" | |
| sleep 5 | |
| done | |
| # ── Job 2: Core parsing tests ────────────────────────────────────────── | |
| test-core: | |
| name: "Test: Core Parsing" | |
| needs: build | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-mojo | |
| - name: Run core tests (with retry) | |
| run: | | |
| for attempt in 1 2 3; do | |
| echo "=== test attempt $attempt ===" | |
| if mojo run -I src -D ASSERT=all tests/test_parse.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_options.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_groups.mojo; then | |
| echo "=== tests passed on attempt $attempt ===" | |
| break | |
| fi | |
| if [ "$attempt" -eq 3 ]; then | |
| echo "=== tests failed after 3 attempts ===" | |
| exit 1 | |
| fi | |
| echo "=== test run crashed, retrying in 5s... ===" | |
| sleep 5 | |
| done | |
| # ── Job 3: Feature tests ─────────────────────────────────────────────── | |
| test-features: | |
| name: "Test: Features" | |
| needs: build | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-mojo | |
| - name: Run feature tests (with retry) | |
| run: | | |
| for attempt in 1 2 3; do | |
| echo "=== test attempt $attempt ===" | |
| if mojo run -I src -D ASSERT=all tests/test_help.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_completion.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_interactive.mojo < /dev/null \ | |
| && mojo run -I src -D ASSERT=all tests/test_wrappers.mojo; then | |
| echo "=== tests passed on attempt $attempt ===" | |
| break | |
| fi | |
| if [ "$attempt" -eq 3 ]; then | |
| echo "=== tests failed after 3 attempts ===" | |
| exit 1 | |
| fi | |
| echo "=== test run crashed, retrying in 5s... ===" | |
| sleep 5 | |
| done | |
| # ── Job 4: Declarative API tests ─────────────────────────────────────── | |
| test-declarative: | |
| name: "Test: Declarative API" | |
| needs: build | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-mojo | |
| - name: Run declarative tests (with retry) | |
| run: | | |
| for attempt in 1 2 3; do | |
| echo "=== test attempt $attempt ===" | |
| if mojo run -I src -D ASSERT=all tests/test_declarative.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_hybrid.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_subcommands.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_subcommands_declarative.mojo \ | |
| && mojo run -I src -D ASSERT=all tests/test_schema_validation.mojo \ | |
| && bash tests/check_schema_errors.sh; then | |
| echo "=== tests passed on attempt $attempt ===" | |
| break | |
| fi | |
| if [ "$attempt" -eq 3 ]; then | |
| echo "=== tests failed after 3 attempts ===" | |
| exit 1 | |
| fi | |
| echo "=== test run crashed, retrying in 5s... ===" | |
| sleep 5 | |
| done | |
| # ── Job 5: Example binaries ──────────────────────────────────────────── | |
| test-examples: | |
| name: "Test: Examples" | |
| needs: build | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-mojo | |
| - name: Run example binaries (with retry) | |
| run: | | |
| for attempt in 1 2 3; do | |
| echo "=== debug attempt $attempt ===" | |
| if pixi run debug; then | |
| echo "=== debug passed on attempt $attempt ===" | |
| break | |
| fi | |
| if [ "$attempt" -eq 3 ]; then | |
| echo "=== debug failed after 3 attempts ===" | |
| exit 1 | |
| fi | |
| echo "=== debug run crashed, retrying in 5s... ===" | |
| sleep 5 | |
| done |