Entry point: .gitlab-ci.yml. Jobs are split across this directory.
Also keep .github/workflows/test_esptool.yml in sync when changing install or test steps.
- MR / branch push — lint, install checks, tests, coverage report. Docs build/deploy when doc files change.
internal/dev_releasepush — above plus preview package build (manual publish). The preview build does not wait on earlier jobs or use their artifacts, so a lint, test, or runner failure still leaves the manual publish available. Publish still downloads the sdist from that build.- Nightly schedule (
STUB_CANARY=1) — stub canary only; see Canary.
Push pipelines are skipped when an open MR already exists for the branch.
pre-check → check → test → report
Optional: build_docs → deploy_docs, deploy_development_package.
Canary adds canary_prep before and canary_post, canary_report after.
| File | Purpose |
|---|---|
danger.yml |
Danger MR linter (internal shared-ci-dangerjs include + its job override); skipped on bot/sync-master (see Sync to internal) |
checks.yml |
Install smoke tests, stub freshness |
host_tests.yml |
Linux + Windows host pytest jobs |
target_tests.yml |
Hardware tests per board (target_<chip> jobs), Windows smoke on COM4 |
canary.yml |
Nightly stub compatibility |
deploy_docs.yml |
Docs build and deploy |
internal_release.yml |
Internal preview sdist |
sync_to_internal.yml |
On each merge to master, open/refresh the review MR syncing master → internal/dev_release (see Sync to internal) |
Python images: PYTHON_IMAGE_MIN and PYTHON_IMAGE_LATEST in .gitlab-ci.yml. Canary jobs use CANARY_IMAGE (ubuntu:24.04).
pre-check — Danger MR linter, pre-commit.
check — Package installs (pip install / -e / venv / --user), CLI --help, stub freshness, UF2 ID test.
test — Host tests (pytest -m host_test on Linux; -m "host_test and not linux_host_test" on Windows — tests marked linux_host_test are excluded; see test/conftest.py), espefuse matrix, hardware jobs in target_tests.yml (-m "not host_test" — host-only cases run in host_tests instead), Windows quick_test smoke on COM4.
report — combine_reports merges coverage from test jobs.
Failures are retried at two levels:
- Job retry.
.target_test(target_tests.yml) and.windows_test(.gitlab-ci.yml) retry a job once onrunner_system_failure,scheduler_failureorapi_failure. This covers everytarget_<chip>job,target_tests_windowsandhost_tests_windows. Timeouts are not retried: the 60 min timeouts onesp32andesp8266came from boards dropping mid-run, and a retry costs another hour. - Test rerun inside the job. Outside the stub canary, a hardware test (a class derived from
EsptoolTestCaseintest/test_esptool.pyortest/test_esptool_sdm.py) that fails on a serial-link or port error is rerun up to 2 times, 5 s apart (flakymark withonly_rerun=TRANSPORT_ERRORS). Assertion failures and boards that cannot be reached are not rerun, unless the assertion message quotes a matching esptool error.TestReset::test_watchdog_resetis the exception: its own mark reruns any failure, because its known failure onesp32c5_32mbis an assertion.
The number of reruns per job has no cap. On a link that still connects but often fails, a slow job such as target_esp32 or target_esp8266 (about 30 min median) could rerun many tests and reach the 60 min timeout. pytest is then killed and writes no test/report.xml. This has not been observed.
With pytest-rerunfailures, each attempt is written to test/report.xml as its own <testcase>. When a test passes on a rerun, every entry is marked passed. When every attempt fails, the earlier entries are marked passed and the last one failed. The GitLab test report view therefore shows rerun attempts as passed tests. The error of a rerun attempt is only in the job log: in the output printed while the attempt ran, and as a traceback in the "rerun test summary info" section (-rR lists the attempts, --rerun-show-tracebacks in addopts adds their tracebacks). The stub canary turns the in-job reruns off, so its reports hold no such entries.
Nightly job that builds fresh v2 stubs from esp-stub-lib and runs the full test suite against them. All canary jobs use $CANARY_IMAGE (ubuntu:24.04).
canary_poll— skip if SHA unchanged (cancels pipeline)canary_build_stubs→canary_patch— build stubs, patch into tree- Normal test jobs (after
canary_prepvia stage order; patched stubs passed as artifacts), with failed tests rerun to separate stub breakage from other failures canary_record— save SHA on successcanary_on_failure(own last stagecanary_report) — open or update an issue when a job fails
Failure reporting: canary_on_failure has no needs:. A job with needs: reacts only to the jobs it lists and is skipped when one of them is skipped, so it would miss test-job failures and every failure that skips canary_record. It sits in a stage after canary_post because when: on_failure ignores failures in its own stage. The script lists the pipeline's failed jobs through the API and picks the issue title from them: a prep job failed (canary_poll, canary_build_stubs, canary_patch), a test job found stub breakage, a test job ran out of time, a test job failed before the comparison, a check-stage install job's script failed (no stub was tested), or canary_record failed. The jobs API does not give a job's exit code, so for each test job whose script failed the reporter downloads the outcome that canary_pytest.py writes to the artifact test/canary-outcome.txt (see below). The body lists every failed job with its failure reason and, for test jobs, that outcome. When the outcome file exists but cannot be downloaded after a retry, the issue gets the "cause not determined" title unless another test job found breakage, because the job may have found stub breakage. When test jobs only hit CI infrastructure problems (timeouts, missing runners, runner errors), the script logs them and opens no issue: those jobs never compared the stubs, and the same SHA is tested again the next night.
Test failures: most canary test failures are serial link errors or offline boards, not stub breakage. In the canary, the host and hardware test jobs run ci/canary_pytest.py instead of plain pytest:
| Failure | Rerun with fresh stubs | Rerun with committed stubs | Job result | Outcome |
|---|---|---|---|---|
| Random hardware failure | passes | not run | passes | pass |
| Board offline, port busy | fails | fails | exit code 75, allowed failure | not-the-stubs |
| Stub breakage | fails | passes | fails, reported as stub breakage | breakage |
| Tests too slow for the job time (first run or rerun not finished) | not run or not finished | not run | fails, reported as out of time | no-time |
| Failed tests too slow to compare | fails | not run, or not finished with no test passed | fails, reported as out of time | no-time |
before_script error |
not run | not run | fails, reported as failed before the comparison | no file |
| pytest error (exit 2–5), git or JUnit report error | any | any | fails, reported as failed before the comparison | error |
Only the failed tests are rerun (pytest --lf). The in-job reruns of the flaky marks in test/test_esptool.py (see Retries) are turned off when STUB_CANARY=1. The rerun above still hides a stub that fails only sometimes (see the known limits below). Without the in-job reruns, a stub that sometimes fails with a transport error is reported when both canary attempts fail; with them, all 6 runs would have to fail. First-run failures also stay in test/report-first.xml, and rerun time stays out of the duration estimate below. The committed stubs are restored with git checkout, which takes effect because the jobs install esptool in editable mode. Exit code 75 is listed in allow_failure:exit_codes, so it does not trigger canary_on_failure; the pipeline ends green with warnings and canary_record saves the SHA. test/report.xml holds the last run with the fresh stubs; test/report-first.xml, test/report-committed.xml and test/canary-outcome.txt are kept as artifacts.
A job killed by the 1 h job timeout counts as CI infrastructure and is not reported, and the next night would test the same SHA and time out again. canary_pytest.py therefore interrupts each pytest run 5 minutes before the job timeout and fails the job with the outcome no-time. The interrupt is repeated every 15 s, because one that arrives while a test runs esptool.main() in the pytest process only fails that test; pytest is killed after 60 s. When more than 5 tests fail, the rerun with the fresh stubs is skipped; random failures hit 1–3 tests per job. Before the rerun with the committed stubs, the script estimates its time as twice the sum of the failed tests' durations, taking for each test the longer of its durations in the runs with the fresh stubs; when less time is left, the job fails with no-time without the comparison. A test that passes with the committed stubs before an interruption still counts as stub breakage.
Known limits:
- A stub bug that breaks communication only sometimes passes the rerun and is not reported.
- A test that fails twice with the fresh stubs for another reason and then passes with the committed stubs (a random failure, a board that comes back) is reported as stub breakage.
- When more than 5 tests fail, a test that fails once at random with the fresh stubs and passes with the committed stubs is reported as stub breakage.
- The
no-timeoutcome does not show that the fresh stubs are at fault: slow boards or runners cause it too. - A job whose
before_scriptruns into GitLab's job timeout is still killed by GitLab and only logged. - The time limits apply only when GitLab sets
CI_JOB_TIMEOUTandCI_JOB_STARTED_AT.
Quiet nights: if LAST_TESTED_STUB_LIB_SHA is unchanged, canary_poll cancels the pipeline before build/tests run. canary_on_failure does not run on cancel, so no spurious issues are opened.
Attribution: only esp-stub-lib is tracked across runs; esp-flasher-stub is rebuilt from master each night, so a test failure can come from either. Issue titles name neither repository; both SHAs appear in the issue body.
CI variables: STUB_CANARY (on the schedule, not project-wide), LAST_TESTED_STUB_LIB_SHA (auto-created by canary_record), GITLAB_API_TOKEN (api scope, Maintainer+ — cancel on quiet nights and record SHA), optional MAINTAINERS.
open_sync_mr (in sync_to_internal.yml) runs on every push to master — i.e. each MR merge. It keeps a single rolling review MR that brings internal/dev_release up to master:
- Clean merge — prepares the
master→internal/dev_releasemerge on the unprotectedbot/sync-masterbranch, then find-or-creates ONE MR intointernal/dev_releasewith$MAINTAINERSas reviewers, and links it back on the just-mergedmasterMR. A maintainer checks the MR's pipeline and merges it — the only write tointernal/dev_release. - Conflict — no MR is opened (it would only sit unmergeable); the bot comments on the original
masterMR naming the conflicting files with a bounded hunk preview and cc'ing$MAINTAINERS.
The bot never merges the sync MR or pushes to internal/dev_release. bot/sync-master stays unprotected so it never reaches the GitHub mirror. Logic lives in ci/sync_to_internal.py; SYNC_DRY_RUN=1 logs the intended actions without performing them.
Danger on the sync MR: the danger.yml include is guarded by include:rules and skipped on bot/sync-master. That pipeline runs under the sync bot's project access token, which can't read the internal shared-ci-dangerjs project; resolving the cross-project include under it fails config compilation (config_error, 0 jobs). The include and its run-danger-mr-linter override live together in danger.yml so include:rules can skip both at once — guarding only the include would leave the override as a scriptless job (its script comes from the include), itself a config_error. The guard keys on CI_COMMIT_REF_NAME (the source branch on both push and merge-request pipelines, and one of the few variables allowed in include:rules). The trade-off is that the sync MR's pipeline no longer runs the Danger linter — acceptable, since it only mirrors already-reviewed master MRs.
CI variables: GITLAB_API_TOKEN (api scope; reuses the shared canary token, but every action here — API calls plus the push to the unprotected bot/sync-master — needs only the Developer role), optional MAINTAINERS, optional SYNC_DRY_RUN.
host_test— Linux Dockeresptool-*— per-board hardware (seetarget_tests.yml)windows-target— Windowsdangerjs,build_docs,deploy— specialised jobs