|
| 1 | +name: Install E2E |
| 2 | + |
| 3 | +# A real install, start to finish, on every OS and architecture CraftBot |
| 4 | +# ships for: the full locked dependency set, the Node sidecar and npm trees, |
| 5 | +# then the agent started headless until it reports ready and the browser UI |
| 6 | +# answers. Each job uses whatever Python the runner image ships with (never |
| 7 | +# actions/setup-python): the point is to prove that the Python a user |
| 8 | +# launches the install with does not matter. One job deliberately launches |
| 9 | +# it with an old Python 3.8. |
| 10 | +# |
| 11 | +# State goes to a throwaway CRAFTBOT_HOME, so runtimes, data and the ready |
| 12 | +# marker land in the job's temp directory. |
| 13 | + |
| 14 | +on: |
| 15 | + pull_request: |
| 16 | + paths: |
| 17 | + - "install.py" |
| 18 | + - "craftbot.py" |
| 19 | + - "run.py" |
| 20 | + - "main.py" |
| 21 | + - "installer/**" |
| 22 | + - "app/paths.py" |
| 23 | + - "app/provision/**" |
| 24 | + - "app/python_runtime.py" |
| 25 | + - "app/node_runtime.py" |
| 26 | + - "app/downloads.py" |
| 27 | + - "requirements.txt" |
| 28 | + - "requirements/**" |
| 29 | + - "agent-app/spec/**" |
| 30 | + - ".github/workflows/install-e2e.yml" |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +concurrency: |
| 34 | + group: install-e2e-${{ github.ref }} |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +jobs: |
| 38 | + install: |
| 39 | + name: Install E2E (${{ matrix.label }}) |
| 40 | + runs-on: ${{ matrix.os }} |
| 41 | + timeout-minutes: 90 |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + include: |
| 46 | + - os: windows-latest |
| 47 | + label: windows-x86_64 |
| 48 | + python: python |
| 49 | + - os: macos-15 |
| 50 | + label: macos-arm64 |
| 51 | + python: python3 |
| 52 | + - os: macos-15-intel |
| 53 | + label: macos-x86_64 |
| 54 | + python: python3 |
| 55 | + - os: ubuntu-22.04 |
| 56 | + label: linux-x86_64 |
| 57 | + python: python3 |
| 58 | + - os: ubuntu-24.04-arm |
| 59 | + label: linux-aarch64 |
| 60 | + python: python3 |
| 61 | + - os: ubuntu-22.04 |
| 62 | + label: linux-x86_64, launched with Python 3.8 |
| 63 | + python: python3.8 |
| 64 | + old_python: true |
| 65 | + |
| 66 | + env: |
| 67 | + PY: ${{ matrix.python }} |
| 68 | + # Output reaches the log as it happens, and box-drawing characters |
| 69 | + # survive a pipe on Windows. The launcher sets the same for its runs. |
| 70 | + PYTHONUNBUFFERED: "1" |
| 71 | + PYTHONIOENCODING: utf-8 |
| 72 | + READY_TIMEOUT: "900" |
| 73 | + |
| 74 | + defaults: |
| 75 | + run: |
| 76 | + shell: bash |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Install an old Python 3.8 to launch with |
| 83 | + if: matrix.old_python |
| 84 | + run: | |
| 85 | + sudo add-apt-repository -y ppa:deadsnakes/ppa |
| 86 | + sudo apt-get update |
| 87 | + sudo apt-get install -y python3.8 |
| 88 | +
|
| 89 | + - name: Prepare |
| 90 | + run: | |
| 91 | + set -euo pipefail |
| 92 | + # Forward slashes on Windows too: both bash and Python accept them. |
| 93 | + tmp="$RUNNER_TEMP" |
| 94 | + if command -v cygpath >/dev/null 2>&1; then tmp="$(cygpath -m "$tmp")"; fi |
| 95 | + mkdir -p "$tmp/craftbot-home" "$tmp/e2e-logs" |
| 96 | + echo "E2E_TMP=$tmp" >> "$GITHUB_ENV" |
| 97 | + echo "CRAFTBOT_HOME=$tmp/craftbot-home" >> "$GITHUB_ENV" |
| 98 | + echo "launching interpreter: $(command -v "$PY")" |
| 99 | + "$PY" -c 'import sys, platform; print(sys.version); print(platform.platform(), platform.machine())' |
| 100 | + echo "STARTED_AT=$(date +%s)" >> "$GITHUB_ENV" |
| 101 | +
|
| 102 | + # stdin is closed: an install that stops to ask a question fails here |
| 103 | + # instead of hanging, exactly as it would behind the setup window. |
| 104 | + - name: Install (install.py --no-launch) |
| 105 | + timeout-minutes: 60 |
| 106 | + run: | |
| 107 | + set -uo pipefail |
| 108 | + t0=$(date +%s) |
| 109 | + "$PY" install.py --no-launch < /dev/null 2>&1 | tee "$E2E_TMP/e2e-logs/install.log" |
| 110 | + code=${PIPESTATUS[0]} |
| 111 | + echo "T_INSTALL=$(( $(date +%s) - t0 ))" >> "$GITHUB_ENV" |
| 112 | + exit "$code" |
| 113 | +
|
| 114 | + - name: Start headless (craftbot.py start --no-open-browser) |
| 115 | + timeout-minutes: 20 |
| 116 | + run: | |
| 117 | + set -uo pipefail |
| 118 | + t0=$(date +%s) |
| 119 | + "$PY" craftbot.py start --no-open-browser < /dev/null 2>&1 | tee "$E2E_TMP/e2e-logs/start.log" |
| 120 | + code=${PIPESTATUS[0]} |
| 121 | + echo "T_START=$(( $(date +%s) - t0 ))" >> "$GITHUB_ENV" |
| 122 | + echo "READY_FROM=$t0" >> "$GITHUB_ENV" |
| 123 | + exit "$code" |
| 124 | +
|
| 125 | + - name: Wait for the agent to report ready |
| 126 | + run: | |
| 127 | + set -euo pipefail |
| 128 | + marker="$CRAFTBOT_HOME/.agent-ready" |
| 129 | + deadline=$(( READY_FROM + READY_TIMEOUT )) |
| 130 | + until [ -f "$marker" ]; do |
| 131 | + if [ "$(date +%s)" -ge "$deadline" ]; then |
| 132 | + echo "::error::$marker did not appear within ${READY_TIMEOUT}s of starting" |
| 133 | + exit 1 |
| 134 | + fi |
| 135 | + sleep 5 |
| 136 | + done |
| 137 | + echo "T_READY=$(( $(date +%s) - READY_FROM ))" >> "$GITHUB_ENV" |
| 138 | + echo "ready marker: $marker" |
| 139 | + for f in craftbot.pid ui.json; do |
| 140 | + if [ -f "$CRAFTBOT_HOME/$f" ]; then echo "$f: $(cat "$CRAFTBOT_HOME/$f")"; fi |
| 141 | + done |
| 142 | +
|
| 143 | + - name: The browser UI answers on port 7925 |
| 144 | + run: | |
| 145 | + set -uo pipefail |
| 146 | + t0=$(date +%s) |
| 147 | + code=000 |
| 148 | + for _ in $(seq 1 60); do |
| 149 | + code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 10 http://localhost:7925/ || true) |
| 150 | + [ "$code" = "200" ] && break |
| 151 | + sleep 2 |
| 152 | + done |
| 153 | + echo "T_HTTP=$(( $(date +%s) - t0 ))" >> "$GITHUB_ENV" |
| 154 | + echo "http://localhost:7925/ answered HTTP $code" |
| 155 | + [ "$code" = "200" ] || { echo "::error::http://localhost:7925/ answered HTTP $code, expected 200"; exit 1; } |
| 156 | +
|
| 157 | + - name: Stop |
| 158 | + if: always() |
| 159 | + run: | |
| 160 | + "$PY" craftbot.py stop < /dev/null || true |
| 161 | +
|
| 162 | + - name: Timings |
| 163 | + if: always() |
| 164 | + run: | |
| 165 | + total=$(( $(date +%s) - ${STARTED_AT:-$(date +%s)} )) |
| 166 | + { |
| 167 | + echo "### Install E2E timings: ${{ matrix.label }}" |
| 168 | + echo |
| 169 | + echo "Launched with \`$("$PY" --version 2>&1)\` ($PY)" |
| 170 | + echo |
| 171 | + echo "| Stage | Seconds |" |
| 172 | + echo "|---|---|" |
| 173 | + echo "| install.py --no-launch | ${T_INSTALL:-failed} |" |
| 174 | + echo "| craftbot.py start | ${T_START:-not reached} |" |
| 175 | + echo "| start to .agent-ready | ${T_READY:-not reached} |" |
| 176 | + echo "| ready to HTTP 200 on :7925 | ${T_HTTP:-not reached} |" |
| 177 | + echo "| total | $total |" |
| 178 | + } | tee -a "$GITHUB_STEP_SUMMARY" |
| 179 | +
|
| 180 | + - name: Collect logs |
| 181 | + if: failure() |
| 182 | + run: | |
| 183 | + logs="$E2E_TMP/e2e-logs" |
| 184 | + cp craftbot.log "$logs/" 2>/dev/null || true |
| 185 | + if [ -d "$CRAFTBOT_HOME/logs" ]; then cp -R "$CRAFTBOT_HOME/logs" "$logs/state-logs"; fi |
| 186 | + for f in craftbot.pid ui.json; do |
| 187 | + cp "$CRAFTBOT_HOME/$f" "$logs/" 2>/dev/null || true |
| 188 | + done |
| 189 | + tail -n 80 craftbot.log 2>/dev/null || true |
| 190 | +
|
| 191 | + - name: Upload logs |
| 192 | + if: failure() |
| 193 | + uses: actions/upload-artifact@v4 |
| 194 | + with: |
| 195 | + name: install-e2e-logs-${{ strategy.job-index }} |
| 196 | + path: ${{ runner.temp }}/e2e-logs |
| 197 | + if-no-files-found: ignore |
0 commit comments