From e2242e0d1561d376341184761aae5d5cec08f8b0 Mon Sep 17 00:00:00 2001 From: ZHU Yuhao Date: Fri, 10 Apr 2026 20:55:52 +0200 Subject: [PATCH 1/5] Split the tasks into 5 --- .github/workflows/run_tests.yaml | 187 +++++++++++++++++++++++++------ 1 file changed, 155 insertions(+), 32 deletions(-) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index a6eed85..0e53582 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -10,44 +10,37 @@ permissions: contents: read pull-requests: read -jobs: - testing-argmojo: - name: Test with ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["macos-latest"] - - runs-on: ${{ matrix.os }} - timeout-minutes: 15 - - defaults: - run: - shell: bash - env: - DEBIAN_FRONTEND: noninteractive +defaults: + run: + shell: bash +jobs: + # ── Job 1: Format + Package ──────────────────────────────────────────── + build: + name: Build & Format + runs-on: macos-latest + timeout-minutes: 10 steps: - - name: Checkout repo - uses: actions/checkout@v4 - + - uses: actions/checkout@v4 - name: Install pixi - run: | - curl -fsSL https://pixi.sh/install.sh | sh - + run: curl -fsSL https://pixi.sh/install.sh | sh - name: Add pixi to PATH run: | echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV - echo "$HOME/.pixi/bin" >> $GITHUB_PATH - - - name: Pixi install + echo "$HOME/.pixi/bin" >> $GITHUB_PATH + - name: pixi install + run: pixi install + - name: Format check run: | - pixi install - - - name: Build package (with retry for Mojo compiler intermittent crashes) + 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 "=== mojo package attempt $attempt ===" + echo "=== package attempt $attempt ===" if pixi run package; then echo "=== package succeeded on attempt $attempt ===" break @@ -60,11 +53,119 @@ jobs: sleep 5 done - - name: Run tests (with retry for Mojo compiler intermittent crashes) + # ── Job 2: Core parsing tests ────────────────────────────────────────── + test-core: + name: "Test: Core Parsing" + runs-on: macos-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install pixi + run: curl -fsSL https://pixi.sh/install.sh | sh + - name: Add pixi to PATH + run: | + echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV + echo "$HOME/.pixi/bin" >> $GITHUB_PATH + - name: pixi install + run: pixi install + - name: Build package (with retry) + run: | + for attempt in 1 2 3; do + if pixi run package; then break; fi + if [ "$attempt" -eq 3 ]; then exit 1; fi + sleep 5 + done + - 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" + runs-on: macos-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install pixi + run: curl -fsSL https://pixi.sh/install.sh | sh + - name: Add pixi to PATH + run: | + echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV + echo "$HOME/.pixi/bin" >> $GITHUB_PATH + - name: pixi install + run: pixi install + - name: Build package (with retry) + run: | + for attempt in 1 2 3; do + if pixi run package; then break; fi + if [ "$attempt" -eq 3 ]; then exit 1; fi + sleep 5 + done + - 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" + runs-on: macos-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install pixi + run: curl -fsSL https://pixi.sh/install.sh | sh + - name: Add pixi to PATH + run: | + echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV + echo "$HOME/.pixi/bin" >> $GITHUB_PATH + - name: pixi install + run: pixi install + - name: Build package (with retry) + run: | + for attempt in 1 2 3; do + if pixi run package; then break; fi + if [ "$attempt" -eq 3 ]; then exit 1; fi + sleep 5 + done + - name: Run declarative tests (with retry) run: | for attempt in 1 2 3; do echo "=== test attempt $attempt ===" - if pixi run test; then + 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 @@ -76,7 +177,29 @@ jobs: sleep 5 done - - name: Run example binaries in debug mode (catches developer-facing validation errors) + # ── Job 5: Example binaries ──────────────────────────────────────────── + test-examples: + name: "Test: Examples" + runs-on: macos-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install pixi + run: curl -fsSL https://pixi.sh/install.sh | sh + - name: Add pixi to PATH + run: | + echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV + echo "$HOME/.pixi/bin" >> $GITHUB_PATH + - name: pixi install + run: pixi install + - name: Build package (with retry) + run: | + for attempt in 1 2 3; do + if pixi run package; then break; fi + if [ "$attempt" -eq 3 ]; then exit 1; fi + sleep 5 + done + - name: Run example binaries (with retry) run: | for attempt in 1 2 3; do echo "=== debug attempt $attempt ===" From a1ec4532b99b902bbc5e1381dadf987adb93de88 Mon Sep 17 00:00:00 2001 From: ZHU Yuhao Date: Fri, 10 Apr 2026 21:08:30 +0200 Subject: [PATCH 2/5] Update workflow --- .github/workflows/run_tests.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 0e53582..79bd37b 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -79,9 +79,9 @@ jobs: 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 + if pixi run mojo run -I src -D ASSERT=all tests/test_parse.mojo \ + && pixi run mojo run -I src -D ASSERT=all tests/test_options.mojo \ + && pixi run mojo run -I src -D ASSERT=all tests/test_groups.mojo; then echo "=== tests passed on attempt $attempt ===" break fi @@ -119,10 +119,10 @@ jobs: 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 + if pixi run mojo run -I src -D ASSERT=all tests/test_help.mojo \ + && pixi run mojo run -I src -D ASSERT=all tests/test_completion.mojo \ + && pixi run mojo run -I src -D ASSERT=all tests/test_interactive.mojo < /dev/null \ + && pixi run mojo run -I src -D ASSERT=all tests/test_wrappers.mojo; then echo "=== tests passed on attempt $attempt ===" break fi @@ -160,11 +160,11 @@ jobs: 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 \ + if pixi run mojo run -I src -D ASSERT=all tests/test_declarative.mojo \ + && pixi run mojo run -I src -D ASSERT=all tests/test_hybrid.mojo \ + && pixi run mojo run -I src -D ASSERT=all tests/test_subcommands.mojo \ + && pixi run mojo run -I src -D ASSERT=all tests/test_subcommands_declarative.mojo \ + && pixi run 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 From 01ed12eebd93e0891caf73dbee93341e910b6671 Mon Sep 17 00:00:00 2001 From: ZHU Yuhao Date: Fri, 10 Apr 2026 21:16:05 +0200 Subject: [PATCH 3/5] Address comments --- .github/actions/setup-mojo/action.yml | 18 +++++ .github/workflows/run_tests.yaml | 103 ++++++-------------------- 2 files changed, 41 insertions(+), 80 deletions(-) create mode 100644 .github/actions/setup-mojo/action.yml diff --git a/.github/actions/setup-mojo/action.yml b/.github/actions/setup-mojo/action.yml new file mode 100644 index 0000000..8ad1c8b --- /dev/null +++ b/.github/actions/setup-mojo/action.yml @@ -0,0 +1,18 @@ +name: Setup Mojo with Pixi +description: Install pixi, activate the Mojo environment, and build the argmojo package + +runs: + using: composite + steps: + - uses: prefix-dev/setup-pixi@v0.9.5 + with: + cache: true + activate-environment: true + - name: Build package (with retry) + shell: bash + run: | + for attempt in 1 2 3; do + if pixi run package; then break; fi + if [ "$attempt" -eq 3 ]; then exit 1; fi + sleep 5 + done diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 79bd37b..39b653f 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -22,14 +22,9 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - name: Install pixi - run: curl -fsSL https://pixi.sh/install.sh | sh - - name: Add pixi to PATH - run: | - echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV - echo "$HOME/.pixi/bin" >> $GITHUB_PATH - - name: pixi install - run: pixi install + - uses: prefix-dev/setup-pixi@v0.9.5 + with: + cache: true - name: Format check run: | pixi run format @@ -56,32 +51,19 @@ jobs: # ── 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 - - name: Install pixi - run: curl -fsSL https://pixi.sh/install.sh | sh - - name: Add pixi to PATH - run: | - echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV - echo "$HOME/.pixi/bin" >> $GITHUB_PATH - - name: pixi install - run: pixi install - - name: Build package (with retry) - run: | - for attempt in 1 2 3; do - if pixi run package; then break; fi - if [ "$attempt" -eq 3 ]; then exit 1; fi - sleep 5 - done + - uses: ./.github/actions/setup-mojo - name: Run core tests (with retry) run: | for attempt in 1 2 3; do echo "=== test attempt $attempt ===" - if pixi run mojo run -I src -D ASSERT=all tests/test_parse.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_options.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_groups.mojo; then + 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 @@ -96,33 +78,20 @@ jobs: # ── Job 3: Feature tests ─────────────────────────────────────────────── test-features: name: "Test: Features" + needs: build runs-on: macos-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 - - name: Install pixi - run: curl -fsSL https://pixi.sh/install.sh | sh - - name: Add pixi to PATH - run: | - echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV - echo "$HOME/.pixi/bin" >> $GITHUB_PATH - - name: pixi install - run: pixi install - - name: Build package (with retry) - run: | - for attempt in 1 2 3; do - if pixi run package; then break; fi - if [ "$attempt" -eq 3 ]; then exit 1; fi - sleep 5 - done + - uses: ./.github/actions/setup-mojo - name: Run feature tests (with retry) run: | for attempt in 1 2 3; do echo "=== test attempt $attempt ===" - if pixi run mojo run -I src -D ASSERT=all tests/test_help.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_completion.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_interactive.mojo < /dev/null \ - && pixi run mojo run -I src -D ASSERT=all tests/test_wrappers.mojo; then + 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 @@ -137,34 +106,21 @@ jobs: # ── 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 - - name: Install pixi - run: curl -fsSL https://pixi.sh/install.sh | sh - - name: Add pixi to PATH - run: | - echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV - echo "$HOME/.pixi/bin" >> $GITHUB_PATH - - name: pixi install - run: pixi install - - name: Build package (with retry) - run: | - for attempt in 1 2 3; do - if pixi run package; then break; fi - if [ "$attempt" -eq 3 ]; then exit 1; fi - sleep 5 - done + - uses: ./.github/actions/setup-mojo - name: Run declarative tests (with retry) run: | for attempt in 1 2 3; do echo "=== test attempt $attempt ===" - if pixi run mojo run -I src -D ASSERT=all tests/test_declarative.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_hybrid.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_subcommands.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_subcommands_declarative.mojo \ - && pixi run mojo run -I src -D ASSERT=all tests/test_schema_validation.mojo \ + 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 @@ -180,25 +136,12 @@ jobs: # ── Job 5: Example binaries ──────────────────────────────────────────── test-examples: name: "Test: Examples" + needs: build runs-on: macos-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 - - name: Install pixi - run: curl -fsSL https://pixi.sh/install.sh | sh - - name: Add pixi to PATH - run: | - echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV - echo "$HOME/.pixi/bin" >> $GITHUB_PATH - - name: pixi install - run: pixi install - - name: Build package (with retry) - run: | - for attempt in 1 2 3; do - if pixi run package; then break; fi - if [ "$attempt" -eq 3 ]; then exit 1; fi - sleep 5 - done + - uses: ./.github/actions/setup-mojo - name: Run example binaries (with retry) run: | for attempt in 1 2 3; do From 8f70a7f8b283baa7923cf993f07a1f4787bb8791 Mon Sep 17 00:00:00 2001 From: ZHU Yuhao Date: Fri, 10 Apr 2026 21:25:01 +0200 Subject: [PATCH 4/5] Address comments --- .github/workflows/run_tests.yaml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 39b653f..b088b40 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -15,9 +15,9 @@ defaults: shell: bash jobs: - # ── Job 1: Format + Package ──────────────────────────────────────────── + # ── Job 1: Format gate ────────────────────────────────────────────────── build: - name: Build & Format + name: Format Check runs-on: macos-latest timeout-minutes: 10 steps: @@ -32,21 +32,6 @@ jobs: 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: From bf8fa9e815db32471694a483b97bbeceb3790da7 Mon Sep 17 00:00:00 2001 From: ZHU Yuhao Date: Fri, 10 Apr 2026 21:27:55 +0200 Subject: [PATCH 5/5] Reset the changes --- .github/workflows/run_tests.yaml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index b088b40..57ff7d3 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -15,9 +15,11 @@ defaults: shell: bash jobs: - # ── Job 1: Format gate ────────────────────────────────────────────────── + # ── 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: Format Check + name: Build & Format runs-on: macos-latest timeout-minutes: 10 steps: @@ -32,6 +34,21 @@ jobs: 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: