From 794acd8fe0c3062a3387c18fba6c1ed2583f2644 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Mon, 23 Nov 2026 01:18:49 +0900 Subject: [PATCH 1/3] CI: a pull request runs Linux x86-64 only, the full matrix runs on main, nightly and with the label ci:full (#442) A ready pull request started 42 jobs and waited a median of 70.9 minutes for the last one; 46% of the job time was queueing, mostly for the macOS runners the organisation shares with ArcadeData/arcadedb (issue 442 has the measurement). In 30 days no pull request had another platform catch a bug of its own change: the four commits that were red only outside Linux x86-64 were intermittent vector failures on docs and tooling branches. Two tiers: - fast, every pull request: the static checks, and on linux/amd64 only the arcadedb-jvm wheel with the tests on the oldest and the newest Python and the examples on the newest, and (when a native path changed) the native image and wheel with parity and examples on Python 3.12. 20 jobs instead of 42 (14 instead of 31 when no native path changed). - full: push to main, nightly, dispatch and release keep the legs they had. A pull request with the label ci:full, and one Dependabot opened (the hourly job merges it without a reader), runs the legs of a push to main. scripts/ci_tier.py decides the tier of a pull request and hands the planners the event pull_request or pull_request_full. It reads the labels again from the API, because a re-run keeps the event of the first attempt: adding the label and re-running is enough. It fails open (labels not readable: full tier). The label is not a trigger: a `labeled` trigger would start a run for every label, and a run whose jobs are all skipped would replace red checks with skipped ones. The summary jobs keep their logic: their legs are matrix jobs, so a smaller matrix gives the same one-word result, red when a started leg failed or was cancelled. The pyver job of test-native.yml has no legs in the fast tier and is skipped (an empty matrix is an error); no job needs it, and the release still requires its markers. The summaries no longer say "all platforms" when one platform ran. The README gets a badge for test-python-examples.yml, so each of the three test workflows shows its last run on main. --- .github/workflows/test-jvm.yml | 33 ++-- .github/workflows/test-native.yml | 20 ++- .github/workflows/test-python-examples.yml | 31 ++-- CONTRIBUTING.md | 10 ++ README.md | 3 +- docs/modules/ROOT/pages/development/ci.adoc | 38 +++-- scripts/ci_tier.py | 126 +++++++++++++++ scripts/select_matrix.py | 59 ++++--- scripts/select_native_matrix.py | 24 ++- tests/test_ci_tier.py | 171 ++++++++++++++++++++ tests/test_select_matrix.py | 61 ++++++- tests/test_select_native_matrix.py | 63 +++++++- 12 files changed, 559 insertions(+), 80 deletions(-) create mode 100644 scripts/ci_tier.py create mode 100644 tests/test_ci_tier.py diff --git a/.github/workflows/test-jvm.yml b/.github/workflows/test-jvm.yml index ba1b0584..2976b0bd 100644 --- a/.github/workflows/test-jvm.yml +++ b/.github/workflows/test-jvm.yml @@ -255,9 +255,13 @@ jobs: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - # The platform x Python legs of this run (scripts/select_matrix.py): a small matrix on - # pull requests, the full one on every other event. The organisation shares one runner - # cap with ArcadeData/arcadedb, so a pull request does not run every combination. + # The platform x Python legs of this run (scripts/select_matrix.py). A pull request runs + # the fast tier (linux/amd64 only); every other event runs the legs of the full tier. The + # organisation shares one runner cap with ArcadeData/arcadedb, so a pull request does not + # wait for the macOS and Windows runners. A pull request with the label ci:full, and one + # Dependabot opened, runs the legs of a push to main: scripts/ci_tier.py turns its event + # into pull_request_full (it reads the labels again from the API, so a re-run after adding + # the label is enough). # The wheel matrix is the platforms of those legs, one build each: the wheel is # py3-none-, the same file for every Python. # Done first, so a failure here costs no Docker pull. @@ -267,7 +271,13 @@ jobs: env: # In a workflow_call github.event_name is the caller's event (a tag push), so a release says so through its input EVENT_NAME: ${{ inputs.release && 'release' || github.event_name }} + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} run: | + EVENT_NAME="$(python3 scripts/ci_tier.py "$EVENT_NAME")" + echo "legs of the event: $EVENT_NAME" matrix="$(python3 scripts/select_matrix.py jvm --event "$EVENT_NAME")" wheel_matrix="$(python3 scripts/select_matrix.py jvm --event "$EVENT_NAME" --wheels)" echo "$matrix" @@ -447,7 +457,8 @@ jobs: fail-fast: false # Chosen by the "Select the test matrix" step of download-jars from the event that # started the run (scripts/select_matrix.py holds the platform and Python lists): - # small on pull requests, the full 4 platforms x 4 Pythons on every other event. + # linux/amd64 on the oldest and the newest Python on a pull request (the fast tier), 10 legs + # on a push to main and the nightly run, the full 4 platforms x 4 Pythons on a release and a manual run. # Every leg carries platform, runs-on and python-version, so the job names stay # "Test arcadedb (, Python )". matrix: ${{ fromJSON(needs.download-jars.outputs.matrix) }} @@ -757,7 +768,9 @@ jobs: .coverage retention-days: 7 - # Summary job that checks all platforms + # Summary job that checks every leg this run started. `build` and `test` are matrices, so the result of each is "success" only when + # every leg of it passed, whatever their number: 1 build and 2 test legs on a pull request (the fast tier), 4 and 10 or 16 on the + # other events. A leg that failed, was cancelled or never started (its build failed) makes the result something else, and this job red. test-summary: name: Test Summary needs: [build, test] @@ -771,17 +784,19 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY if [ "${{ needs.build.result }}" = "success" ] && [ "${{ needs.test.result }}" = "success" ]; then - echo "✅ **All platforms passed testing!**" >> $GITHUB_STEP_SUMMARY + echo "✅ **Every leg of this run passed testing!**" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "The arcadedb package has been successfully built (one py3-none wheel for each platform) and tested." >> $GITHUB_STEP_SUMMARY + echo "The arcadedb package has been successfully built (one py3-none wheel for each platform of this run) and tested." >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**Package**: arcadedb" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "ℹ️ **Note**: Some platform/Python combinations are excluded from testing:" >> $GITHUB_STEP_SUMMARY + echo "**Legs**: a pull request runs linux/amd64 only (the fast tier). A push to main, the nightly run, a manual run and a pull request with the label ci:full run every platform. The jobs of this run list its legs." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "ℹ️ **Note**: Some platform/Python combinations are excluded from testing on every event:" >> $GITHUB_STEP_SUMMARY echo "- Windows ARM64 (GitHub-hosted windows-11-arm runners exist, but jpype1 1.7.1 ships no win_arm64 wheel and GraalVM CE 25.4.4.1.1 has no Windows ARM64 build, so neither package can be built there)" >> $GITHUB_STEP_SUMMARY echo "- macOS x86_64 (temporarily disabled)" >> $GITHUB_STEP_SUMMARY else - echo "❌ **Some platforms failed testing**" >> $GITHUB_STEP_SUMMARY + echo "❌ **Some legs failed testing**" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "Please check the individual test jobs for details." >> $GITHUB_STEP_SUMMARY exit 1 diff --git a/.github/workflows/test-native.yml b/.github/workflows/test-native.yml index d6622be6..2463bea9 100644 --- a/.github/workflows/test-native.yml +++ b/.github/workflows/test-native.yml @@ -4,7 +4,8 @@ # # A native image build takes about 5 to 30 minutes per platform and the ArcadeData organisation shares a runner cap with # upstream ArcadeDB, so the load is selective (scripts/select_native_matrix.py holds the legs, tests/test_select_native_matrix.py pins them): -# pull request only when a native path changed (the `paths` filter below); linux-x86_64, Python 3.12; not for a draft +# pull request only when a native path changed (the `paths` filter below); linux-x86_64, Python 3.12 (the fast tier); not for a draft. +# With the label ci:full, or opened by Dependabot: the legs of a push to main (scripts/ci_tier.py) # push to main only when a native path changed; all four platforms, Python 3.12 and 3.14 # nightly all four platforms, Python 3.12 and 3.14, but only when something besides docs changed in the last 25 hours (a full run on Mondays) # dispatch all four platforms, Python 3.12 and 3.14 @@ -12,7 +13,7 @@ # This workflow never publishes: it has no id-token permission and no environment. # # Beside the full parity runs, the `pyver` job installs the already built linux-x86_64 wheel (py3-none: no rebuild) into the Pythons the full -# runs of the event leave out (a pull request: 3.11, 3.13, 3.14; main, nightly, dispatch: 3.11, 3.13; a release: none), into 3.15 (always: the full suite +# runs of the event leave out (main, nightly, dispatch: 3.11, 3.13; a release: none; a pull request has no `pyver` legs, the fast tier is one Python), into 3.15 (the full suite # needs jpype1 and ladybug, which have no cp315 wheel yet, so 3.15 runs without the test files that need jpype1) and into the free-threaded 3.14t, and runs a small subset of the tests there (about 20 s of tests per Python). A release needs it: a leg that passes uploads a marker (native-passed-pyver-py), and release-native.yml # publishes nothing unless the legs of a release (3.15 and the free-threaded 3.14t) passed. Only linux-x86_64 is checked on them. # scripts/select_native_matrix.py decides its legs. @@ -52,6 +53,7 @@ on: - "src/arcadedb/**" - "tests/**" - "scripts/select_native_matrix.py" + - "scripts/ci_tier.py" - "scripts/smoke_wheel.py" - "scripts/run_examples.sh" - "scripts/native_examples_skip.txt" @@ -225,10 +227,18 @@ jobs: EVENT: ${{ github.event_name }} RELEASE: ${{ inputs.release }} LEGS: ${{ inputs.legs }} + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} run: | set -euo pipefail run=true - event="$EVENT" + # A pull request runs the fast tier (one platform, one Python). With the label ci:full, or opened by Dependabot, it runs the legs + # of a push to main: scripts/ci_tier.py turns its event into pull_request_full (it reads the labels again from the API, so a re-run + # after adding the label is enough). Every other event passes through unchanged. + event="$(python3 -I scripts/ci_tier.py "$EVENT")" + echo "legs of the event: $event" if [ "$RELEASE" = true ]; then event=release; fi # a manual run may ask for the legs of a pull request (one platform, one Python): the runner cap is shared with upstream if [ "$EVENT" = workflow_dispatch ] && [ "${LEGS:-full}" = pull-request ]; then event=pull_request; fi @@ -980,7 +990,9 @@ jobs: name: Python ${{ matrix.python }} on the wheel (linux-x86_64) needs: [plan, build] # The linux-x86_64 build may have failed: then there is no wheel to download and this shows red, as the test job does. - if: ${{ !cancelled() && needs.plan.outputs.run == 'true' }} + # A pull request (the fast tier) has no legs here: the list is empty and the job is skipped, because an empty matrix is an error. + # No other job needs this one, so a skipped pyver job changes no summary. + if: ${{ !cancelled() && needs.plan.outputs.run == 'true' && needs.plan.outputs.pyver != '[]' }} runs-on: ubuntu-latest timeout-minutes: 20 defaults: diff --git a/.github/workflows/test-python-examples.yml b/.github/workflows/test-python-examples.yml index 76e1b5f1..02458f8d 100644 --- a/.github/workflows/test-python-examples.yml +++ b/.github/workflows/test-python-examples.yml @@ -138,9 +138,13 @@ jobs: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - # The platform x Python legs of this run (scripts/select_matrix.py): a small matrix on - # pull requests, the full one on every other event. The organisation shares one runner - # cap with ArcadeData/arcadedb, so a pull request does not run every combination. + # The platform x Python legs of this run (scripts/select_matrix.py). A pull request runs + # the fast tier (linux/amd64, the newest Python); every other event runs the full matrix. + # The organisation shares one runner cap with ArcadeData/arcadedb, so a pull request does + # not wait for the macOS and Windows runners. A pull request with the label ci:full, and + # one Dependabot opened, runs the legs of a push to main: scripts/ci_tier.py turns its + # event into pull_request_full (it reads the labels again from the API, so a re-run after + # adding the label is enough). # The wheel matrix is the platforms of those legs, one build each: the wheel is # py3-none-, the same file for every Python. # Done first, so a failure here costs no Docker pull. @@ -149,7 +153,13 @@ jobs: shell: bash env: EVENT_NAME: ${{ github.event_name }} + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} run: | + EVENT_NAME="$(python3 scripts/ci_tier.py "$EVENT_NAME")" + echo "legs of the event: $EVENT_NAME" matrix="$(python3 scripts/select_matrix.py examples --event "$EVENT_NAME")" wheel_matrix="$(python3 scripts/select_matrix.py examples --event "$EVENT_NAME" --wheels)" echo "$matrix" @@ -331,7 +341,8 @@ jobs: fail-fast: false # Chosen by the "Select the test matrix" step of download-jars from the event that # started the run (scripts/select_matrix.py holds the platform and Python lists): - # small on pull requests, the full 4 platforms x 4 Pythons on every other event. + # linux/amd64 on the newest Python on a pull request (the fast tier), the full + # 4 platforms x 4 Pythons on every other event. # Every leg carries platform, runs-on and python-version, so the job names stay # "Test Python Examples (, Python )". matrix: ${{ fromJSON(needs.download-jars.outputs.matrix) }} @@ -574,7 +585,9 @@ jobs: if-no-files-found: ignore retention-days: 14 - # Summary job that checks all platforms + # Summary job that checks every leg this run started. The legs are a matrix, so the result of the job is "success" only when + # every leg of it passed, whatever their number: one leg on a pull request (the fast tier), 16 on the other events. A leg that + # failed, was cancelled or never started (its build failed) makes the result something else, and this job red. test-examples-summary: name: Examples Test Summary needs: [build, test-examples] @@ -589,13 +602,13 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY if [ "${{ needs.build.result }}" = "success" ] && [ "${{ needs.test-examples.result }}" = "success" ]; then - echo "✅ **All platforms passed example testing!**" >> $GITHUB_STEP_SUMMARY + echo "✅ **Every leg of this run passed example testing!**" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "All examples ran successfully across all enabled platforms, against one wheel built for each platform." >> $GITHUB_STEP_SUMMARY + echo "All examples ran successfully on every leg this run started, against one wheel built for each platform." >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "**Platforms tested**: linux/amd64, linux/arm64, darwin/arm64, windows/amd64" >> $GITHUB_STEP_SUMMARY + echo "**Legs**: a pull request runs linux/amd64 only (the fast tier). A push to main, the nightly run, a manual run and a pull request with the label ci:full run linux/amd64, linux/arm64, darwin/arm64 and windows/amd64. The jobs of this run list its legs." >> $GITHUB_STEP_SUMMARY else - echo "❌ **Some platforms failed example testing**" >> $GITHUB_STEP_SUMMARY + echo "❌ **Some legs failed example testing**" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "Please check the individual platform jobs for details." >> $GITHUB_STEP_SUMMARY exit 1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5806273e..ee4c2a84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -142,6 +142,16 @@ shellcheck and hadolint run as `docker_image` hooks (Docker pulls the images aut 3. Open a pull request that says `Closes #N`. Fill in the pull request template (`.github/pull_request_template.md`): what changed, the issue, the timed result for a performance change, the docs you updated, and the checklist. 4. The checks must pass before a pull request is merged. A draft pull request skips the platform jobs; mark it ready for review to start them. +### What CI runs + +CI has two tiers, so that a pull request does not wait for the macOS and Windows runners that the organisation shares with ArcadeData/arcadedb. + +- **A pull request runs the fast tier.** The static checks (pre-commit, Bandit, the dependency audits) run as before. The builds and tests run on Linux x86-64 only: the `arcadedb-jvm` wheel with the tests on Python 3.11 and 3.14 and the examples on Python 3.14 and, when a native path changed, the native image and wheel with the tests and the examples on Python 3.12. A pull request that changes only documentation runs no platform job. +- **`main` runs the full tier.** A push to `main` and the nightly run (03:00 to 04:00 UTC) test all four platforms: Linux x86-64, Linux arm64, macOS arm64 and Windows x86-64. A release tests every platform on every Python version. +- **To run the full tier on a pull request**, add the label `ci:full`, then push a commit or choose "Re-run all jobs" on its test workflows. The pull request then runs what a push to `main` runs. Use it for a change that can behave differently on another platform: file paths, processes and signals, the wheel build, the native library, a workflow file. If you cannot add labels, ask for it in the pull request. Dependabot pull requests always run the full tier. + +A problem that only another platform shows is found on `main` after the merge: the badges at the top of the README turn red, and the fix or the revert comes before the next release. [Continuous integration](docs/modules/ROOT/pages/development/ci.adoc) lists the legs of each event. + A commit message starts with a short subject that says what changes and where, for example `Native find_nearest: send the query vector as one float32 array, not a Python list`. The body says why. Link the issue with `Closes #N` in the pull request. ### Performance changes diff --git a/README.md b/README.md index e479dbc3..09bc6bee 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![Python versions](https://img.shields.io/pypi/pyversions/arcadedb-jvm)](https://pypi.org/project/arcadedb-jvm/) [![Tests JVM](https://github.com/ArcadeData/arcadedb-python/actions/workflows/test-jvm.yml/badge.svg)](https://github.com/ArcadeData/arcadedb-python/actions/workflows/test-jvm.yml) [![Tests native](https://github.com/ArcadeData/arcadedb-python/actions/workflows/test-native.yml/badge.svg)](https://github.com/ArcadeData/arcadedb-python/actions/workflows/test-native.yml) +[![Examples](https://github.com/ArcadeData/arcadedb-python/actions/workflows/test-python-examples.yml/badge.svg)](https://github.com/ArcadeData/arcadedb-python/actions/workflows/test-python-examples.yml) [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/ArcadeData/arcadedb-python/blob/main/LICENSE) Python bindings for [ArcadeDB](https://arcadedb.com), the multi-model database (graph, document, key/value, vector and time series, queried with SQL or openCypher). The engine runs inside your Python process, with no server and no network hop. This repository builds two packages, and both import as `arcadedb`: `arcadedb` (the native build, the default) for scripts, notebooks, tests, CLIs, serverless functions and agents, and `arcadedb-jvm` (the JVM build) for heavy, long-running loads. Status: beta. @@ -46,7 +47,7 @@ uv add arcadedb-jvm # JVM, for heavy long-running loads > Old names: `arcadedb-jvm` was formerly `arcadedb-embedded`, and `arcadedb` was formerly `arcadedb-embedded-native` (archived on PyPI). The last `arcadedb-embedded` release, 26.11.1, is a deprecation shim: it installs `arcadedb`, the native build, and warns once at import. It does not install `arcadedb-jvm`. -- Python: `arcadedb` (native) is tested on 3.11 to 3.14 and also installs on 3.15 (`requires-python` is `>=3.11` with no upper bound; the CI runs a subset of the tests on 3.15). `arcadedb-jvm` needs 3.11 to 3.14 (`requires-python` is `>=3.11,<3.15`; its dependency JPype has no 3.15 wheel yet). Each release builds and tests both packages on Python 3.11 to 3.14 on all four platforms below. Between releases, `main` and the nightly run test `arcadedb` on 3.12 and 3.14 on every platform (with a short subset on 3.11, 3.13 and 3.15), and `arcadedb-jvm` on 3.11 to 3.14 on Linux x86-64 and on 3.11 and 3.14 on the other three. A pull request runs a smaller selection. +- Python: `arcadedb` (native) is tested on 3.11 to 3.14 and also installs on 3.15 (`requires-python` is `>=3.11` with no upper bound; the CI runs a subset of the tests on 3.15). `arcadedb-jvm` needs 3.11 to 3.14 (`requires-python` is `>=3.11,<3.15`; its dependency JPype has no 3.15 wheel yet). Each release builds and tests both packages on Python 3.11 to 3.14 on all four platforms below. Between releases, `main` and the nightly run test `arcadedb` on 3.12 and 3.14 on every platform (with a short subset on 3.11, 3.13 and 3.15), and `arcadedb-jvm` on 3.11 to 3.14 on Linux x86-64 and on 3.11 and 3.14 on the other three. A pull request runs Linux x86-64 only, and the other platforms when it carries the label `ci:full` ([CONTRIBUTING](https://github.com/ArcadeData/arcadedb-python/blob/main/CONTRIBUTING.md#what-ci-runs)). - Linux x86_64 and ARM64, macOS on Apple Silicon, Windows x86_64, for both packages. The Windows wheel of `arcadedb` is the newest. - Import name: `arcadedb`. Check which package you have with `python -c "import arcadedb; print(arcadedb.__backend__)"`. It prints `native` or `jvm`. - Optional extras: `arrow`, `pandas`, `polars`, `vector` for `arcadedb-jvm`; `numpy`, `arrow`, `pandas`, `polars` for `arcadedb`. diff --git a/docs/modules/ROOT/pages/development/ci.adoc b/docs/modules/ROOT/pages/development/ci.adoc index a1289174..3eea431e 100644 --- a/docs/modules/ROOT/pages/development/ci.adoc +++ b/docs/modules/ROOT/pages/development/ci.adoc @@ -1,5 +1,5 @@ = Continuous integration -:description: Which platforms and Python versions the CI runs for a pull request, and which for main, the nightly run and a release. +:description: Which platforms and Python versions the CI runs for a pull request (the fast tier), and which for main, the nightly run and a release (the full tier). Each package has one test workflow and one release workflow: @@ -22,6 +22,21 @@ The workflow `docs.yml` builds these docs (the Antora component in `docs/`) as a The package supports four platforms and four Python versions (3.11 to 3.14). That is 16 combinations. The organisation shares one runner limit with ArcadeData/arcadedb, so each macOS or Windows job delays the upstream jobs too, and not every combination runs. +== Fast tier and full tier + +The CI has two tiers. + +* The fast tier runs on every pull request: the static checks, and the builds and tests on Linux x86-64 only. It waits for no macOS, Windows or arm64 runner. +* The full tier runs on a push to `main`, on the nightly run, on a manual run and on a release. It tests all four platforms. A release tests every platform on every Python version. + +A pull request runs the legs of a push to `main` when it carries the label `ci:full`. Add the label, then push a commit or choose "Re-run all jobs" on the test workflows of the pull request: `scripts/ci_tier.py` reads the labels again at the start of each run, so no new commit is needed. Use the label for a change that can behave differently on another platform: file paths, processes and signals, the wheel build, the native library, a workflow file. To go back to the fast tier, remove the label and push a commit. A pull request that Dependabot opened always runs the full tier, because the hourly job merges it without a reader. When the labels cannot be read, the pull request runs the full tier. + +The nightly runs start between 03:00 and 04:00 UTC, when the shared runners are least busy (issue 442 has the measurement of the queue for each hour). + +A problem that only another platform shows is found on `main`, after the merge, or in the nightly run. The badges of `test-jvm.yml`, `test-native.yml` and `test-python-examples.yml` at the top of the README show the last run of each workflow on `main`, and GitHub sends a mail to the person who merged. Fix or revert before the next release. The release workflows run the full matrix again and publish nothing when a leg is red. + +The summary jobs (`Test Summary`, `Examples Test Summary`, `Examples summary`) check the legs that the run started. A leg that failed or was cancelled makes them red in both tiers. A leg that the tier does not start is not in the run, so nothing waits for it. + == One wheel for each platform The wheel of `arcadedb-jvm` is tagged `py3-none-` (`setup.py`), like the native wheel: it carries a JRE for its platform, but nothing in it is compiled against CPython. So a Python version is a test, not a build. `test-jvm.yml` has two jobs: @@ -39,12 +54,12 @@ The script `scripts/select_matrix.py` chooses the combinations. The first job of |=== | Event | Unit tests (`Test arcadedb`) | Examples (`Test Python Examples`) -| Pull request -| 10 legs: `linux/amd64` on all four Python versions. `linux/arm64`, `darwin/arm64` and `windows/amd64` on Python 3.11 and 3.14. -| All four platforms on Python 3.14. +| Pull request (the fast tier) +| 2 legs: `linux/amd64` on Python 3.11 and 3.14. +| `linux/amd64` on Python 3.14. -| Push to `main`, the nightly run -| The same 10 legs. +| Push to `main`, the nightly run, a pull request with the label `ci:full`, a Dependabot pull request +| 10 legs: `linux/amd64` on all four Python versions. `linux/arm64`, `darwin/arm64` and `windows/amd64` on Python 3.11 and 3.14. | All 16 combinations. | A manual run (dispatch), a release @@ -52,9 +67,9 @@ The script `scripts/select_matrix.py` chooses the combinations. The first job of | All 16 combinations. |=== -The unit tests run 10 legs on a pull request, a push to `main` and the nightly run (all Python versions on one Linux platform, the oldest and the newest elsewhere), and all 16 combinations on a release and a manual run, like the native package: what is published is tested on every platform and Python it claims. `release-jvm.yml` calls the workflow with `release: true`, which the matrix step turns into the event `release`, because in a called workflow `github.event_name` is the caller's tag push. A pull request runs 28 checks: 14 test jobs (10 and 4), 8 wheel builds (4 for each workflow), the two `Download ArcadeDB JARs` jobs, the two summary jobs, `Bandit security scan` and `Dependency floor audit`. A push and the nightly run run 40: the examples run all 16 combinations there, from 4 wheel builds. A manual run and a release run 46, with the 6 extra unit-test legs. +The unit tests run 2 legs on a pull request (the oldest and the newest Python on `linux/amd64`), 10 legs on a push to `main` and the nightly run (all Python versions on one Linux platform, the oldest and the newest elsewhere), and all 16 combinations on a release and a manual run, like the native package: what is published is tested on every platform and Python it claims. `release-jvm.yml` calls the workflow with `release: true`, which the matrix step turns into the event `release`, because in a called workflow `github.event_name` is the caller's tag push. A pull request runs 11 checks in these two workflows: 3 test jobs (2 and 1), 2 wheel builds (one for each workflow), the two `Download ArcadeDB JARs` jobs, the two summary jobs, `Bandit security scan` and `Dependency floor audit`. A push, the nightly run and a pull request that asks for the full tier run 40: 26 test jobs (10 and 16), 8 wheel builds (4 for each workflow) and the same six other jobs. A manual run and a release run 46, with the 6 extra unit-test legs. -The names of the test jobs do not change: `Test arcadedb (, Python )`. A check keeps its history when a pull request runs fewer of them. +The names of the test jobs do not change: `Test arcadedb (, Python )`. A check keeps its history when a pull request runs fewer of them. No check is required by a branch rule today. If one becomes required, choose a job of the fast tier or a summary job: a required check that only the full tier starts would never report on a pull request. `release-jvm.yml` expects exactly four wheels, one for each platform, all `py3-none`. It checks the count, the tags, the sizes and the names before it publishes. The nightly run also tests against the newest `arcadedata/arcadedb:latest` image. @@ -75,6 +90,7 @@ The dev-engine bump after each release, described in xref:development/release.ad * A pull request that changes only documentation (`+docs/**+`, `+*.adoc+`, `CLAUDE.md`, `examples/README.md`, `+LICENSE*+`) runs nothing. * A draft pull request skips the platform jobs. Marking it ready for review starts them. +* The label `ci:full` changes the legs of the workflows that the paths of the pull request start. It does not start a workflow that the paths leave out. * A new push to a pull request cancels the run it replaces. A run on `main` is never cancelled. * A JVM crash in an example leaves a HotSpot `hs_err_pid.log`. `test-python-examples.yml` uploads these files as the artifacts `jvm-crash-logdir--py` and `jvm-crash-cwd--py` (issue 352); read them before you re-run a red example leg. @@ -101,13 +117,13 @@ To close a release, close its milestone and open the next one with its due date: The workflow `test-native.yml` builds the native image of the `arcadedb` package and runs the test suite against the installed wheel. It does not follow the table above. It never publishes; `release-native.yml` calls it on a version tag. -* A pull request runs it only when native paths change: `+native/**+`, `+src/arcadedb/**+`, `+tests/**+`, `+examples/**+` (not `examples/README.md`), `pyproject.toml`, `setup.py`, `scripts/select_native_matrix.py`, `scripts/smoke_wheel.py`, `scripts/run_examples.sh`, `scripts/native_examples_skip.txt` or `test-native.yml` itself. Changes under `tests/` and `src/arcadedb/` are included because both backends share those files, so a shared test or source can break native parity without touching a native file; docs outside those paths do not run it. It then runs on `linux-x86_64` with Python 3.12 only. +* A pull request runs it only when native paths change: `+native/**+`, `+src/arcadedb/**+`, `+tests/**+`, `+examples/**+` (not `examples/README.md`), `pyproject.toml`, `setup.py`, `scripts/select_native_matrix.py`, `scripts/smoke_wheel.py`, `scripts/run_examples.sh`, `scripts/native_examples_skip.txt` or `test-native.yml` itself. Changes under `tests/` and `src/arcadedb/` are included because both backends share those files, so a shared test or source can break native parity without touching a native file; docs outside those paths do not run it. It then runs on `linux-x86_64` with Python 3.12 only (the fast tier): the image and the wheel, the parity suite and the examples. With the label `ci:full`, and for a Dependabot pull request, it runs the legs of a push to `main`. * A push to `main` (only when a native path changed, same filter as a pull request), the nightly run (skipped when nothing changed in the last 25 hours, except on Mondays) and a manual run (dispatch) run all four platforms: `linux-x86_64`, `linux-aarch64`, `macos-arm64` and `windows-x64` (Python 3.12 and 3.14). A release (`release-native.yml` calls the workflow with `release: true`) runs the same four platforms on all four Python versions, 16 legs. -* The `pyver` job installs the already built `linux-x86_64` wheel (no rebuild) into the Pythons that the full parity runs of the event leave out (3.11, 3.13 and 3.14 on a pull request; 3.11 and 3.13 on a push to `main`, the nightly run and a dispatch; none on a release) into 3.15 and into the free-threaded 3.14t, and runs 13 test files there (14 where polars installs; 3.15 has no jpype1 wheel, so it leaves out the two files that need jpype1), about 20 seconds of tests per Python. A release needs it: a `pyver` leg that passes uploads the marker `native-passed-pyver-py` (it holds the file name of the wheel the leg installed), and `Verify what may be published` in `release-native.yml` requires the markers of 3.15 and 3.14t, the two legs of a release, and that both tested the `linux-x86_64` wheel that is published. A red leg stops a release before anything reaches PyPI. Only `linux-x86_64` is checked on these two Pythons: the other platforms are not tested on 3.15 and 3.14t, and the JVM package has no such job. The 3.14t leg has no polars (no free-threaded wheel exists), so it skips `test_dataframe_ingest.py`. `scripts/select_native_matrix.py` decides its legs, and `tests/test_select_native_matrix.py` and `tests/test_release_native_verify.py` pin the gate. +* The `pyver` job installs the already built `linux-x86_64` wheel (no rebuild) into the Pythons that the full parity runs of the event leave out (3.11 and 3.13 on a push to `main`, the nightly run and a dispatch; none on a release) into 3.15 and into the free-threaded 3.14t, and runs 13 test files there (14 where polars installs; 3.15 has no jpype1 wheel, so it leaves out the two files that need jpype1), about 20 seconds of tests per Python. A release needs it: a `pyver` leg that passes uploads the marker `native-passed-pyver-py` (it holds the file name of the wheel the leg installed), and `Verify what may be published` in `release-native.yml` requires the markers of 3.15 and 3.14t, the two legs of a release, and that both tested the `linux-x86_64` wheel that is published. A red leg stops a release before anything reaches PyPI. A pull request has no `pyver` legs (the fast tier is one Python): the job shows as skipped there. Only `linux-x86_64` is checked on these two Pythons: the other platforms are not tested on 3.15 and 3.14t, and the JVM package has no such job. The 3.14t leg has no polars (no free-threaded wheel exists), so it skips `test_dataframe_ingest.py`. `scripts/select_native_matrix.py` decides its legs, and `tests/test_select_native_matrix.py` and `tests/test_release_native_verify.py` pin the gate. * Every test file runs in its own process (`native/wheel/parity_wheel.py`). A process that dies without writing its result is a `CRASH` row in `parity-wheel.tsv` with its exit code, for example `CRASH(rc=0xC0000005,3221225477)`, and it fails the leg. On the Windows legs only (the crashes of issue 295 happen there), the harness runs such a file once more in a fresh process (`--retry-crash`). A retry that produces a result is a `FLAKY-CRASH` row: the gate lets the leg pass, the job summary lists the file with the first exit code, and on a release or a dispatch the `crash-report` job adds one comment to issue 295 (run URL, Python, wheel version, exit codes). A second crash, a failing test, a timeout and every crash on Linux or macOS stay failures. A process that wrote its result and then died in shutdown is a `DIRTY-EXIT` record (exit code, file, attempt) in the metadata, the job summary and the issue comment: it is not retried and does not fail the leg. Each Windows test process also writes a faulthandler trace, `parity-wheel-xml/.attemptN.fault.txt`, into the parity artifact of the leg. Only a retry hides a crash, so treat a `FLAKY-CRASH` as an open bug: read the trace in the artifact before a release is announced. * The `examples` job runs every script of `examples/` against the installed wheel of each platform (Python 3.12 and 3.14; a pull request: `linux-x86_64`, Python 3.12) through `scripts/run_examples.sh`, the runner that `test-python-examples.yml` uses too. `scripts/native_examples_skip.txt` lists, with a reason, the examples that need the JVM package. `Examples summary` is the one check for all its legs. These legs do not decide what a release publishes. * A native image build takes about 5 to 30 minutes for each platform (macOS is the slowest). The organisation shares one runner limit with upstream ArcadeDB, so do not add runs lightly. Change the paths or the matrix of `test-native.yml` only for a reason that you can write down. == Change the selection -Edit `JVM_LEGS` (unit tests on the events in `JVM_REDUCED_EVENTS`: a pull request, a push and the nightly run; every other event runs the full matrix) or `PULL_REQUEST_LEGS` (examples on a pull request) in `scripts/select_matrix.py`. The test `tests/test_select_matrix.py` fixes the legs, so a change that shrinks them fails. When you add a Python version, add it to `PYTHONS` in the script and to the classifiers in `pyproject.toml`. A test checks that both lists are the same, that `requires-python` starts at the oldest of them and stops before the minor after the newest. When you drop one, remove it from the same places and update the counts in the test. +Edit `JVM_LEGS` (unit tests on the events in `JVM_REDUCED_EVENTS`: a push and the nightly run; every other event but a pull request runs the full matrix) or `PULL_REQUEST_LEGS` (the fast tier: unit tests and examples on a pull request) in `scripts/select_matrix.py`. The legs of the native workflow are in `scripts/select_native_matrix.py`. `scripts/ci_tier.py` holds the name of the label and decides whether a pull request runs the fast tier or the legs of a push. The tests `tests/test_select_matrix.py`, `tests/test_select_native_matrix.py` and `tests/test_ci_tier.py` fix the legs, so a change that shrinks them fails. When you add a Python version, add it to `PYTHONS` in the script and to the classifiers in `pyproject.toml`. A test checks that both lists are the same, that `requires-python` starts at the oldest of them and stops before the minor after the newest. When you drop one, remove it from the same places and update the counts in the test. diff --git a/scripts/ci_tier.py b/scripts/ci_tier.py new file mode 100644 index 00000000..03f1bb01 --- /dev/null +++ b/scripts/ci_tier.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python3 +"""Name the event the leg planners get, so a pull request runs the fast tier unless it asks for the full one. + +CI has two tiers (docs page development/ci.adoc): + +- fast: a pull request. Linux x86-64 only, the legs of the event `pull_request` in scripts/select_matrix.py and + scripts/select_native_matrix.py. +- full: a push to main, the nightly run, a manual run and a release, each with the legs of its own event. A pull request gets the + legs of a push to main when it carries the label `ci:full` or when Dependabot opened it (nobody reads a Dependabot pull request + before the hourly job merges it, so the full matrix is its only review). + +usage: ci_tier.py EVENT EVENT: the event that started the workflow + +Prints EVENT unchanged unless it is `pull_request`. For a pull request it prints `pull_request` (fast) or `pull_request_full` +(the legs of a push to main), and says why on stderr. It reads: + + PR_AUTHOR the login of the author (github.event.pull_request.user.login) + PR_LABELS the label names in the event, a JSON list (toJSON(github.event.pull_request.labels.*.name)) + PR_NUMBER, GITHUB_REPOSITORY, GH_TOKEN + to read the labels the pull request has now, through `gh api` + +The labels are read again from the API because a re-run keeps the event of the first attempt: with the label added afterwards, +"Re-run all jobs" is enough to get the full matrix, no new commit is needed. The choice fails open: when the labels cannot be read, +the pull request runs the full tier, never less. +""" + +from __future__ import annotations + +import json +import os +import subprocess +import sys +from collections.abc import Callable + +FULL_LABEL = "ci:full" +# Authors whose pull requests always run the full tier. +FULL_AUTHORS = ("dependabot[bot]",) + +FAST_EVENT = "pull_request" +FULL_EVENT = "pull_request_full" + + +def live_labels(repo: str, number: str) -> list[str] | None: + """The label names the pull request has now, or None when they cannot be read.""" + if not repo or not number: + return None + try: + proc = subprocess.run( + [ + "gh", + "api", + f"repos/{repo}/issues/{number}/labels?per_page=100", + "--jq", + ".[].name", + ], + capture_output=True, + text=True, + timeout=60, + ) + except (OSError, subprocess.SubprocessError): + return None + if proc.returncode != 0: + return None + return proc.stdout.splitlines() + + +def payload_labels(text: str) -> list[str]: + """The label names of the event from PR_LABELS; anything that is not a JSON list of strings counts as no label.""" + try: + value = json.loads(text or "[]") + except ValueError: + return [] + if not isinstance(value, list): + return [] + return [name for name in value if isinstance(name, str)] + + +def planner_event( + event: str, + author: str, + labels: list[str], + read_live: Callable[[], list[str] | None], +) -> tuple[str, str]: + """(the event for the planners, why). `read_live` is called only when nothing else has already decided.""" + if event != FAST_EVENT: + return ( + event, + f"{event or 'no event'}: not a pull request, the legs of the event", + ) + if author in FULL_AUTHORS: + return FULL_EVENT, f"full tier: opened by {author}" + if FULL_LABEL in labels: + return FULL_EVENT, f"full tier: the label {FULL_LABEL} is in the event" + live = read_live() + if live is None: + return ( + FULL_EVENT, + "full tier: the labels of the pull request could not be read (fails open)", + ) + if FULL_LABEL in live: + return ( + FULL_EVENT, + f"full tier: the label {FULL_LABEL} was added after the event", + ) + return FAST_EVENT, f"fast tier: no label {FULL_LABEL}" + + +def main(argv: list[str] | None = None) -> int: + args = sys.argv[1:] if argv is None else argv + if len(args) != 1: + print("usage: ci_tier.py EVENT", file=sys.stderr) + return 2 + env = os.environ + event, why = planner_event( + args[0], + env.get("PR_AUTHOR", ""), + payload_labels(env.get("PR_LABELS", "")), + lambda: live_labels(env.get("GITHUB_REPOSITORY", ""), env.get("PR_NUMBER", "")), + ) + print(why, file=sys.stderr) + print(event) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/select_matrix.py b/scripts/select_matrix.py index 60808a8f..1fe3de11 100644 --- a/scripts/select_matrix.py +++ b/scripts/select_matrix.py @@ -3,19 +3,24 @@ The wheels support four platforms and four Python versions. -- `jvm` (test-jvm.yml) runs 10 legs on a pull request, a push to main and the nightly schedule, and all 16 for - a release (release-jvm.yml calls the workflow with `release: true`, which test-jvm.yml passes as the event - `release`) and a manual dispatch. The JVM wheel is one file for each platform (py3-none-, built once - by the `build` job), so a Python version is a test leg, not a build. The 10 legs are all four Pythons on - linux/amd64 and the oldest and the newest on the other platforms: a bug that depends on the interpreter shows - on the ends of the range, and one that depends on the platform shows on any version of it. The organisation - shares one runner cap with ArcadeData/arcadedb, so every extra macOS or Windows leg delays upstream too; what - is published, and a run started by hand before a release, gets every combination, like test-native.yml. -- `examples` (test-python-examples.yml) runs the newest Python on every platform on a pull request, and every +CI has two tiers. A pull request runs the fast tier: linux/amd64 only, so it does not wait for the macOS and Windows +runners the organisation shares with ArcadeData/arcadedb. Every other event runs the full tier, and a pull request +that asks for it (the label `ci:full`, or a Dependabot author; scripts/ci_tier.py decides and passes the event +`pull_request_full`) runs the legs of a push to main. + +- `jvm` (test-jvm.yml) runs 2 legs on a pull request (linux/amd64, the oldest and the newest Python), 10 legs on + a push to main and the nightly schedule, and all 16 for a release (release-jvm.yml calls the workflow with + `release: true`, which test-jvm.yml passes as the event `release`) and a manual dispatch. The JVM wheel is one + file for each platform (py3-none-, built once by the `build` job), so a Python version is a test leg, + not a build. The 10 legs are all four Pythons on linux/amd64 and the oldest and the newest on the other + platforms: a bug that depends on the interpreter shows on the ends of the range, and one that depends on the + platform shows on any version of it. What is published, and a run started by hand before a release, gets every + combination, like test-native.yml. +- `examples` (test-python-examples.yml) runs the newest Python on linux/amd64 on a pull request, and every combination (16 legs) on every other event. The selection fails open to the full matrix: an event name this script does not know runs everything, never less -(for `jvm` too: only a pull request, a push and the nightly schedule get its 10 legs). +(for `jvm` too: only a pull request, a push and the nightly schedule get fewer than 16 legs). usage: select_matrix.py jvm [--event NAME] # test-jvm.yml: the test legs @@ -54,9 +59,9 @@ OLDEST = PYTHONS[0] NEWEST = PYTHONS[-1] -# The legs of `jvm` on a pull request, a push and the nightly run: all Pythons on linux/amd64 (the cheap, fast runner and the one most -# contributors use), the oldest and the newest on the three other platforms (the shape of test-native.yml). The wheel -# is py3-none-, one file for each platform, so these are test legs against that file, not builds. +# The legs of `jvm` on a push and the nightly run (and on a pull request that asks for the full tier): all Pythons on linux/amd64 +# (the cheap, fast runner and the one most contributors use), the oldest and the newest on the three other platforms (the shape of +# test-native.yml). The wheel is py3-none-, one file for each platform, so these are test legs against that file, not builds. JVM_LEGS = { "linux/amd64": PYTHONS, "linux/arm64": (OLDEST, NEWEST), @@ -66,17 +71,23 @@ # The events on which `jvm` runs only JVM_LEGS. Every other event (a release, a manual dispatch, an event this # script does not know) runs every platform x Python combination, so the selection fails open. -JVM_REDUCED_EVENTS = ("pull_request", "push", "schedule") +JVM_REDUCED_EVENTS = ("push", "schedule") -# The legs of a pull request, for the workflows whose legs depend on the event. +# The fast tier: the legs of a pull request, linux/amd64 only (ArcadeData/arcadedb-python#442). The other +# platforms run after the merge (the push to main) and every night, and before the merge when the pull request +# carries the label `ci:full`. # -# examples: the newest Python only, on every platform. The examples are slow (torch, -# sentence-transformers), and they carry platform-specific code (`os.name == "nt"` branches in -# examples 07 to 12) and per-platform steps in the workflow (a CPU torch index on macOS, UTF-8 -# on Windows), so all four platforms stay. +# jvm: the oldest and the newest Python, the ends of the range. +# examples: the newest Python. The examples are slow (torch, sentence-transformers); their platform-specific +# code (`os.name == "nt"` branches in examples 07 to 12) and the per-platform steps of the workflow (a CPU torch +# index on macOS, UTF-8 on Windows) are covered by the full tier. +FAST_PLATFORM = "linux/amd64" PULL_REQUEST_LEGS = { - "examples": {platform: (NEWEST,) for platform in RUNNERS}, + "jvm": {FAST_PLATFORM: (OLDEST, NEWEST)}, + "examples": {FAST_PLATFORM: (NEWEST,)}, } +# The event scripts/ci_tier.py passes for a pull request that asks for the full tier: the legs of a push to main. +PULL_REQUEST_FULL = "pull_request_full" WORKFLOWS = ("jvm", "examples") @@ -95,12 +106,12 @@ def select(workflow: str, event: str) -> dict[str, list[dict[str, str]]]: raise ValueError( f"unknown workflow {workflow!r}; use one of {sorted(WORKFLOWS)}" ) - if workflow == "jvm": - if event in JVM_REDUCED_EVENTS: - return {"include": _legs(JVM_LEGS)} - return {"include": _legs({platform: PYTHONS for platform in RUNNERS})} + if event == PULL_REQUEST_FULL: + event = "push" if event == "pull_request": return {"include": _legs(PULL_REQUEST_LEGS[workflow])} + if workflow == "jvm" and event in JVM_REDUCED_EVENTS: + return {"include": _legs(JVM_LEGS)} return {"include": _legs({platform: PYTHONS for platform in RUNNERS})} diff --git a/scripts/select_native_matrix.py b/scripts/select_native_matrix.py index a106de96..4f924688 100644 --- a/scripts/select_native_matrix.py +++ b/scripts/select_native_matrix.py @@ -2,12 +2,13 @@ """Choose the legs of the native test workflow (.github/workflows/test-native.yml) for one event. A native image build takes about 5 to 30 minutes per platform and the ArcadeData organisation shares a runner cap with -upstream ArcadeDB, so a pull request builds one platform (linux-x86_64) and tests one Python (3.12), and only when -native paths changed (the workflow's `paths` filter). Push to main, the nightly run and a dispatch build all four +upstream ArcadeDB, so a pull request (the fast tier) builds one platform (linux-x86_64) and tests one Python (3.12, no `pyver` legs), +and only when native paths changed (the workflow's `paths` filter). Push to main, the nightly run and a dispatch build all four platforms and test Python 3.12 and 3.14 on each. A release (release-native.yml calls the workflow with `release: true`) tests every -supported Python (3.11 to 3.14) on all four. +supported Python (3.11 to 3.14) on all four. A pull request that asks for the full tier (the label `ci:full`, or a Dependabot author; +scripts/ci_tier.py decides and passes the event `pull_request_full`) runs the legs of a push to main. -usage: select_native_matrix.py EVENT EVENT: pull_request | push | schedule | workflow_dispatch | release +usage: select_native_matrix.py EVENT EVENT: pull_request | pull_request_full | push | schedule | workflow_dispatch | release Prints `build=`, `test=`, `pyver=` and `examples=` lines (GITHUB_OUTPUT format). Publishing is not decided here: release-native.yml does it. `pyver` is the cheap Python-version job (see PYVER_NOTE): a subset of the tests against the built @@ -125,6 +126,8 @@ def pyver_legs(covered: list[str]) -> list[dict]: def select(event: str) -> dict: + if event == "pull_request_full": + event = "push" if event == "pull_request": platforms, pythons = PULL_REQUEST_PLATFORMS, PULL_REQUEST_PYTHONS elif event in ("push", "schedule", "workflow_dispatch"): @@ -148,7 +151,9 @@ def select(event: str) -> dict: return { "build": build, "test": test, - "pyver": pyver_legs(pythons), + # The fast tier is one Python: the Python-version legs run on main, every night and for a release (where they are a gate), + # and on a pull request that asks for the full tier. test-native.yml skips the job when this list is empty. + "pyver": [] if event == "pull_request" else pyver_legs(pythons), "examples": examples, } @@ -157,7 +162,14 @@ def main(argv: list[str] | None = None) -> int: ap = argparse.ArgumentParser() ap.add_argument( "event", - choices=["pull_request", "push", "schedule", "workflow_dispatch", "release"], + choices=[ + "pull_request", + "pull_request_full", + "push", + "schedule", + "workflow_dispatch", + "release", + ], ) a = ap.parse_args(argv) chosen = select(a.event) diff --git a/tests/test_ci_tier.py b/tests/test_ci_tier.py new file mode 100644 index 00000000..8a43d629 --- /dev/null +++ b/tests/test_ci_tier.py @@ -0,0 +1,171 @@ +"""The tier of a CI run (scripts/ci_tier.py): a pull request runs the fast tier unless it asks for the full one.""" + +from __future__ import annotations + +import importlib.util +import os +import subprocess # nosec B404 - runs this repository's script with sys.executable +import sys +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parents[1] +SCRIPT = ROOT / "scripts" / "ci_tier.py" +spec = importlib.util.spec_from_file_location("ci_tier", SCRIPT) +ct = importlib.util.module_from_spec(spec) +spec.loader.exec_module(ct) + + +def _never(): + raise AssertionError("the labels were read from the API") + + +@pytest.mark.parametrize( + "event", + ["push", "schedule", "workflow_dispatch", "release", "", "some_new_event"], +) +def test_every_event_but_a_pull_request_passes_through_unchanged(event): + # the label and the author matter for a pull request only, and no other event costs an API call + chosen, _why = ct.planner_event(event, "dependabot[bot]", ["ci:full"], _never) + assert chosen == event + + +def test_a_pull_request_without_the_label_runs_the_fast_tier(): + chosen, why = ct.planner_event( + "pull_request", "someone", ["bug"], lambda: ["bug", "native"] + ) + assert chosen == "pull_request" + assert "fast tier" in why + + +def test_the_label_in_the_event_asks_for_the_full_tier_without_an_api_call(): + chosen, _why = ct.planner_event( + "pull_request", "someone", ["bug", "ci:full"], _never + ) + assert chosen == "pull_request_full" + + +def test_the_label_added_after_the_event_asks_for_the_full_tier_on_a_rerun(): + # a re-run keeps the event of the first attempt, so the labels are read again from the API + chosen, why = ct.planner_event( + "pull_request", "someone", ["bug"], lambda: ["bug", "ci:full"] + ) + assert chosen == "pull_request_full" + assert "after the event" in why + + +def test_labels_that_cannot_be_read_fail_open_to_the_full_tier(): + chosen, why = ct.planner_event("pull_request", "someone", [], lambda: None) + assert chosen == "pull_request_full" + assert "fails open" in why + + +def test_a_dependabot_pull_request_runs_the_full_tier(): + # the hourly job merges it without a reader, so the full matrix is its only review + chosen, _why = ct.planner_event("pull_request", "dependabot[bot]", [], _never) + assert chosen == "pull_request_full" + + +def test_only_the_exact_label_counts(): + near = ["ci:fullish", "not ci:full", "CI:FULL", "ci"] + chosen, _why = ct.planner_event("pull_request", "someone", near, lambda: near) + assert chosen == "pull_request" + + +@pytest.mark.parametrize( + ("text", "labels"), + [ + ('["bug","ci:full"]', ["bug", "ci:full"]), + ("[]", []), + ("", []), + ("null", []), + ("not json", []), + ('{"ci:full": 1}', []), + ('[1, "x", null]', ["x"]), + ], +) +def test_the_labels_of_the_event_are_a_json_list_and_anything_else_is_no_label( + text, labels +): + assert ct.payload_labels(text) == labels + + +class _Proc: + def __init__(self, returncode, stdout): + self.returncode = returncode + self.stdout = stdout + + +def test_the_live_labels_come_from_gh_api_one_name_on_each_line(monkeypatch): + calls = [] + + def run(cmd, **kwargs): + calls.append(cmd) + return _Proc(0, "bug\nci:full\n") + + monkeypatch.setattr(ct.subprocess, "run", run) + assert ct.live_labels("ArcadeData/arcadedb-python", "7") == ["bug", "ci:full"] + assert calls[0][:2] == ["gh", "api"] + assert "repos/ArcadeData/arcadedb-python/issues/7/labels" in calls[0][2] + + +def test_the_live_labels_are_unknown_when_gh_fails_is_missing_or_has_nothing_to_ask( + monkeypatch, +): + monkeypatch.setattr(ct.subprocess, "run", lambda cmd, **kwargs: _Proc(1, "")) + assert ct.live_labels("ArcadeData/arcadedb-python", "7") is None + + def missing(cmd, **kwargs): + raise FileNotFoundError("gh") + + monkeypatch.setattr(ct.subprocess, "run", missing) + assert ct.live_labels("ArcadeData/arcadedb-python", "7") is None + + def never(cmd, **kwargs): + raise AssertionError("gh was called without a repository or a number") + + monkeypatch.setattr(ct.subprocess, "run", never) + assert ct.live_labels("", "7") is None + assert ct.live_labels("ArcadeData/arcadedb-python", "") is None + + +def _run(args, **env): + clean = { + k: v + for k, v in os.environ.items() + if k not in ("PR_AUTHOR", "PR_LABELS", "PR_NUMBER", "GITHUB_REPOSITORY") + } + return subprocess.run( # nosec B603 - fixed argv, no shell + [sys.executable, "-I", str(SCRIPT), *args], + capture_output=True, + text=True, + env={**clean, **env}, + ) + + +def test_the_command_line_prints_the_event_on_one_line_and_the_reason_on_stderr(): + # neither call reaches the API: the event is not a pull request, or the label is already in the event + proc = _run(["push"]) + assert (proc.returncode, proc.stdout) == (0, "push\n") + proc = _run(["pull_request"], PR_AUTHOR="someone", PR_LABELS='["ci:full"]') + assert (proc.returncode, proc.stdout) == (0, "pull_request_full\n") + assert "ci:full" in proc.stderr + # no number and no repository: the labels cannot be read, so the pull request runs the full tier + proc = _run(["pull_request"], PR_AUTHOR="someone", PR_LABELS="[]") + assert (proc.returncode, proc.stdout) == (0, "pull_request_full\n") + assert _run([]).returncode == 2 + + +def test_both_planners_know_the_event_of_a_full_tier_pull_request(): + # the name is written in three scripts; a rename in one of them would send a pull request to the wrong legs + for name in ("select_matrix.py", "select_native_matrix.py"): + text = (ROOT / "scripts" / name).read_text(encoding="utf-8") + assert f'"{ct.FULL_EVENT}"' in text, name + assert ct.FAST_EVENT == "pull_request" + + +def test_the_label_is_the_one_contributing_names(): + # CONTRIBUTING.md only: the test workflows ignore docs/**, so a test must not depend on a page there + text = (ROOT / "CONTRIBUTING.md").read_text(encoding="utf-8") + assert f"`{ct.FULL_LABEL}`" in text diff --git a/tests/test_select_matrix.py b/tests/test_select_matrix.py index 825da288..fb29bbd3 100644 --- a/tests/test_select_matrix.py +++ b/tests/test_select_matrix.py @@ -1,4 +1,4 @@ -"""Which platform x Python legs CI runs per event: a small matrix on pull requests, the full one everywhere else.""" +"""Which platform x Python legs CI runs per event: the fast tier (linux/amd64) on pull requests, the full tier everywhere else.""" from __future__ import annotations @@ -30,6 +30,7 @@ PYTHONS = ["3.11", "3.12", "3.13", "3.14"] FULL = {(p, v) for p, v in itertools.product(PLATFORMS, PYTHONS)} NON_PULL_REQUEST_EVENTS = [ + "pull_request_full", "push", "schedule", "workflow_dispatch", @@ -68,8 +69,8 @@ def test_every_event_but_pull_request_runs_the_full_examples_matrix(event): assert _pairs(matrix) == FULL -@pytest.mark.parametrize("event", ["pull_request", "push", "schedule"]) -def test_jvm_tests_the_one_wheel_of_a_platform_on_ten_legs_on_a_pull_request_a_push_and_the_nightly( +@pytest.mark.parametrize("event", ["pull_request_full", "push", "schedule"]) +def test_jvm_tests_the_one_wheel_of_a_platform_on_ten_legs_on_a_push_the_nightly_and_a_full_tier_pull_request( event, ): # The wheel is py3-none-: every Python of linux/amd64, the oldest and the newest elsewhere (as test-native.yml) @@ -93,7 +94,29 @@ def test_jvm_tests_every_platform_and_python_for_a_release_a_dispatch_and_any_ot assert _pairs(matrix) == FULL -@pytest.mark.parametrize("event", ["pull_request", *NON_PULL_REQUEST_EVENTS]) +def test_a_pull_request_runs_the_fast_tier_of_the_jvm_tests(): + # linux/amd64 only, the oldest and the newest Python: no macOS, Windows or arm64 runner is waited for + assert _pairs(sm.select("jvm", "pull_request")) == { + ("linux/amd64", "3.11"), + ("linux/amd64", "3.14"), + } + assert sm.select_wheels("jvm", "pull_request") == { + "include": [{"platform": "linux/amd64", "runs-on": "ubuntu-24.04"}] + } + + +@pytest.mark.parametrize("workflow", ["jvm", "examples"]) +def test_a_pull_request_that_asks_for_the_full_tier_runs_the_legs_of_a_push_to_main( + workflow, +): + # scripts/ci_tier.py passes pull_request_full for the label ci:full and for a Dependabot pull request + assert sm.select(workflow, "pull_request_full") == sm.select(workflow, "push") + assert sm.select_wheels(workflow, "pull_request_full") == sm.select_wheels( + workflow, "push" + ) + + +@pytest.mark.parametrize("event", NON_PULL_REQUEST_EVENTS) def test_jvm_builds_one_wheel_for_each_platform_whatever_the_python(event): # One build leg for each platform of the test legs, in the order of RUNNERS; no Python in it assert sm.select_wheels("jvm", event) == { @@ -102,8 +125,12 @@ def test_jvm_builds_one_wheel_for_each_platform_whatever_the_python(event): def test_pull_request_examples_matrix(): + # the fast tier: the newest Python on linux/amd64, one build pairs = _pairs(sm.select("examples", "pull_request")) - assert pairs == {(p, "3.14") for p in PLATFORMS} + assert pairs == {("linux/amd64", "3.14")} + assert sm.select_wheels("examples", "pull_request") == { + "include": [{"platform": "linux/amd64", "runs-on": "ubuntu-24.04"}] + } @pytest.mark.parametrize("workflow", ["jvm", "examples"]) @@ -114,6 +141,19 @@ def test_pull_request_matrix_is_part_of_the_full_matrix(workflow): ) +@pytest.mark.parametrize("workflow", sorted(WORKFLOWS)) +def test_workflow_asks_ci_tier_for_the_event_before_it_selects_the_legs(workflow): + # the tier of a pull request is decided in one place (scripts/ci_tier.py), and before the matrix is selected + text = WORKFLOWS[workflow].read_text(encoding="utf-8") + step = text.split(" - name: Select the test matrix\n", 1)[1].split( + "\n - name:", 1 + )[0] + tier = step.index('EVENT_NAME="$(python3 scripts/ci_tier.py "$EVENT_NAME")"') + assert tier < step.index(f"scripts/select_matrix.py {workflow}") + for name in ("GH_TOKEN", "PR_NUMBER", "PR_AUTHOR", "PR_LABELS"): + assert f" {name}: ${{{{ " in step, name + + def test_unknown_workflow_is_refused(): with pytest.raises(ValueError): sm.select("docs", "pull_request") @@ -141,7 +181,12 @@ def test_pythons_match_the_classifiers_of_pyproject(): def test_command_line_prints_one_line_of_matrix_json(): - for event, count in (("pull_request", 10), ("push", 10), ("release", 16)): + for event, count in ( + ("pull_request", 2), + ("pull_request_full", 10), + ("push", 10), + ("release", 16), + ): out = subprocess.run( # nosec B603 - fixed argument list, no untrusted input [sys.executable, "-I", str(SCRIPT_PATH), "jvm", "--event", event], capture_output=True, @@ -210,8 +255,8 @@ def test_the_examples_workflow_builds_each_platform_once_and_runs_the_examples_a assert "dist/" not in test # release-jvm.yml publishes every wheel-* artifact of the run, and the release runs this workflow beside test-jvm.yml assert "name: wheel-" not in text - # the legs of the pull request and of the other events are the same platforms, one build each - for event in ["pull_request", *NON_PULL_REQUEST_EVENTS]: + # every event but a pull request (the fast tier, one platform) builds the same four platforms, one build each + for event in NON_PULL_REQUEST_EVENTS: assert sm.select_wheels("examples", event) == { "include": [{"platform": p, "runs-on": r} for p, r in PLATFORMS.items()] } diff --git a/tests/test_select_native_matrix.py b/tests/test_select_native_matrix.py index 0a4ca316..fac3d57f 100644 --- a/tests/test_select_native_matrix.py +++ b/tests/test_select_native_matrix.py @@ -24,6 +24,28 @@ def test_pull_request_builds_one_platform_and_tests_one_python(): ] +def test_a_pull_request_that_asks_for_the_full_tier_runs_the_legs_of_a_push_to_main(): + # scripts/ci_tier.py passes pull_request_full for the label ci:full and for a Dependabot pull request + assert sel.select("pull_request_full") == sel.select("push") + + +def test_the_workflow_asks_ci_tier_for_the_event_and_skips_an_empty_python_version_job(): + workflow = (ROOT / ".github" / "workflows" / "test-native.yml").read_text() + plan = _job(workflow, "plan") + tier = plan.index('event="$(python3 -I scripts/ci_tier.py "$EVENT")"') + assert tier < plan.index('scripts/select_native_matrix.py "$event"') + # a change to the script that picks the tier starts this workflow + assert ' - "scripts/ci_tier.py"\n' in workflow.split("\njobs:\n", 1)[0] + # the fast tier has no pyver legs, and an empty matrix is an error: the job is skipped then, and no other job needs it + assert sel.select("pull_request")["pyver"] == [] + assert ( + "needs.plan.outputs.pyver != '[]'" + in _job(workflow, "pyver").split("steps:", 1)[0] + ) + for needs in re.findall(r"^ needs: (.*)$", workflow, re.M): + assert "pyver" not in needs, needs + + def test_main_nightly_and_dispatch_build_all_four_platforms(): for event in ("push", "schedule", "workflow_dispatch"): chosen = sel.select(event) @@ -75,10 +97,17 @@ def test_the_script_prints_github_output_lines(): "examples", ] assert json.loads(out[0].split("=", 1)[1])[0]["key"] == "linux-x86_64" - assert [leg["python"] for leg in json.loads(out[2].split("=", 1)[1])] == [ + # the fast tier is one Python: no pyver legs, and the list is the text the workflow compares with '[]' + assert out[2] == "pyver=[]" + full = subprocess.run( # nosec B603 - fixed argv, no shell + [sys.executable, str(SCRIPT), "pull_request_full"], + capture_output=True, + text=True, + check=True, + ).stdout.splitlines() + assert [leg["python"] for leg in json.loads(full[2].split("=", 1)[1])] == [ "3.11", "3.13", - "3.14", "3.15", "3.14t", ] @@ -92,16 +121,22 @@ def _pyver(event): def test_the_python_version_job_covers_what_the_full_parity_run_leaves_out(): - # a pull request tests 3.12 only: the other three Pythons, 3.15 (no jpype1 wheel yet) and the free-threaded one run the cheap subset - assert _pyver("pull_request") == [ + # a pull request (the fast tier) tests 3.12 only and has no Python-version legs + assert _pyver("pull_request") == [] + # the selection itself still knows what one full Python leaves out: the other three Pythons, 3.15 (no jpype1 wheel yet) and the + # free-threaded one + assert [ + (leg["python"], leg["freethreaded"], leg["polars"], leg["jpype"]) + for leg in sel.pyver_legs(sel.PULL_REQUEST_PYTHONS) + ] == [ ("3.11", False, True, True), ("3.13", False, True, True), ("3.14", False, True, True), ("3.15", False, True, False), ("3.14t", True, False, True), ] - # main, nightly and dispatch test 3.12 and 3.14 in full - for event in ("push", "schedule", "workflow_dispatch"): + # main, nightly, dispatch and a pull request that asks for the full tier test 3.12 and 3.14 in full + for event in ("pull_request_full", "push", "schedule", "workflow_dispatch"): assert _pyver(event) == [ ("3.11", False, True, True), ("3.13", False, True, True), @@ -116,7 +151,13 @@ def test_the_python_version_job_covers_what_the_full_parity_run_leaves_out(): def test_the_python_version_job_never_repeats_a_full_parity_leg_and_has_no_polars_on_a_free_threaded_python(): - for event in ("pull_request", "push", "schedule", "workflow_dispatch", "release"): + for event in ( + "pull_request_full", + "push", + "schedule", + "workflow_dispatch", + "release", + ): chosen = sel.select(event) full = {t["python"] for t in chosen["test"]} assert not full & {leg["python"] for leg in chosen["pyver"]}, event @@ -191,7 +232,13 @@ def test_the_linux_legs_build_in_the_manylinux_container_of_the_tag_and_the_work def test_the_examples_job_runs_on_the_parity_pythons_3_12_and_3_14_of_every_platform_it_builds(): pr = sel.select("pull_request")["examples"] assert [(leg["key"], leg["python"]) for leg in pr] == [("linux-x86_64", "3.12")] - for event in ("push", "schedule", "workflow_dispatch", "release"): + for event in ( + "pull_request_full", + "push", + "schedule", + "workflow_dispatch", + "release", + ): legs = sel.select(event)["examples"] assert {leg["key"] for leg in legs} == set(sel.ALL_PLATFORMS), event assert {leg["python"] for leg in legs} == {"3.12", "3.14"}, event From f83a5db5073be8ba3ddae0f9d9fc598763661a64 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Mon, 23 Nov 2026 02:01:39 +0900 Subject: [PATCH 2/3] CI: the examples leave the fast tier, the native pull-request leg keeps the oldest and the newest Python (#442) The first run of this pull request took 31.8 minutes, and both jobs that ended it were example jobs: `Test Python Examples (linux/amd64, Python 3.14)` (29.8 minutes) and `Examples on the installed wheel (linux-x86_64, Python 3.12)` (19.0). Their longest step is `Download datasets` (891 s and 608 s), which mostly builds the vectors of the Stack Overflow dataset. The target for a pull request is about 15 minutes. - A pull request runs no example leg in either workflow. The examples run on a push to main, in the nightly run, on a manual run and with the label ci:full, like the rest of the full tier. - Exception, by path and at job level: a pull request that changes a file under examples/ (not examples/README.md), scripts/run_examples.sh or scripts/native_examples_skip.txt runs the example leg of Linux x86-64. scripts/ci_tier.py reads the changed files from the API and hands the planners the event pull_request_examples. Files that cannot be read: the example legs run (fails open). - The workflows still start and their summary checks still report, so no check is left pending: `Examples Test Summary` and `Examples summary` are green for exactly the case "the plan has no example leg and the job was skipped", and red when a planned leg failed, was cancelled or did not run. In test-python-examples.yml the first job downloads no jars when there is no leg. - The native `pyver` job runs Python 3.11 and 3.14 on a pull request (the ends of the range, about a minute each, beside the parity suite). 3.13, 3.15 and the free-threaded 3.14t stay in the full tier: in 30 days no pyver leg was red on a commit whose Linux parity run was green. What stays on every pull request: the arcadedb-jvm wheel and its tests, the native image and wheel built from the pull request, and the parity suite against the installed wheel. --- .github/workflows/test-native.yml | 39 ++++-- .github/workflows/test-python-examples.yml | 71 ++++++---- CONTRIBUTING.md | 8 +- docs/modules/ROOT/pages/development/ci.adoc | 18 +-- scripts/ci_tier.py | 92 +++++++++---- scripts/select_matrix.py | 26 +++- scripts/select_native_matrix.py | 25 +++- tests/test_ci_tier.py | 140 ++++++++++++++++---- tests/test_select_matrix.py | 43 +++++- tests/test_select_native_matrix.py | 38 +++++- 10 files changed, 372 insertions(+), 128 deletions(-) diff --git a/.github/workflows/test-native.yml b/.github/workflows/test-native.yml index 2463bea9..f25bf6da 100644 --- a/.github/workflows/test-native.yml +++ b/.github/workflows/test-native.yml @@ -4,8 +4,9 @@ # # A native image build takes about 5 to 30 minutes per platform and the ArcadeData organisation shares a runner cap with # upstream ArcadeDB, so the load is selective (scripts/select_native_matrix.py holds the legs, tests/test_select_native_matrix.py pins them): -# pull request only when a native path changed (the `paths` filter below); linux-x86_64, Python 3.12 (the fast tier); not for a draft. -# With the label ci:full, or opened by Dependabot: the legs of a push to main (scripts/ci_tier.py) +# pull request only when a native path changed (the `paths` filter below); linux-x86_64, Python 3.12, no example leg (the fast tier); +# not for a draft. The example leg runs when the pull request changes the examples or their runner. With the label +# ci:full, or opened by Dependabot: the legs of a push to main (scripts/ci_tier.py decides all three) # push to main only when a native path changed; all four platforms, Python 3.12 and 3.14 # nightly all four platforms, Python 3.12 and 3.14, but only when something besides docs changed in the last 25 hours (a full run on Mondays) # dispatch all four platforms, Python 3.12 and 3.14 @@ -13,12 +14,12 @@ # This workflow never publishes: it has no id-token permission and no environment. # # Beside the full parity runs, the `pyver` job installs the already built linux-x86_64 wheel (py3-none: no rebuild) into the Pythons the full -# runs of the event leave out (main, nightly, dispatch: 3.11, 3.13; a release: none; a pull request has no `pyver` legs, the fast tier is one Python), into 3.15 (the full suite +# runs of the event leave out (main, nightly, dispatch: 3.11, 3.13; a release: none; a pull request runs only 3.11 and 3.14 of this job), into 3.15 (the full suite # needs jpype1 and ladybug, which have no cp315 wheel yet, so 3.15 runs without the test files that need jpype1) and into the free-threaded 3.14t, and runs a small subset of the tests there (about 20 s of tests per Python). A release needs it: a leg that passes uploads a marker (native-passed-pyver-py), and release-native.yml # publishes nothing unless the legs of a release (3.15 and the free-threaded 3.14t) passed. Only linux-x86_64 is checked on them. # scripts/select_native_matrix.py decides its legs. # -# The `examples` job runs every script of examples/ against the installed wheel of each platform (Python 3.12 and 3.14; a pull request: linux-x86_64, 3.12), through +# The `examples` job runs every script of examples/ against the installed wheel of each platform (Python 3.12 and 3.14; a pull request: none, or linux-x86_64 on 3.12 when it changes the examples), through # scripts/run_examples.sh, the runner test-python-examples.yml uses too. scripts/native_examples_skip.txt lists, with a reason, the examples that need the JVM package. # `examples-summary` is the one check for all its legs. They do not decide what a release publishes (release-native.yml reads the markers and the wheels only). # @@ -234,9 +235,10 @@ jobs: run: | set -euo pipefail run=true - # A pull request runs the fast tier (one platform, one Python). With the label ci:full, or opened by Dependabot, it runs the legs - # of a push to main: scripts/ci_tier.py turns its event into pull_request_full (it reads the labels again from the API, so a re-run - # after adding the label is enough). Every other event passes through unchanged. + # A pull request runs the fast tier (one platform, one Python, no examples). scripts/ci_tier.py turns its event into + # pull_request_examples when it changes the examples or their runner (the example leg too), and into pull_request_full with the + # label ci:full or a Dependabot author (the legs of a push to main; it reads the labels again from the API, so a re-run after + # adding the label is enough). Every other event passes through unchanged. event="$(python3 -I scripts/ci_tier.py "$EVENT")" echo "legs of the event: $event" if [ "$RELEASE" = true ]; then event=release; fi @@ -770,7 +772,9 @@ jobs: name: Examples on the installed wheel (${{ matrix.key }}, Python ${{ matrix.python }}) needs: [plan, build] # A platform whose build failed has no wheel to download and shows red here; the other platforms still run. - if: ${{ !cancelled() && needs.plan.outputs.run == 'true' }} + # A pull request (the fast tier) has no example leg unless it changes the examples or their runner (scripts/ci_tier.py): the list is + # empty then and the job is skipped, because an empty matrix is an error. `Examples summary` below knows that case. + if: ${{ !cancelled() && needs.plan.outputs.run == 'true' && needs.plan.outputs.examples != '[]' }} runs-on: ${{ matrix.runner }} timeout-minutes: 240 defaults: @@ -955,6 +959,8 @@ jobs: retention-days: 3 # One check for the examples of every platform and Python: red when any leg of the `examples` job failed or the job did not run to the end. + # When the plan has no example leg on purpose (the list is `[]`: a pull request, the fast tier) it is green only if the job was skipped. + # An empty list text (the plan step failed half way) is not that case: the job must then have succeeded, so the check is red. examples-summary: name: Examples summary needs: [plan, examples] @@ -965,17 +971,22 @@ jobs: - name: Check the examples legs env: RESULT: ${{ needs.examples.result }} + LEGS: ${{ needs.plan.outputs.examples }} run: | + want=success + if [ "$LEGS" = '[]' ]; then want=skipped; fi { echo "## Examples on the installed wheel" echo - if [ "$RESULT" = success ]; then - echo "All example legs passed." + if [ "$RESULT" != "$want" ]; then + echo "The examples job ended with: $RESULT (expected: $want). See the legs of the job \"Examples on the installed wheel\"." + elif [ "$want" = skipped ]; then + echo "No example leg in this run: a pull request runs the examples only when it changes them or their runner, or carries the label ci:full." else - echo "The examples job ended with: $RESULT. See the legs of the job \"Examples on the installed wheel\"." + echo "All example legs passed." fi } >> "$GITHUB_STEP_SUMMARY" - [ "$RESULT" = success ] + [ "$RESULT" = "$want" ] # The cheap Python-version coverage of the wheel of linux-x86_64 (py3-none: the same file for every Python, nothing is rebuilt): a subset of # the test files, not the whole suite. The legs are the supported Pythons the full parity runs of this event leave out, plus the @@ -990,8 +1001,8 @@ jobs: name: Python ${{ matrix.python }} on the wheel (linux-x86_64) needs: [plan, build] # The linux-x86_64 build may have failed: then there is no wheel to download and this shows red, as the test job does. - # A pull request (the fast tier) has no legs here: the list is empty and the job is skipped, because an empty matrix is an error. - # No other job needs this one, so a skipped pyver job changes no summary. + # Skipped when the list is empty, because an empty matrix is an error (every event has legs today: a pull request the oldest and the + # newest Python). No other job needs this one, so a skipped pyver job changes no summary. if: ${{ !cancelled() && needs.plan.outputs.run == 'true' && needs.plan.outputs.pyver != '[]' }} runs-on: ubuntu-latest timeout-minutes: 20 diff --git a/.github/workflows/test-python-examples.yml b/.github/workflows/test-python-examples.yml index 02458f8d..1d936b0a 100644 --- a/.github/workflows/test-python-examples.yml +++ b/.github/workflows/test-python-examples.yml @@ -132,6 +132,8 @@ jobs: if: github.event_name != 'pull_request' || github.event.pull_request.draft == false outputs: arcadedb-tag: ${{ steps.jars.outputs.arcadedb-tag }} + # "true" when this run has example legs, "false" when it has none on purpose (a pull request, the fast tier) + run: ${{ steps.matrix.outputs.run }} matrix: ${{ steps.matrix.outputs.matrix }} wheel-matrix: ${{ steps.matrix.outputs.wheel-matrix }} steps: @@ -139,12 +141,14 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # The platform x Python legs of this run (scripts/select_matrix.py). A pull request runs - # the fast tier (linux/amd64, the newest Python); every other event runs the full matrix. - # The organisation shares one runner cap with ArcadeData/arcadedb, so a pull request does - # not wait for the macOS and Windows runners. A pull request with the label ci:full, and - # one Dependabot opened, runs the legs of a push to main: scripts/ci_tier.py turns its - # event into pull_request_full (it reads the labels again from the API, so a re-run after - # adding the label is enough). + # the fast tier, which has NO example leg: the examples are the slowest jobs (20 to 30 + # minutes), so they run on a push to main, in the nightly run and on a manual run. The + # matrix is then empty, `run` is false, the rest of this job and the two jobs below are + # skipped, and the summary job says so and stays green. A pull request that changes the + # examples or their runner runs the leg of linux/amd64 on the newest Python + # (pull_request_examples). A pull request with the label ci:full, and one Dependabot + # opened, runs the legs of a push to main (pull_request_full). scripts/ci_tier.py decides: + # it reads the labels again from the API, so a re-run after adding the label is enough. # The wheel matrix is the platforms of those legs, one build each: the wheel is # py3-none-, the same file for every Python. # Done first, so a failure here costs no Docker pull. @@ -166,11 +170,17 @@ jobs: echo "$wheel_matrix" echo "matrix=$matrix" >> "$GITHUB_OUTPUT" echo "wheel-matrix=$wheel_matrix" >> "$GITHUB_OUTPUT" + # An empty matrix is an error for a job, so the jobs that take it are skipped when there is no leg + if [ "$matrix" = '{"include":[]}' ]; then run=false; else run=true; fi + echo "example legs in this run: $run" + echo "run=$run" >> "$GITHUB_OUTPUT" - name: Set up Docker Buildx + if: steps.matrix.outputs.run == 'true' uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Download JARs from ArcadeDB Docker image + if: steps.matrix.outputs.run == 'true' id: jars shell: bash run: | @@ -210,6 +220,7 @@ jobs: # Unfiltered on purpose: build-native.sh applies scripts/jar_exclusions.txt # to whatever lands in the jars directory, so the list lives in one place. - name: Upload JARs as artifact + if: steps.matrix.outputs.run == 'true' uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: arcadedb-jars-examples @@ -224,7 +235,7 @@ jobs: name: Build wheel for examples (${{ matrix.platform }}) runs-on: ${{ matrix.runs-on }} needs: download-jars - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && needs.download-jars.outputs.run == 'true' env: BUILD_VERSION: ${{ inputs.build-version }} strategy: @@ -329,7 +340,7 @@ jobs: name: Test Python Examples (${{ matrix.platform }}, Python ${{ matrix.python-version }}) runs-on: ${{ matrix.runs-on }} needs: [download-jars, build] - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && needs.download-jars.outputs.run == 'true' env: # Pin the Hugging Face cache inside the workspace so it is cacheable with # one path on every platform (the default differs per OS). The examples @@ -585,31 +596,43 @@ jobs: if-no-files-found: ignore retention-days: 14 - # Summary job that checks every leg this run started. The legs are a matrix, so the result of the job is "success" only when - # every leg of it passed, whatever their number: one leg on a pull request (the fast tier), 16 on the other events. A leg that - # failed, was cancelled or never started (its build failed) makes the result something else, and this job red. + # Summary job that checks every leg this run started, and the one check that always reports for this workflow. + # - The run has example legs (`run` is true): green only when the build and the example legs both ended with "success". They are + # matrix jobs, so the result is one word for the whole matrix whatever the number of legs; a leg that failed, was cancelled or + # never started (its build failed) makes it something else, and this job red. + # - The run has no example leg on purpose (`run` is false: a pull request, the fast tier): green only when the first job + # succeeded and both jobs were skipped. + # - Anything else is red: the first job failed, `run` is empty, or a job that should have been skipped ran. test-examples-summary: name: Examples Test Summary - needs: [build, test-examples] + needs: [download-jars, build, test-examples] runs-on: ubuntu-latest # Skipped (not red) when the matrix was skipped for a draft PR. if: always() && (github.event_name != 'pull_request' || github.event.pull_request.draft == false) steps: - name: Check test results shell: bash + env: + PLAN: ${{ needs.download-jars.result }} + RUN: ${{ needs.download-jars.outputs.run }} + BUILD: ${{ needs.build.result }} + LEGS: ${{ needs.test-examples.result }} run: | - echo "## 🎯 Overall Examples Test Summary" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - - if [ "${{ needs.build.result }}" = "success" ] && [ "${{ needs.test-examples.result }}" = "success" ]; then - echo "✅ **Every leg of this run passed example testing!**" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "All examples ran successfully on every leg this run started, against one wheel built for each platform." >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Legs**: a pull request runs linux/amd64 only (the fast tier). A push to main, the nightly run, a manual run and a pull request with the label ci:full run linux/amd64, linux/arm64, darwin/arm64 and windows/amd64. The jobs of this run list its legs." >> $GITHUB_STEP_SUMMARY + echo "## 🎯 Overall Examples Test Summary" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "first job: $PLAN, example legs in this run: ${RUN:-unknown}, build: $BUILD, examples: $LEGS" + + if [ "$PLAN" = success ] && [ "$RUN" = false ] && [ "$BUILD" = skipped ] && [ "$LEGS" = skipped ]; then + echo "⏭️ **No example leg in this run**" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "A pull request runs the examples only when it changes them or their runner, or carries the label ci:full. A push to main, the nightly run and a manual run run them on every platform." >> "$GITHUB_STEP_SUMMARY" + elif [ "$PLAN" = success ] && [ "$RUN" = true ] && [ "$BUILD" = success ] && [ "$LEGS" = success ]; then + echo "✅ **Every leg of this run passed example testing!**" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "All examples ran successfully on every leg this run started, against one wheel built for each platform. The jobs of this run list its legs." >> "$GITHUB_STEP_SUMMARY" else - echo "❌ **Some legs failed example testing**" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "Please check the individual platform jobs for details." >> $GITHUB_STEP_SUMMARY + echo "❌ **Some legs failed example testing**" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "Please check the individual platform jobs for details." >> "$GITHUB_STEP_SUMMARY" exit 1 fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee4c2a84..30911dca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -146,11 +146,13 @@ shellcheck and hadolint run as `docker_image` hooks (Docker pulls the images aut CI has two tiers, so that a pull request does not wait for the macOS and Windows runners that the organisation shares with ArcadeData/arcadedb. -- **A pull request runs the fast tier.** The static checks (pre-commit, Bandit, the dependency audits) run as before. The builds and tests run on Linux x86-64 only: the `arcadedb-jvm` wheel with the tests on Python 3.11 and 3.14 and the examples on Python 3.14 and, when a native path changed, the native image and wheel with the tests and the examples on Python 3.12. A pull request that changes only documentation runs no platform job. -- **`main` runs the full tier.** A push to `main` and the nightly run (03:00 to 04:00 UTC) test all four platforms: Linux x86-64, Linux arm64, macOS arm64 and Windows x86-64. A release tests every platform on every Python version. +- **A pull request runs the fast tier.** The static checks (pre-commit, Bandit, the dependency audits) run as before. The builds and tests run on Linux x86-64 only: the `arcadedb-jvm` wheel with the tests on Python 3.11 and 3.14 and, when a native path changed, the native image and wheel with the parity suite on Python 3.12 and a short subset on Python 3.11 and 3.14. The examples do not run, unless the pull request changes a file under `examples/` or their runner (`scripts/run_examples.sh`, `scripts/native_examples_skip.txt`). A pull request that changes only documentation runs no platform job. +- **`main` runs the full tier.** A push to `main` and the nightly run (03:00 to 04:00 UTC) test all four platforms (Linux x86-64, Linux arm64, macOS arm64 and Windows x86-64) and run the examples on each. A release tests every platform on every Python version. - **To run the full tier on a pull request**, add the label `ci:full`, then push a commit or choose "Re-run all jobs" on its test workflows. The pull request then runs what a push to `main` runs. Use it for a change that can behave differently on another platform: file paths, processes and signals, the wheel build, the native library, a workflow file. If you cannot add labels, ask for it in the pull request. Dependabot pull requests always run the full tier. -A problem that only another platform shows is found on `main` after the merge: the badges at the top of the README turn red, and the fix or the revert comes before the next release. [Continuous integration](docs/modules/ROOT/pages/development/ci.adoc) lists the legs of each event. +The wait of a pull request is set by the native image build and the parity suite that follows it. A pull request that changes no native path waits for the `arcadedb-jvm` tests only. + +A problem that only another platform or an example shows is found on `main` after the merge: the badges at the top of the README turn red, and the fix or the revert comes before the next release. [Continuous integration](docs/modules/ROOT/pages/development/ci.adoc) lists the legs of each event. A commit message starts with a short subject that says what changes and where, for example `Native find_nearest: send the query vector as one float32 array, not a Python list`. The body says why. Link the issue with `Closes #N` in the pull request. diff --git a/docs/modules/ROOT/pages/development/ci.adoc b/docs/modules/ROOT/pages/development/ci.adoc index 3eea431e..b580ee5f 100644 --- a/docs/modules/ROOT/pages/development/ci.adoc +++ b/docs/modules/ROOT/pages/development/ci.adoc @@ -26,7 +26,7 @@ The package supports four platforms and four Python versions (3.11 to 3.14). Tha The CI has two tiers. -* The fast tier runs on every pull request: the static checks, and the builds and tests on Linux x86-64 only. It waits for no macOS, Windows or arm64 runner. +* The fast tier runs on every pull request: the static checks, and the builds and tests on Linux x86-64 only. It waits for no macOS, Windows or arm64 runner. It runs no example job: the examples are the slowest jobs (they build the vectors of a dataset and run 30 scripts), so they run in the full tier. A pull request that changes a file under `examples/` (not `examples/README.md`), `scripts/run_examples.sh` or `scripts/native_examples_skip.txt` runs the example legs of Linux x86-64 too. * The full tier runs on a push to `main`, on the nightly run, on a manual run and on a release. It tests all four platforms. A release tests every platform on every Python version. A pull request runs the legs of a push to `main` when it carries the label `ci:full`. Add the label, then push a commit or choose "Re-run all jobs" on the test workflows of the pull request: `scripts/ci_tier.py` reads the labels again at the start of each run, so no new commit is needed. Use the label for a change that can behave differently on another platform: file paths, processes and signals, the wheel build, the native library, a workflow file. To go back to the fast tier, remove the label and push a commit. A pull request that Dependabot opened always runs the full tier, because the hourly job merges it without a reader. When the labels cannot be read, the pull request runs the full tier. @@ -35,7 +35,9 @@ The nightly runs start between 03:00 and 04:00 UTC, when the shared runners are A problem that only another platform shows is found on `main`, after the merge, or in the nightly run. The badges of `test-jvm.yml`, `test-native.yml` and `test-python-examples.yml` at the top of the README show the last run of each workflow on `main`, and GitHub sends a mail to the person who merged. Fix or revert before the next release. The release workflows run the full matrix again and publish nothing when a leg is red. -The summary jobs (`Test Summary`, `Examples Test Summary`, `Examples summary`) check the legs that the run started. A leg that failed or was cancelled makes them red in both tiers. A leg that the tier does not start is not in the run, so nothing waits for it. +The summary jobs (`Test Summary`, `Examples Test Summary`, `Examples summary`) check the legs that the run started. A leg that failed or was cancelled makes them red in both tiers. A leg that the tier does not start is not in the run, so nothing waits for it. When a pull request has no example leg, the example jobs are skipped on purpose. The two example summaries are green for exactly that case (the plan has no leg and the job was skipped) and say so. They are red when a planned leg did not run. + +With the examples out of the fast tier, the wait of a pull request is set by the native workflow: the native image build, then the parity suite against the wheel that was just built (issue 442 has the timings of each job). A pull request that changes no native path does not start that workflow and waits for the `arcadedb-jvm` tests only. == One wheel for each platform @@ -56,7 +58,7 @@ The script `scripts/select_matrix.py` chooses the combinations. The first job of | Pull request (the fast tier) | 2 legs: `linux/amd64` on Python 3.11 and 3.14. -| `linux/amd64` on Python 3.14. +| None. `linux/amd64` on Python 3.14 when the pull request changes the examples or their runner. | Push to `main`, the nightly run, a pull request with the label `ci:full`, a Dependabot pull request | 10 legs: `linux/amd64` on all four Python versions. `linux/arm64`, `darwin/arm64` and `windows/amd64` on Python 3.11 and 3.14. @@ -67,7 +69,7 @@ The script `scripts/select_matrix.py` chooses the combinations. The first job of | All 16 combinations. |=== -The unit tests run 2 legs on a pull request (the oldest and the newest Python on `linux/amd64`), 10 legs on a push to `main` and the nightly run (all Python versions on one Linux platform, the oldest and the newest elsewhere), and all 16 combinations on a release and a manual run, like the native package: what is published is tested on every platform and Python it claims. `release-jvm.yml` calls the workflow with `release: true`, which the matrix step turns into the event `release`, because in a called workflow `github.event_name` is the caller's tag push. A pull request runs 11 checks in these two workflows: 3 test jobs (2 and 1), 2 wheel builds (one for each workflow), the two `Download ArcadeDB JARs` jobs, the two summary jobs, `Bandit security scan` and `Dependency floor audit`. A push, the nightly run and a pull request that asks for the full tier run 40: 26 test jobs (10 and 16), 8 wheel builds (4 for each workflow) and the same six other jobs. A manual run and a release run 46, with the 6 extra unit-test legs. +The unit tests run 2 legs on a pull request (the oldest and the newest Python on `linux/amd64`), 10 legs on a push to `main` and the nightly run (all Python versions on one Linux platform, the oldest and the newest elsewhere), and all 16 combinations on a release and a manual run, like the native package: what is published is tested on every platform and Python it claims. `release-jvm.yml` calls the workflow with `release: true`, which the matrix step turns into the event `release`, because in a called workflow `github.event_name` is the caller's tag push. A pull request runs 9 jobs in these two workflows: 2 test jobs, 1 wheel build, the two `Download ArcadeDB JARs` jobs (the one of `test-python-examples.yml` only chooses the legs, and downloads nothing when there is none), the two summary jobs, `Bandit security scan` and `Dependency floor audit`. The build and the example job of `test-python-examples.yml` show as skipped, and `Examples Test Summary` is green and says that the run has no example leg. A push, the nightly run and a pull request that asks for the full tier run 40: 26 test jobs (10 and 16), 8 wheel builds (4 for each workflow) and the same six other jobs. A manual run and a release run 46, with the 6 extra unit-test legs. The names of the test jobs do not change: `Test arcadedb (, Python )`. A check keeps its history when a pull request runs fewer of them. No check is required by a branch rule today. If one becomes required, choose a job of the fast tier or a summary job: a required check that only the full tier starts would never report on a pull request. @@ -117,13 +119,13 @@ To close a release, close its milestone and open the next one with its due date: The workflow `test-native.yml` builds the native image of the `arcadedb` package and runs the test suite against the installed wheel. It does not follow the table above. It never publishes; `release-native.yml` calls it on a version tag. -* A pull request runs it only when native paths change: `+native/**+`, `+src/arcadedb/**+`, `+tests/**+`, `+examples/**+` (not `examples/README.md`), `pyproject.toml`, `setup.py`, `scripts/select_native_matrix.py`, `scripts/smoke_wheel.py`, `scripts/run_examples.sh`, `scripts/native_examples_skip.txt` or `test-native.yml` itself. Changes under `tests/` and `src/arcadedb/` are included because both backends share those files, so a shared test or source can break native parity without touching a native file; docs outside those paths do not run it. It then runs on `linux-x86_64` with Python 3.12 only (the fast tier): the image and the wheel, the parity suite and the examples. With the label `ci:full`, and for a Dependabot pull request, it runs the legs of a push to `main`. +* A pull request runs it only when native paths change: `+native/**+`, `+src/arcadedb/**+`, `+tests/**+`, `+examples/**+` (not `examples/README.md`), `pyproject.toml`, `setup.py`, `scripts/select_native_matrix.py`, `scripts/smoke_wheel.py`, `scripts/run_examples.sh`, `scripts/native_examples_skip.txt` or `test-native.yml` itself. Changes under `tests/` and `src/arcadedb/` are included because both backends share those files, so a shared test or source can break native parity without touching a native file; docs outside those paths do not run it. It then runs on `linux-x86_64` only (the fast tier): the image and the wheel, the parity suite on Python 3.12 and the `pyver` subset on Python 3.11 and 3.14. The examples run only when the pull request changes them or their runner. With the label `ci:full`, and for a Dependabot pull request, it runs the legs of a push to `main`. * A push to `main` (only when a native path changed, same filter as a pull request), the nightly run (skipped when nothing changed in the last 25 hours, except on Mondays) and a manual run (dispatch) run all four platforms: `linux-x86_64`, `linux-aarch64`, `macos-arm64` and `windows-x64` (Python 3.12 and 3.14). A release (`release-native.yml` calls the workflow with `release: true`) runs the same four platforms on all four Python versions, 16 legs. -* The `pyver` job installs the already built `linux-x86_64` wheel (no rebuild) into the Pythons that the full parity runs of the event leave out (3.11 and 3.13 on a push to `main`, the nightly run and a dispatch; none on a release) into 3.15 and into the free-threaded 3.14t, and runs 13 test files there (14 where polars installs; 3.15 has no jpype1 wheel, so it leaves out the two files that need jpype1), about 20 seconds of tests per Python. A release needs it: a `pyver` leg that passes uploads the marker `native-passed-pyver-py` (it holds the file name of the wheel the leg installed), and `Verify what may be published` in `release-native.yml` requires the markers of 3.15 and 3.14t, the two legs of a release, and that both tested the `linux-x86_64` wheel that is published. A red leg stops a release before anything reaches PyPI. A pull request has no `pyver` legs (the fast tier is one Python): the job shows as skipped there. Only `linux-x86_64` is checked on these two Pythons: the other platforms are not tested on 3.15 and 3.14t, and the JVM package has no such job. The 3.14t leg has no polars (no free-threaded wheel exists), so it skips `test_dataframe_ingest.py`. `scripts/select_native_matrix.py` decides its legs, and `tests/test_select_native_matrix.py` and `tests/test_release_native_verify.py` pin the gate. +* The `pyver` job installs the already built `linux-x86_64` wheel (no rebuild) into the Pythons that the full parity runs of the event leave out (3.11 and 3.13 on a push to `main`, the nightly run and a dispatch; none on a release) into 3.15 and into the free-threaded 3.14t, and runs 13 test files there (14 where polars installs; 3.15 has no jpype1 wheel, so it leaves out the two files that need jpype1), about 20 seconds of tests per Python. A release needs it: a `pyver` leg that passes uploads the marker `native-passed-pyver-py` (it holds the file name of the wheel the leg installed), and `Verify what may be published` in `release-native.yml` requires the markers of 3.15 and 3.14t, the two legs of a release, and that both tested the `linux-x86_64` wheel that is published. A red leg stops a release before anything reaches PyPI. A pull request runs only two legs of this job, Python 3.11 and 3.14 (the oldest and the newest): 3.13, 3.15 and 3.14t run in the full tier. In the 30 days before issue 442 no `pyver` leg was red on a commit where the parity suite on Linux x86-64 was green. Only `linux-x86_64` is checked on these two Pythons: the other platforms are not tested on 3.15 and 3.14t, and the JVM package has no such job. The 3.14t leg has no polars (no free-threaded wheel exists), so it skips `test_dataframe_ingest.py`. `scripts/select_native_matrix.py` decides its legs, and `tests/test_select_native_matrix.py` and `tests/test_release_native_verify.py` pin the gate. * Every test file runs in its own process (`native/wheel/parity_wheel.py`). A process that dies without writing its result is a `CRASH` row in `parity-wheel.tsv` with its exit code, for example `CRASH(rc=0xC0000005,3221225477)`, and it fails the leg. On the Windows legs only (the crashes of issue 295 happen there), the harness runs such a file once more in a fresh process (`--retry-crash`). A retry that produces a result is a `FLAKY-CRASH` row: the gate lets the leg pass, the job summary lists the file with the first exit code, and on a release or a dispatch the `crash-report` job adds one comment to issue 295 (run URL, Python, wheel version, exit codes). A second crash, a failing test, a timeout and every crash on Linux or macOS stay failures. A process that wrote its result and then died in shutdown is a `DIRTY-EXIT` record (exit code, file, attempt) in the metadata, the job summary and the issue comment: it is not retried and does not fail the leg. Each Windows test process also writes a faulthandler trace, `parity-wheel-xml/.attemptN.fault.txt`, into the parity artifact of the leg. Only a retry hides a crash, so treat a `FLAKY-CRASH` as an open bug: read the trace in the artifact before a release is announced. -* The `examples` job runs every script of `examples/` against the installed wheel of each platform (Python 3.12 and 3.14; a pull request: `linux-x86_64`, Python 3.12) through `scripts/run_examples.sh`, the runner that `test-python-examples.yml` uses too. `scripts/native_examples_skip.txt` lists, with a reason, the examples that need the JVM package. `Examples summary` is the one check for all its legs. These legs do not decide what a release publishes. +* The `examples` job runs every script of `examples/` against the installed wheel of each platform (Python 3.12 and 3.14; a pull request: no leg, or `linux-x86_64` on Python 3.12 when it changes the examples or their runner) through `scripts/run_examples.sh`, the runner that `test-python-examples.yml` uses too. `scripts/native_examples_skip.txt` lists, with a reason, the examples that need the JVM package. `Examples summary` is the one check for all its legs. These legs do not decide what a release publishes. * A native image build takes about 5 to 30 minutes for each platform (macOS is the slowest). The organisation shares one runner limit with upstream ArcadeDB, so do not add runs lightly. Change the paths or the matrix of `test-native.yml` only for a reason that you can write down. == Change the selection -Edit `JVM_LEGS` (unit tests on the events in `JVM_REDUCED_EVENTS`: a push and the nightly run; every other event but a pull request runs the full matrix) or `PULL_REQUEST_LEGS` (the fast tier: unit tests and examples on a pull request) in `scripts/select_matrix.py`. The legs of the native workflow are in `scripts/select_native_matrix.py`. `scripts/ci_tier.py` holds the name of the label and decides whether a pull request runs the fast tier or the legs of a push. The tests `tests/test_select_matrix.py`, `tests/test_select_native_matrix.py` and `tests/test_ci_tier.py` fix the legs, so a change that shrinks them fails. When you add a Python version, add it to `PYTHONS` in the script and to the classifiers in `pyproject.toml`. A test checks that both lists are the same, that `requires-python` starts at the oldest of them and stops before the minor after the newest. When you drop one, remove it from the same places and update the counts in the test. +Edit `JVM_LEGS` (unit tests on the events in `JVM_REDUCED_EVENTS`: a push and the nightly run; every other event but a pull request runs the full matrix) or `PULL_REQUEST_LEGS` (the fast tier: unit tests and examples on a pull request) in `scripts/select_matrix.py`. The legs of the native workflow are in `scripts/select_native_matrix.py`. `scripts/ci_tier.py` holds the name of the label and the paths that start the example legs, and decides whether a pull request runs the fast tier, the fast tier with the example legs, or the legs of a push. The tests `tests/test_select_matrix.py`, `tests/test_select_native_matrix.py` and `tests/test_ci_tier.py` fix the legs, so a change that shrinks them fails. When you add a Python version, add it to `PYTHONS` in the script and to the classifiers in `pyproject.toml`. A test checks that both lists are the same, that `requires-python` starts at the oldest of them and stops before the minor after the newest. When you drop one, remove it from the same places and update the counts in the test. diff --git a/scripts/ci_tier.py b/scripts/ci_tier.py index 03f1bb01..5fd7c576 100644 --- a/scripts/ci_tier.py +++ b/scripts/ci_tier.py @@ -1,27 +1,28 @@ #!/usr/bin/env python3 -"""Name the event the leg planners get, so a pull request runs the fast tier unless it asks for the full one. +"""Name the event the leg planners get, so a pull request runs the fast tier unless it asks for more. CI has two tiers (docs page development/ci.adoc): -- fast: a pull request. Linux x86-64 only, the legs of the event `pull_request` in scripts/select_matrix.py and - scripts/select_native_matrix.py. +- fast: a pull request. Linux x86-64 only and no example legs, the legs of the event `pull_request` in scripts/select_matrix.py and + scripts/select_native_matrix.py. A pull request that changes the examples or their runner (EXAMPLE_PATHS) also runs the example + legs of Linux x86-64: the event `pull_request_examples`. - full: a push to main, the nightly run, a manual run and a release, each with the legs of its own event. A pull request gets the - legs of a push to main when it carries the label `ci:full` or when Dependabot opened it (nobody reads a Dependabot pull request - before the hourly job merges it, so the full matrix is its only review). + legs of a push to main (the event `pull_request_full`) when it carries the label `ci:full` or when Dependabot opened it (nobody + reads a Dependabot pull request before the hourly job merges it, so the full matrix is its only review). usage: ci_tier.py EVENT EVENT: the event that started the workflow -Prints EVENT unchanged unless it is `pull_request`. For a pull request it prints `pull_request` (fast) or `pull_request_full` -(the legs of a push to main), and says why on stderr. It reads: +Prints EVENT unchanged unless it is `pull_request`. For a pull request it prints `pull_request`, `pull_request_examples` or +`pull_request_full`, and says why on stderr. It reads: PR_AUTHOR the login of the author (github.event.pull_request.user.login) PR_LABELS the label names in the event, a JSON list (toJSON(github.event.pull_request.labels.*.name)) PR_NUMBER, GITHUB_REPOSITORY, GH_TOKEN - to read the labels the pull request has now, through `gh api` + to read the labels the pull request has now and the files it changes, through `gh api` The labels are read again from the API because a re-run keeps the event of the first attempt: with the label added afterwards, -"Re-run all jobs" is enough to get the full matrix, no new commit is needed. The choice fails open: when the labels cannot be read, -the pull request runs the full tier, never less. +"Re-run all jobs" is enough to get the full matrix, no new commit is needed. The choice fails open, never to less: when the labels +cannot be read the pull request runs the full tier, and when the changed files cannot be read it runs the example legs. """ from __future__ import annotations @@ -37,31 +38,56 @@ FULL_AUTHORS = ("dependabot[bot]",) FAST_EVENT = "pull_request" +EXAMPLES_EVENT = "pull_request_examples" FULL_EVENT = "pull_request_full" +# A pull request that changes one of these runs the example legs: a file under examples/ (the scripts, their data loader), or the +# runner both example jobs call and the list of examples the native wheel leaves out. examples/README.md is prose only. +EXAMPLE_DIRS = ("examples/",) +EXAMPLE_FILES = ("scripts/run_examples.sh", "scripts/native_examples_skip.txt") +NOT_EXAMPLES = ("examples/README.md",) -def live_labels(repo: str, number: str) -> list[str] | None: - """The label names the pull request has now, or None when they cannot be read.""" - if not repo or not number: - return None + +def _gh_lines(path: str, jq: str) -> list[str] | None: + """The lines `gh api --paginate PATH --jq JQ` prints (one value on each line), or None when the call fails.""" try: proc = subprocess.run( - [ - "gh", - "api", - f"repos/{repo}/issues/{number}/labels?per_page=100", - "--jq", - ".[].name", - ], + ["gh", "api", "--paginate", path, "--jq", jq], capture_output=True, text=True, - timeout=60, + timeout=120, ) except (OSError, subprocess.SubprocessError): return None if proc.returncode != 0: return None - return proc.stdout.splitlines() + return [line for line in proc.stdout.splitlines() if line] + + +def live_labels(repo: str, number: str) -> list[str] | None: + """The label names the pull request has now, or None when they cannot be read.""" + if not repo or not number: + return None + return _gh_lines(f"repos/{repo}/issues/{number}/labels?per_page=100", ".[].name") + + +def changed_files(repo: str, number: str) -> list[str] | None: + """The paths the pull request changes (for a rename: the new and the old path), or None when they cannot be read.""" + if not repo or not number: + return None + return _gh_lines( + f"repos/{repo}/pulls/{number}/files?per_page=100", + ".[] | .filename, (.previous_filename // empty)", + ) + + +def touches_examples(paths: list[str]) -> bool: + """True when one of the paths is an example, its data loader or the runner of the example jobs.""" + return any( + path not in NOT_EXAMPLES + and (path in EXAMPLE_FILES or path.startswith(EXAMPLE_DIRS)) + for path in paths + ) def payload_labels(text: str) -> list[str]: @@ -80,8 +106,9 @@ def planner_event( author: str, labels: list[str], read_live: Callable[[], list[str] | None], + read_files: Callable[[], list[str] | None], ) -> tuple[str, str]: - """(the event for the planners, why). `read_live` is called only when nothing else has already decided.""" + """(the event for the planners, why). `read_live` and `read_files` are called only when nothing else has already decided.""" if event != FAST_EVENT: return ( event, @@ -102,7 +129,18 @@ def planner_event( FULL_EVENT, f"full tier: the label {FULL_LABEL} was added after the event", ) - return FAST_EVENT, f"fast tier: no label {FULL_LABEL}" + files = read_files() + if files is None: + return ( + EXAMPLES_EVENT, + "fast tier with the example legs: the changed files could not be read (fails open)", + ) + if touches_examples(files): + return ( + EXAMPLES_EVENT, + "fast tier with the example legs: the pull request changes the examples or their runner", + ) + return FAST_EVENT, f"fast tier: no label {FULL_LABEL}, no example changed" def main(argv: list[str] | None = None) -> int: @@ -111,11 +149,13 @@ def main(argv: list[str] | None = None) -> int: print("usage: ci_tier.py EVENT", file=sys.stderr) return 2 env = os.environ + repo, number = env.get("GITHUB_REPOSITORY", ""), env.get("PR_NUMBER", "") event, why = planner_event( args[0], env.get("PR_AUTHOR", ""), payload_labels(env.get("PR_LABELS", "")), - lambda: live_labels(env.get("GITHUB_REPOSITORY", ""), env.get("PR_NUMBER", "")), + lambda: live_labels(repo, number), + lambda: changed_files(repo, number), ) print(why, file=sys.stderr) print(event) diff --git a/scripts/select_matrix.py b/scripts/select_matrix.py index 1fe3de11..2de768d2 100644 --- a/scripts/select_matrix.py +++ b/scripts/select_matrix.py @@ -3,10 +3,12 @@ The wheels support four platforms and four Python versions. -CI has two tiers. A pull request runs the fast tier: linux/amd64 only, so it does not wait for the macOS and Windows -runners the organisation shares with ArcadeData/arcadedb. Every other event runs the full tier, and a pull request -that asks for it (the label `ci:full`, or a Dependabot author; scripts/ci_tier.py decides and passes the event -`pull_request_full`) runs the legs of a push to main. +CI has two tiers. A pull request runs the fast tier: linux/amd64 only and no example legs, so it does not wait for +the macOS and Windows runners the organisation shares with ArcadeData/arcadedb, nor for the examples (the slowest +jobs). Every other event runs the full tier, and a pull request that asks for it (the label `ci:full`, or a +Dependabot author; scripts/ci_tier.py decides and passes the event `pull_request_full`) runs the legs of a push to +main. A pull request that changes the examples or their runner gets the event `pull_request_examples`: the fast +tier and the example leg of linux/amd64. - `jvm` (test-jvm.yml) runs 2 legs on a pull request (linux/amd64, the oldest and the newest Python), 10 legs on a push to main and the nightly schedule, and all 16 for a release (release-jvm.yml calls the workflow with @@ -16,8 +18,9 @@ platforms: a bug that depends on the interpreter shows on the ends of the range, and one that depends on the platform shows on any version of it. What is published, and a run started by hand before a release, gets every combination, like test-native.yml. -- `examples` (test-python-examples.yml) runs the newest Python on linux/amd64 on a pull request, and every - combination (16 legs) on every other event. +- `examples` (test-python-examples.yml) runs no leg on a pull request (the matrix is empty and the workflow skips + its jobs), the newest Python on linux/amd64 on a pull request that changes the examples, and every combination + (16 legs) on every other event. The selection fails open to the full matrix: an event name this script does not know runs everything, never less (for `jvm` too: only a pull request, a push and the nightly schedule get fewer than 16 legs). @@ -78,12 +81,19 @@ # carries the label `ci:full`. # # jvm: the oldest and the newest Python, the ends of the range. -# examples: the newest Python. The examples are slow (torch, sentence-transformers); their platform-specific +# examples: no leg. The examples are the slowest jobs (about 20 to 30 minutes: they build the vectors of a dataset +# and run 30 scripts), so they run in the full tier. A pull request that changes the examples or their runner +# (the event `pull_request_examples`, scripts/ci_tier.py) runs them on the newest Python; their platform-specific # code (`os.name == "nt"` branches in examples 07 to 12) and the per-platform steps of the workflow (a CPU torch # index on macOS, UTF-8 on Windows) are covered by the full tier. FAST_PLATFORM = "linux/amd64" PULL_REQUEST_LEGS = { "jvm": {FAST_PLATFORM: (OLDEST, NEWEST)}, + "examples": {}, +} +PULL_REQUEST_EXAMPLES = "pull_request_examples" +PULL_REQUEST_EXAMPLES_LEGS = { + "jvm": PULL_REQUEST_LEGS["jvm"], "examples": {FAST_PLATFORM: (NEWEST,)}, } # The event scripts/ci_tier.py passes for a pull request that asks for the full tier: the legs of a push to main. @@ -110,6 +120,8 @@ def select(workflow: str, event: str) -> dict[str, list[dict[str, str]]]: event = "push" if event == "pull_request": return {"include": _legs(PULL_REQUEST_LEGS[workflow])} + if event == PULL_REQUEST_EXAMPLES: + return {"include": _legs(PULL_REQUEST_EXAMPLES_LEGS[workflow])} if workflow == "jvm" and event in JVM_REDUCED_EVENTS: return {"include": _legs(JVM_LEGS)} return {"include": _legs({platform: PYTHONS for platform in RUNNERS})} diff --git a/scripts/select_native_matrix.py b/scripts/select_native_matrix.py index 4f924688..581ad602 100644 --- a/scripts/select_native_matrix.py +++ b/scripts/select_native_matrix.py @@ -2,13 +2,14 @@ """Choose the legs of the native test workflow (.github/workflows/test-native.yml) for one event. A native image build takes about 5 to 30 minutes per platform and the ArcadeData organisation shares a runner cap with -upstream ArcadeDB, so a pull request (the fast tier) builds one platform (linux-x86_64) and tests one Python (3.12, no `pyver` legs), -and only when native paths changed (the workflow's `paths` filter). Push to main, the nightly run and a dispatch build all four +upstream ArcadeDB, so a pull request (the fast tier) builds one platform (linux-x86_64), runs the parity suite on one Python (3.12) and the +`pyver` subset on the oldest and the newest Python (3.11, 3.14), and only when native paths changed (the workflow's `paths` filter). It runs +no example leg, unless it changes the examples or their runner (the event `pull_request_examples`, scripts/ci_tier.py). Push to main, the nightly run and a dispatch build all four platforms and test Python 3.12 and 3.14 on each. A release (release-native.yml calls the workflow with `release: true`) tests every supported Python (3.11 to 3.14) on all four. A pull request that asks for the full tier (the label `ci:full`, or a Dependabot author; scripts/ci_tier.py decides and passes the event `pull_request_full`) runs the legs of a push to main. -usage: select_native_matrix.py EVENT EVENT: pull_request | pull_request_full | push | schedule | workflow_dispatch | release +usage: select_native_matrix.py EVENT EVENT: pull_request | pull_request_examples | pull_request_full | push | schedule | workflow_dispatch | release Prints `build=`, `test=`, `pyver=` and `examples=` lines (GITHUB_OUTPUT format). Publishing is not decided here: release-native.yml does it. `pyver` is the cheap Python-version job (see PYVER_NOTE): a subset of the tests against the built @@ -105,6 +106,8 @@ PULL_REQUEST_PLATFORMS = ["linux-x86_64"] PULL_REQUEST_PYTHONS = ["3.12"] +# The legs of the `pyver` job on a pull request: the oldest and the newest supported Python. +PULL_REQUEST_PYVER = [ALL_PYTHONS[0], ALL_PYTHONS[-1]] MAIN_PYTHONS = ["3.12", "3.14"] # The Pythons of the `examples` job (the examples of examples/ against the installed wheel): the parity Pythons of a push, the nightly run and a # dispatch. A release runs the parity suite on every supported Python, but the examples only on these two. @@ -128,7 +131,7 @@ def pyver_legs(covered: list[str]) -> list[dict]: def select(event: str) -> dict: if event == "pull_request_full": event = "push" - if event == "pull_request": + if event in ("pull_request", "pull_request_examples"): platforms, pythons = PULL_REQUEST_PLATFORMS, PULL_REQUEST_PYTHONS elif event in ("push", "schedule", "workflow_dispatch"): platforms, pythons = ALL_PLATFORMS, MAIN_PYTHONS @@ -148,12 +151,19 @@ def select(event: str) -> dict: for py in pythons ] examples = [leg for leg in test if leg["python"] in EXAMPLES_PYTHONS] + pyver = pyver_legs(pythons) + if event in ("pull_request", "pull_request_examples"): + # The fast tier: the Python-version subset on the ends of the supported range only (the parity suite runs the Python between + # them). 3.13, 3.15 and the free-threaded 3.14t run on main, every night and for a release (where 3.15 and 3.14t are a gate). + pyver = [leg for leg in pyver if leg["python"] in PULL_REQUEST_PYVER] + if event == "pull_request": + # The examples are the slowest job (about 20 minutes): the full tier runs them, and a pull request only when it changes them. + # test-native.yml skips the job when this list is empty. + examples = [] return { "build": build, "test": test, - # The fast tier is one Python: the Python-version legs run on main, every night and for a release (where they are a gate), - # and on a pull request that asks for the full tier. test-native.yml skips the job when this list is empty. - "pyver": [] if event == "pull_request" else pyver_legs(pythons), + "pyver": pyver, "examples": examples, } @@ -164,6 +174,7 @@ def main(argv: list[str] | None = None) -> int: "event", choices=[ "pull_request", + "pull_request_examples", "pull_request_full", "push", "schedule", diff --git a/tests/test_ci_tier.py b/tests/test_ci_tier.py index 8a43d629..98752ff9 100644 --- a/tests/test_ci_tier.py +++ b/tests/test_ci_tier.py @@ -1,4 +1,4 @@ -"""The tier of a CI run (scripts/ci_tier.py): a pull request runs the fast tier unless it asks for the full one.""" +"""The tier of a CI run (scripts/ci_tier.py): a pull request runs the fast tier unless it asks for more.""" from __future__ import annotations @@ -18,7 +18,11 @@ def _never(): - raise AssertionError("the labels were read from the API") + raise AssertionError("the API was asked") + + +def _no_files(): + return ["src/arcadedb/core.py", "tests/test_core.py"] @pytest.mark.parametrize( @@ -26,14 +30,16 @@ def _never(): ["push", "schedule", "workflow_dispatch", "release", "", "some_new_event"], ) def test_every_event_but_a_pull_request_passes_through_unchanged(event): - # the label and the author matter for a pull request only, and no other event costs an API call - chosen, _why = ct.planner_event(event, "dependabot[bot]", ["ci:full"], _never) + # the label, the author and the changed files matter for a pull request only, and no other event costs an API call + chosen, _why = ct.planner_event( + event, "dependabot[bot]", ["ci:full"], _never, _never + ) assert chosen == event def test_a_pull_request_without_the_label_runs_the_fast_tier(): chosen, why = ct.planner_event( - "pull_request", "someone", ["bug"], lambda: ["bug", "native"] + "pull_request", "someone", ["bug"], lambda: ["bug", "native"], _no_files ) assert chosen == "pull_request" assert "fast tier" in why @@ -41,7 +47,7 @@ def test_a_pull_request_without_the_label_runs_the_fast_tier(): def test_the_label_in_the_event_asks_for_the_full_tier_without_an_api_call(): chosen, _why = ct.planner_event( - "pull_request", "someone", ["bug", "ci:full"], _never + "pull_request", "someone", ["bug", "ci:full"], _never, _never ) assert chosen == "pull_request_full" @@ -49,30 +55,88 @@ def test_the_label_in_the_event_asks_for_the_full_tier_without_an_api_call(): def test_the_label_added_after_the_event_asks_for_the_full_tier_on_a_rerun(): # a re-run keeps the event of the first attempt, so the labels are read again from the API chosen, why = ct.planner_event( - "pull_request", "someone", ["bug"], lambda: ["bug", "ci:full"] + "pull_request", "someone", ["bug"], lambda: ["bug", "ci:full"], _never ) assert chosen == "pull_request_full" assert "after the event" in why def test_labels_that_cannot_be_read_fail_open_to_the_full_tier(): - chosen, why = ct.planner_event("pull_request", "someone", [], lambda: None) + chosen, why = ct.planner_event("pull_request", "someone", [], lambda: None, _never) assert chosen == "pull_request_full" assert "fails open" in why def test_a_dependabot_pull_request_runs_the_full_tier(): # the hourly job merges it without a reader, so the full matrix is its only review - chosen, _why = ct.planner_event("pull_request", "dependabot[bot]", [], _never) + chosen, _why = ct.planner_event( + "pull_request", "dependabot[bot]", [], _never, _never + ) assert chosen == "pull_request_full" def test_only_the_exact_label_counts(): near = ["ci:fullish", "not ci:full", "CI:FULL", "ci"] - chosen, _why = ct.planner_event("pull_request", "someone", near, lambda: near) + chosen, _why = ct.planner_event( + "pull_request", "someone", near, lambda: near, _no_files + ) + assert chosen == "pull_request" + + +@pytest.mark.parametrize( + "path", + [ + "examples/03_vector_search.py", + "examples/download_data.py", + "examples/scripts/anything.sh", + "scripts/run_examples.sh", + "scripts/native_examples_skip.txt", + ], +) +def test_a_pull_request_that_changes_the_examples_or_their_runner_runs_the_example_legs( + path, +): + chosen, why = ct.planner_event( + "pull_request", "someone", [], lambda: [], lambda: ["README.md", path] + ) + assert chosen == "pull_request_examples" + assert "example" in why + + +@pytest.mark.parametrize( + "path", + [ + "examples/README.md", + "src/arcadedb/examples/x.py", + "docs/examples/x.adoc", + "scripts/run_examples.sh.bak", + "tests/test_examples.py", + "examples", + ], +) +def test_other_paths_do_not_start_the_example_legs(path): + chosen, _why = ct.planner_event( + "pull_request", "someone", [], lambda: [], lambda: [path] + ) assert chosen == "pull_request" +def test_changed_files_that_cannot_be_read_fail_open_to_the_example_legs(): + chosen, why = ct.planner_event( + "pull_request", "someone", [], lambda: [], lambda: None + ) + assert chosen == "pull_request_examples" + assert "fails open" in why + + +def test_the_full_tier_wins_over_the_example_legs(): + # the full tier has the example legs of every platform, so the changed files are not even read + chosen, _why = ct.planner_event( + "pull_request", "someone", ["ci:full"], _never, _never + ) + assert chosen == "pull_request_full" + + @pytest.mark.parametrize( ("text", "labels"), [ @@ -97,37 +161,54 @@ def __init__(self, returncode, stdout): self.stdout = stdout -def test_the_live_labels_come_from_gh_api_one_name_on_each_line(monkeypatch): +def test_the_live_labels_and_the_changed_files_come_from_gh_api_one_value_on_each_line( + monkeypatch, +): calls = [] def run(cmd, **kwargs): calls.append(cmd) - return _Proc(0, "bug\nci:full\n") + if "/labels" in cmd[3]: + return _Proc(0, "bug\nci:full\n") + return _Proc(0, "examples/new_name.py\nexamples/old_name.py\nREADME.md\n") monkeypatch.setattr(ct.subprocess, "run", run) assert ct.live_labels("ArcadeData/arcadedb-python", "7") == ["bug", "ci:full"] - assert calls[0][:2] == ["gh", "api"] - assert "repos/ArcadeData/arcadedb-python/issues/7/labels" in calls[0][2] - - -def test_the_live_labels_are_unknown_when_gh_fails_is_missing_or_has_nothing_to_ask( + assert ct.changed_files("ArcadeData/arcadedb-python", "7") == [ + "examples/new_name.py", + "examples/old_name.py", + "README.md", + ] + assert [cmd[:3] for cmd in calls] == [["gh", "api", "--paginate"]] * 2 + assert "repos/ArcadeData/arcadedb-python/issues/7/labels" in calls[0][3] + assert "repos/ArcadeData/arcadedb-python/pulls/7/files" in calls[1][3] + # a renamed file counts under both names: moving a file out of examples/ changes the examples too + assert "previous_filename" in calls[1][5] + + +def test_the_api_answers_are_unknown_when_gh_fails_is_missing_or_has_nothing_to_ask( monkeypatch, ): - monkeypatch.setattr(ct.subprocess, "run", lambda cmd, **kwargs: _Proc(1, "")) - assert ct.live_labels("ArcadeData/arcadedb-python", "7") is None - def missing(cmd, **kwargs): raise FileNotFoundError("gh") - monkeypatch.setattr(ct.subprocess, "run", missing) - assert ct.live_labels("ArcadeData/arcadedb-python", "7") is None - def never(cmd, **kwargs): raise AssertionError("gh was called without a repository or a number") - monkeypatch.setattr(ct.subprocess, "run", never) - assert ct.live_labels("", "7") is None - assert ct.live_labels("ArcadeData/arcadedb-python", "") is None + for read in (ct.live_labels, ct.changed_files): + monkeypatch.setattr(ct.subprocess, "run", lambda cmd, **kwargs: _Proc(1, "")) + assert read("ArcadeData/arcadedb-python", "7") is None + monkeypatch.setattr(ct.subprocess, "run", missing) + assert read("ArcadeData/arcadedb-python", "7") is None + monkeypatch.setattr(ct.subprocess, "run", never) + assert read("", "7") is None + assert read("ArcadeData/arcadedb-python", "") is None + + +def test_no_label_and_no_changed_file_are_answers_not_failures(monkeypatch): + monkeypatch.setattr(ct.subprocess, "run", lambda cmd, **kwargs: _Proc(0, "")) + assert ct.live_labels("ArcadeData/arcadedb-python", "7") == [] + assert ct.changed_files("ArcadeData/arcadedb-python", "7") == [] def _run(args, **env): @@ -157,11 +238,12 @@ def test_the_command_line_prints_the_event_on_one_line_and_the_reason_on_stderr( assert _run([]).returncode == 2 -def test_both_planners_know_the_event_of_a_full_tier_pull_request(): - # the name is written in three scripts; a rename in one of them would send a pull request to the wrong legs +def test_both_planners_know_the_events_this_script_prints(): + # the names are written in three scripts; a rename in one of them would send a pull request to the wrong legs for name in ("select_matrix.py", "select_native_matrix.py"): text = (ROOT / "scripts" / name).read_text(encoding="utf-8") - assert f'"{ct.FULL_EVENT}"' in text, name + for event in (ct.EXAMPLES_EVENT, ct.FULL_EVENT): + assert f'"{event}"' in text, (name, event) assert ct.FAST_EVENT == "pull_request" diff --git a/tests/test_select_matrix.py b/tests/test_select_matrix.py index fb29bbd3..42bc3c66 100644 --- a/tests/test_select_matrix.py +++ b/tests/test_select_matrix.py @@ -125,12 +125,49 @@ def test_jvm_builds_one_wheel_for_each_platform_whatever_the_python(event): def test_pull_request_examples_matrix(): - # the fast tier: the newest Python on linux/amd64, one build - pairs = _pairs(sm.select("examples", "pull_request")) + # the fast tier has no example leg and builds no wheel for one: the examples are the slowest jobs + assert sm.select("examples", "pull_request") == {"include": []} + assert sm.select_wheels("examples", "pull_request") == {"include": []} + # a pull request that changes the examples or their runner (scripts/ci_tier.py): the newest Python on linux/amd64, one build + pairs = _pairs(sm.select("examples", "pull_request_examples")) assert pairs == {("linux/amd64", "3.14")} - assert sm.select_wheels("examples", "pull_request") == { + assert sm.select_wheels("examples", "pull_request_examples") == { "include": [{"platform": "linux/amd64", "runs-on": "ubuntu-24.04"}] } + # its unit tests are those of every pull request + assert sm.select("jvm", "pull_request_examples") == sm.select("jvm", "pull_request") + + +def test_the_examples_workflow_skips_its_jobs_when_the_matrix_is_empty_and_the_summary_knows_it(): + # An empty matrix is an error for a job. The first job says whether the run has legs, the two jobs that take the matrix are + # skipped when it has none, and the summary is green for exactly that case (the bash is run in the pull request of issue 442). + text = WORKFLOWS["examples"].read_text(encoding="utf-8") + one_line = subprocess.run( # nosec B603 - fixed argument list, no untrusted input + [sys.executable, "-I", str(SCRIPT_PATH), "examples", "--event", "pull_request"], + capture_output=True, + text=True, + check=True, + ).stdout + assert one_line == '{"include":[]}\n' + assert ( + """if [ "$matrix" = '{"include":[]}' ]; then run=false; else run=true; fi""" + in text + ) + assert " run: ${{ steps.matrix.outputs.run }}\n" in text + build, rest = text.split("\n build:\n")[1].split("\n test-examples:\n") + test, summary = rest.split("\n test-examples-summary:\n") + for job in (build, test): + condition = job.split(" if: ", 1)[1].split("\n", 1)[0] + assert condition.endswith("&& needs.download-jars.outputs.run == 'true'") + assert "needs: [download-jars, build, test-examples]" in summary + assert "if: always() &&" in summary + for line in ( + "PLAN: ${{ needs.download-jars.result }}", + "RUN: ${{ needs.download-jars.outputs.run }}", + "BUILD: ${{ needs.build.result }}", + "LEGS: ${{ needs.test-examples.result }}", + ): + assert f" {line}\n" in summary, line @pytest.mark.parametrize("workflow", ["jvm", "examples"]) diff --git a/tests/test_select_native_matrix.py b/tests/test_select_native_matrix.py index fac3d57f..b0baea77 100644 --- a/tests/test_select_native_matrix.py +++ b/tests/test_select_native_matrix.py @@ -36,8 +36,17 @@ def test_the_workflow_asks_ci_tier_for_the_event_and_skips_an_empty_python_versi assert tier < plan.index('scripts/select_native_matrix.py "$event"') # a change to the script that picks the tier starts this workflow assert ' - "scripts/ci_tier.py"\n' in workflow.split("\njobs:\n", 1)[0] - # the fast tier has no pyver legs, and an empty matrix is an error: the job is skipped then, and no other job needs it - assert sel.select("pull_request")["pyver"] == [] + # the fast tier has no example leg, and an empty matrix is an error: the job is skipped then, and the summary expects that + assert sel.select("pull_request")["examples"] == [] + assert ( + "needs.plan.outputs.examples != '[]'" + in _job(workflow, "examples").split("steps:", 1)[0] + ) + summary = _job(workflow, "examples-summary") + assert "LEGS: ${{ needs.plan.outputs.examples }}" in summary + assert """if [ "$LEGS" = '[]' ]; then want=skipped; fi""" in summary + assert '[ "$RESULT" = "$want" ]' in summary + # the same guard on the pyver job, which no other job needs assert ( "needs.plan.outputs.pyver != '[]'" in _job(workflow, "pyver").split("steps:", 1)[0] @@ -97,8 +106,12 @@ def test_the_script_prints_github_output_lines(): "examples", ] assert json.loads(out[0].split("=", 1)[1])[0]["key"] == "linux-x86_64" - # the fast tier is one Python: no pyver legs, and the list is the text the workflow compares with '[]' - assert out[2] == "pyver=[]" + # the fast tier: the pyver subset on the oldest and the newest Python, and no example leg (the text the workflow compares with '[]') + assert [leg["python"] for leg in json.loads(out[2].split("=", 1)[1])] == [ + "3.11", + "3.14", + ] + assert out[3] == "examples=[]" full = subprocess.run( # nosec B603 - fixed argv, no shell [sys.executable, str(SCRIPT), "pull_request_full"], capture_output=True, @@ -121,8 +134,13 @@ def _pyver(event): def test_the_python_version_job_covers_what_the_full_parity_run_leaves_out(): - # a pull request (the fast tier) tests 3.12 only and has no Python-version legs - assert _pyver("pull_request") == [] + # a pull request (the fast tier) runs the parity suite on 3.12 and the subset on the ends of the supported range; 3.13, 3.15 and + # the free-threaded build wait for the full tier + for event in ("pull_request", "pull_request_examples"): + assert _pyver(event) == [ + ("3.11", False, True, True), + ("3.14", False, True, True), + ] # the selection itself still knows what one full Python leaves out: the other three Pythons, 3.15 (no jpype1 wheel yet) and the # free-threaded one assert [ @@ -230,8 +248,14 @@ def test_the_linux_legs_build_in_the_manylinux_container_of_the_tag_and_the_work def test_the_examples_job_runs_on_the_parity_pythons_3_12_and_3_14_of_every_platform_it_builds(): - pr = sel.select("pull_request")["examples"] + # a pull request has no example leg, unless it changes the examples or their runner (scripts/ci_tier.py): then one, on the parity Python + assert sel.select("pull_request")["examples"] == [] + pr = sel.select("pull_request_examples")["examples"] assert [(leg["key"], leg["python"]) for leg in pr] == [("linux-x86_64", "3.12")] + for key in ("build", "test", "pyver"): + assert ( + sel.select("pull_request_examples")[key] == sel.select("pull_request")[key] + ) for event in ( "pull_request_full", "push", From c420873b0c43b2b1739a3377d2d968636fbcbd26 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Mon, 23 Nov 2026 02:20:52 +0900 Subject: [PATCH 3/3] CI: a change to test-python-examples.yml starts the example legs of a pull request (#442) The workflow whose only work is to run the examples joins the paths that start the example legs (examples/, scripts/run_examples.sh, scripts/native_examples_skip.txt): a pull request that edits it would otherwise merge without one run of what it changed. test-native.yml and test-jvm.yml are left out on purpose. They change for many other reasons, and the example job of test-native.yml takes about 20 minutes; a change to it can ask for the full tier with the label ci:full. This pull request edits test-python-examples.yml, so from this commit on its own run has the example legs: the run of the commit before (f83a5db) is the measurement of a pull request without them, and this one shows the example jobs and their two summaries with legs. --- CONTRIBUTING.md | 2 +- docs/modules/ROOT/pages/development/ci.adoc | 2 +- scripts/ci_tier.py | 12 +++++++++--- tests/test_ci_tier.py | 3 +++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30911dca..6a354b4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -146,7 +146,7 @@ shellcheck and hadolint run as `docker_image` hooks (Docker pulls the images aut CI has two tiers, so that a pull request does not wait for the macOS and Windows runners that the organisation shares with ArcadeData/arcadedb. -- **A pull request runs the fast tier.** The static checks (pre-commit, Bandit, the dependency audits) run as before. The builds and tests run on Linux x86-64 only: the `arcadedb-jvm` wheel with the tests on Python 3.11 and 3.14 and, when a native path changed, the native image and wheel with the parity suite on Python 3.12 and a short subset on Python 3.11 and 3.14. The examples do not run, unless the pull request changes a file under `examples/` or their runner (`scripts/run_examples.sh`, `scripts/native_examples_skip.txt`). A pull request that changes only documentation runs no platform job. +- **A pull request runs the fast tier.** The static checks (pre-commit, Bandit, the dependency audits) run as before. The builds and tests run on Linux x86-64 only: the `arcadedb-jvm` wheel with the tests on Python 3.11 and 3.14 and, when a native path changed, the native image and wheel with the parity suite on Python 3.12 and a short subset on Python 3.11 and 3.14. The examples do not run, unless the pull request changes a file under `examples/` or what runs them (`scripts/run_examples.sh`, `scripts/native_examples_skip.txt`, `test-python-examples.yml`). A pull request that changes only documentation runs no platform job. - **`main` runs the full tier.** A push to `main` and the nightly run (03:00 to 04:00 UTC) test all four platforms (Linux x86-64, Linux arm64, macOS arm64 and Windows x86-64) and run the examples on each. A release tests every platform on every Python version. - **To run the full tier on a pull request**, add the label `ci:full`, then push a commit or choose "Re-run all jobs" on its test workflows. The pull request then runs what a push to `main` runs. Use it for a change that can behave differently on another platform: file paths, processes and signals, the wheel build, the native library, a workflow file. If you cannot add labels, ask for it in the pull request. Dependabot pull requests always run the full tier. diff --git a/docs/modules/ROOT/pages/development/ci.adoc b/docs/modules/ROOT/pages/development/ci.adoc index b580ee5f..78a0e414 100644 --- a/docs/modules/ROOT/pages/development/ci.adoc +++ b/docs/modules/ROOT/pages/development/ci.adoc @@ -26,7 +26,7 @@ The package supports four platforms and four Python versions (3.11 to 3.14). Tha The CI has two tiers. -* The fast tier runs on every pull request: the static checks, and the builds and tests on Linux x86-64 only. It waits for no macOS, Windows or arm64 runner. It runs no example job: the examples are the slowest jobs (they build the vectors of a dataset and run 30 scripts), so they run in the full tier. A pull request that changes a file under `examples/` (not `examples/README.md`), `scripts/run_examples.sh` or `scripts/native_examples_skip.txt` runs the example legs of Linux x86-64 too. +* The fast tier runs on every pull request: the static checks, and the builds and tests on Linux x86-64 only. It waits for no macOS, Windows or arm64 runner. It runs no example job: the examples are the slowest jobs (they build the vectors of a dataset and run 30 scripts), so they run in the full tier. A pull request that changes a file under `examples/` (not `examples/README.md`), `scripts/run_examples.sh`, `scripts/native_examples_skip.txt` or `test-python-examples.yml` runs the example legs of Linux x86-64 too. A change to the example job of `test-native.yml` does not: use the label `ci:full` for it. * The full tier runs on a push to `main`, on the nightly run, on a manual run and on a release. It tests all four platforms. A release tests every platform on every Python version. A pull request runs the legs of a push to `main` when it carries the label `ci:full`. Add the label, then push a commit or choose "Re-run all jobs" on the test workflows of the pull request: `scripts/ci_tier.py` reads the labels again at the start of each run, so no new commit is needed. Use the label for a change that can behave differently on another platform: file paths, processes and signals, the wheel build, the native library, a workflow file. To go back to the fast tier, remove the label and push a commit. A pull request that Dependabot opened always runs the full tier, because the hourly job merges it without a reader. When the labels cannot be read, the pull request runs the full tier. diff --git a/scripts/ci_tier.py b/scripts/ci_tier.py index 5fd7c576..16d2ac18 100644 --- a/scripts/ci_tier.py +++ b/scripts/ci_tier.py @@ -41,10 +41,16 @@ EXAMPLES_EVENT = "pull_request_examples" FULL_EVENT = "pull_request_full" -# A pull request that changes one of these runs the example legs: a file under examples/ (the scripts, their data loader), or the -# runner both example jobs call and the list of examples the native wheel leaves out. examples/README.md is prose only. +# A pull request that changes one of these runs the example legs: a file under examples/ (the scripts, their data loader), the +# runner both example jobs call, the list of examples the native wheel leaves out, or the workflow whose only work is to run the +# examples. examples/README.md is prose only. test-native.yml and test-jvm.yml are not here: they change for many other reasons, +# and a change to the example job of test-native.yml can ask for the full tier with the label. EXAMPLE_DIRS = ("examples/",) -EXAMPLE_FILES = ("scripts/run_examples.sh", "scripts/native_examples_skip.txt") +EXAMPLE_FILES = ( + "scripts/run_examples.sh", + "scripts/native_examples_skip.txt", + ".github/workflows/test-python-examples.yml", +) NOT_EXAMPLES = ("examples/README.md",) diff --git a/tests/test_ci_tier.py b/tests/test_ci_tier.py index 98752ff9..ea105a52 100644 --- a/tests/test_ci_tier.py +++ b/tests/test_ci_tier.py @@ -91,6 +91,7 @@ def test_only_the_exact_label_counts(): "examples/scripts/anything.sh", "scripts/run_examples.sh", "scripts/native_examples_skip.txt", + ".github/workflows/test-python-examples.yml", ], ) def test_a_pull_request_that_changes_the_examples_or_their_runner_runs_the_example_legs( @@ -112,6 +113,8 @@ def test_a_pull_request_that_changes_the_examples_or_their_runner_runs_the_examp "scripts/run_examples.sh.bak", "tests/test_examples.py", "examples", + ".github/workflows/test-native.yml", + ".github/workflows/test-jvm.yml", ], ) def test_other_paths_do_not_start_the_example_legs(path):