Skip to content

feat(layout): charts face each other: mirrored, on a fixed maximum, labels hidden (#2487 part 4a) #10460

feat(layout): charts face each other: mirrored, on a fixed maximum, labels hidden (#2487 part 4a)

feat(layout): charts face each other: mirrored, on a fixed maximum, labels hidden (#2487 part 4a) #10460

Workflow file for this run

name: CI
# macOS and Windows are slow: pushes to main test on every platform, pull requests on Linux, plus
# macOS when labelled `ci:macos`, Windows (x64 and ARM64) when labelled `ci:windows`, and both for
# `ci:full`. A manual run tests on every platform, or on Linux alone when asked (a fork checking a
# branch before its pull request runs the pull request's own checks).
# Adding the label runs that platform straight away (ci-label.yml); later pushes include it here.
#
# The merge queue tests a pull request merged with main and the pull requests ahead of it with this
# workflow's jobs as an unlabelled pull request runs them (Linux, the changed packages), so two that
# pass apart but break together are stopped before main. `Tests pass` is the only check the ruleset
# requires. The other pull request workflows (python.yml, mobile.yml, docs, Docker, fuzz) don't run
# in the queue: Python and Docker are tested on the push to main, and the phone apps through this
# workflow's `ios` and `android` jobs there.
#
# Queued commits can carry a fork's code, and the queue runs them in this repository: the token is
# read-only (`permissions` below, `flaky` asks for issues on pushes only), and no job here may use a
# secret.
#
# A pull request's tests cover the packages it changes and those that depend on them (`select`);
# pushes to main, labelled runs, manual runs on every platform and changes to Cargo.lock,
# rust-toolchain, .github/ or .config/ test the whole workspace. `Tests pass` is the check to
# require: it fails when any job here failed, whichever ran.
on:
push:
branches: [main]
pull_request:
merge_group:
workflow_dispatch:
inputs:
platforms:
description: Platforms to test on
type: choice
options: [all, linux]
default: all
# A pull request's runs are grouped by its number, not by github.ref: a run GitHub creates after
# the pull request has merged gets the base branch's ref (refs/heads/main), and would otherwise
# join main's group and cancel main's run. Never cancel in-progress `main` runs so macOS and
# Windows finish and populate their caches instead of repeatedly timing out mid-run.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number && format('pr-{0}', github.event.pull_request.number) || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
lint:
name: Lint (pre-commit)
runs-on: ubuntu-latest
env:
CARGO_PROFILE_DEV_DEBUG: 0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.12"
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
wasm:
name: Web app (wasm32)
runs-on: ubuntu-latest
env:
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_DEV_OPT_LEVEL: 0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build for the browser
run: cargo build --locked --target wasm32-unknown-unknown -p rustgis-web
# The iOS app (apps/rustgis-mobile, #1902): linted for devices and built for the Simulator,
# where macOS is tested (pushes to main, a manual run on every platform, a pull request labelled
# `ci:macos` or `ci:full`). Unlike the tests, it runs from the next push after the label is
# added, not straight away (ci-label.yml runs test-rust.yml only).
ios:
name: iOS app
if: >-
github.event_name == 'push'
|| (github.event_name == 'workflow_dispatch' && inputs.platforms != 'linux')
|| contains(github.event.pull_request.labels.*.name, 'ci:macos')
|| contains(github.event.pull_request.labels.*.name, 'ci:full')
runs-on: macos-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
with:
targets: aarch64-apple-ios, aarch64-apple-ios-sim
components: clippy
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Lint the app for devices
run: cargo clippy --locked --target aarch64-apple-ios -p rustgis-mobile --all-targets
- name: Build the app for the Simulator
run: apps/rustgis-mobile/build-ios.sh --debug simulator
# The Android app (apps/rustgis-mobile, #1902): the Rust library and the activity's Java half
# built into an APK for the emulator's x86_64, with the runner's Android SDK, NDK and JDK. As
# slow as a test run, it runs where the iOS job does (pushes to main, a manual run on every
# platform, a pull request labelled `ci:full`), from the next push after the label is added.
android:
name: Android app
if: >-
github.event_name == 'push'
|| (github.event_name == 'workflow_dispatch' && inputs.platforms != 'linux')
|| contains(github.event.pull_request.labels.*.name, 'ci:full')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
with:
targets: x86_64-linux-android
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: taiki-e/install-action@ab49d3c64680143e184118bed66a46419fc15519 # v2
with:
tool: cargo-ndk
# The platform the manifest targets (build-apk.sh refuses an older one).
- name: The Android platform
run: yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "platforms;android-36" >/dev/null
- name: Build the APK
run: apps/rustgis-mobile/build-apk.sh --debug x86_64
# Every dependency's licence must be one the project accepts (deny.toml). The third-party
# notices the packages ship (`cargo xtask notices`) only warn here when out of date, since
# Dependabot can't regenerate them; the release build requires them current. On PRs and the merge
# queue, skip the slow `cargo about` checks when no dependency, licence or notice file changed.
licenses:
name: Licences
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
filter: blob:none
persist-credentials: false
- id: scope
name: Check if licence files changed
env:
EVENT: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if [ "$EVENT" != pull_request ] && [ "$EVENT" != merge_group ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
base="origin/${BASE_REF:-main}"
if ! fork_point="$(git merge-base HEAD "$base" 2>/dev/null)"; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! changed="$(git diff --name-only "$fork_point" HEAD 2>/dev/null)"; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if grep -qE '^(Cargo\.lock|(.*/)?Cargo\.toml|deny\.toml|about\.toml|xtask/src/(main|notices)\.rs|(.*/)?THIRD-PARTY-LICENSES\.txt|\.github/scripts/(check-cargo-sources|review-deferrals|ratchet-limits|test_[^/]+)\.py|\.github/workflows/ci\.yml|crates/map/src/color/(scientific|matplotlib)\.rs|crates/tiles/src/(symbols|style)\.rs|crates/data/src/(raster/crs|esripbf)\.rs)$|^(third-party/|\.cargo/)' <<<"$changed"; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "No dependency, licence or notice files changed; skipping."
echo "run=false" >> "$GITHUB_OUTPUT"
fi
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
if: steps.scope.outputs.run == 'true'
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
if: steps.scope.outputs.run == 'true'
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: taiki-e/install-action@ab49d3c64680143e184118bed66a46419fc15519 # v2
if: steps.scope.outputs.run == 'true'
with:
tool: cargo-deny,cargo-about@0.9.2
- name: Cargo source replacements
if: steps.scope.outputs.run == 'true'
run: |
python3 -m unittest discover -s .github/scripts -p 'test_*.py'
python3 .github/scripts/check-cargo-sources.py
- name: Dependency licences and sources
if: steps.scope.outputs.run == 'true'
run: cargo deny --locked check licenses sources
- name: Third-party notices
if: steps.scope.outputs.run == 'true'
# Exit code 2 is stale notices (a warning); anything else (cargo-about failing, a licence
# it can't work out) fails the job.
run: |
status=0
cargo xtask notices --check || status=$?
if [ "$status" -eq 2 ]; then
echo "::warning::THIRD-PARTY-LICENSES.txt is out of date: run cargo xtask notices and commit it before the next release."
elif [ "$status" -ne 0 ]; then
exit "$status"
fi
schema:
name: Project schema
runs-on: ubuntu-latest
env:
CARGO_PROFILE_DEV_DEBUG: 0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
filter: blob:none
persist-credentials: false
- id: scope
name: Check if schema-related files changed
env:
EVENT: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if [ "$EVENT" != pull_request ] && [ "$EVENT" != merge_group ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
base="origin/${BASE_REF:-main}"
if ! fork_point="$(git merge-base HEAD "$base" 2>/dev/null)"; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! changed="$(git diff --name-only "$fork_point" HEAD 2>/dev/null)"; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if grep -qE '^(crates/(geom|data|map|analysis|tiles|render|plugins|geolibre|engine)/|schema/|Cargo\.(toml|lock)$|rust-toolchain|xtask/src/main\.rs$|\.github/workflows/ci\.yml$)' <<<"$changed"; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "No schema-related files changed; skipping."
echo "run=false" >> "$GITHUB_OUTPUT"
fi
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
if: steps.scope.outputs.run == 'true'
with:
# `cargo xtask schema --check` lints the code behind the `schema` feature first.
components: clippy
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
if: steps.scope.outputs.run == 'true'
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
# The committed schema matches the types the project is saved from, and the fixture projects
# open. `--locked` on the outer run too, so a stale Cargo.lock is refused before xtask starts.
- name: Check the project file's schema
if: steps.scope.outputs.run == 'true'
run: cargo run --locked -q -p xtask -- schema --check
# Every fixture, not only those the pull request changes (as pre-commit does), so a change
# to the schema alone is checked against them too.
- name: Validate the fixture projects against the schema
if: steps.scope.outputs.run == 'true'
run: pipx run check-jsonschema==0.39.0 --schemafile schema/project.schema.json --default-filetype json schema/fixtures/*.rgis
# Direct uses of a layer's rows outside rustgis-data may not rise above xtask/row-uses.txt
# (`cargo xtask rows`, #2431). The compiler counts them as deprecation warnings, so this job
# leaves warnings as warnings; the lint job denies them in the normal build.
rows:
name: Direct row uses
runs-on: ubuntu-latest
env:
RUSTFLAGS: ""
CARGO_PROFILE_DEV_DEBUG: 0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Count direct row uses
run: cargo run --locked -q -p xtask -- rows
# A review point left for the release quality pass must be a quality point
# (.github/scripts/review-deferrals.py). The merge queue's run sees replies posted after the last
# push. It runs the checkout with a read-only token and no secrets, like every job here.
deferrals:
name: Review deferrals
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: No defect left for the release quality pass
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
MERGE_GROUP_REF: ${{ github.event.merge_group.head_ref }}
run: python3 .github/scripts/review-deferrals.py
# xtask/row-uses.txt and xtask/memory-limits.txt only go down (AGENTS.md): the check against the
# base commit (.github/scripts/ratchet-limits.py) fails when one rose or went.
# The merge queue's run sees a maintainer's approval posted after the last push. Read-only token,
# no secrets, like every job here.
ratchets:
name: Limits only go down
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: No limit raised
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
env:
GH_TOKEN: ${{ github.token }}
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
MERGE_GROUP_REF: ${{ github.event.merge_group.head_ref }}
run: python3 .github/scripts/ratchet-limits.py
# The packages whose tests this run needs, for `test` (.github/scripts/test-selection.sh). Only
# tests are narrowed: lint, the wasm build, licences and the schema check run whole every time.
select:
name: Tests to run
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.select.outputs.packages }}
steps:
# The history, without file contents, to find where the branch left the base.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
filter: blob:none
persist-credentials: false
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
- id: select
env:
EVENT: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
PLATFORMS: ${{ inputs.platforms }}
run: .github/scripts/test-selection.sh >> "$GITHUB_OUTPUT"
# Timer waits and ignored tests carry their reasons. Runs on the whole workspace every time
# (reuses the xtask already built above, #2289).
- name: Test hygiene
run: cargo run --locked -q -p xtask -- test-hygiene
# Every image and font file has a row in ATTRIBUTION.md.
- name: Attribution rows
run: cargo run --locked -q -p xtask -- attribution
plan:
name: Platforms
runs-on: ubuntu-latest
outputs:
os: ${{ steps.os.outputs.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
sparse-checkout: .github/scripts
- id: os
env:
EVENT: ${{ github.event_name }}
ACTION: ${{ github.event.action }}
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
PLATFORMS: ${{ inputs.platforms }}
run: echo "os=$(.github/scripts/platforms.sh)" >> "$GITHUB_OUTPUT"
test:
needs: [plan, select]
uses: ./.github/workflows/test-rust.yml
with:
os: ${{ needs.plan.outputs.os }}
packages: ${{ needs.select.outputs.packages }}
# The release build runs nightly; `ci:full` asks for it before merging.
release-build: ${{ contains(github.event.pull_request.labels.*.name, 'ci:full') }}
# A test that failed and then passed on a retry (.config/nextest.toml) on a push to main gets an
# issue, or a comment on its open one: a retry hides a flaky test from the run, not from us. A
# pull request only lists them in the test jobs' summaries. Like nightly.yml's report, it writes
# issues and runs none of the repository's code.
flaky:
name: Flaky tests
needs: test
if: ${{ !cancelled() && github.event_name == 'push' && github.repository == 'opengeos/RustGIS' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
# One file a runner, flaky-<runner>.txt, each line a test ("<binary> <test>").
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
pattern: flaky-*
merge-multiple: true
path: flaky
- env:
GH_TOKEN: ${{ github.token }}
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
shopt -s nullglob
files=(flaky/flaky-*.txt)
[ "${#files[@]}" -gt 0 ] || exit 0
sort -u "${files[@]}" | while read -r test; do
title="Flaky test: $test"
runners="$(grep -lxF -- "$test" flaky/flaky-*.txt | sed 's|^flaky/flaky-||; s|\.txt$||' | paste -sd, - | sed 's/,/, /g')"
body="$test failed and passed on a retry on $runners, for $GITHUB_SHA: $RUN"
open="$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues?state=open&per_page=100" \
| jq -sr --arg t "$title" '[.[][] | select(.pull_request | not) | select(.title == $t)][0].number // ""')"
if [ -n "$open" ]; then
gh issue comment "$open" -R "$GITHUB_REPOSITORY" --body "Flaky again: $body"
else
gh issue create -R "$GITHUB_REPOSITORY" --title "$title" \
--body "$body. A retry hides a flaky test from the run, so it is listed here. Fix the test; if it waits on a timer, wait for completion instead (\`cargo xtask test-hygiene\`)."
fi
done
# The check to require before merging, so the list of required checks needn't follow the jobs
# above (a runner that only a label adds, a job added later). It fails if any of them failed or
# was cancelled. A skipped job passes only when it was meant to skip: `ios` and `android` skip
# unless their conditions below hold (the same as on the jobs), and every other job always runs.
tests_pass:
name: Tests pass
needs: [lint, wasm, ios, android, licenses, schema, rows, deferrals, ratchets, plan, select, test]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- env:
NEEDS: ${{ toJSON(needs) }}
RUNS_IOS: >-
${{ github.event_name == 'push'
|| (github.event_name == 'workflow_dispatch' && inputs.platforms != 'linux')
|| contains(github.event.pull_request.labels.*.name, 'ci:macos')
|| contains(github.event.pull_request.labels.*.name, 'ci:full') }}
RUNS_ANDROID: >-
${{ github.event_name == 'push'
|| (github.event_name == 'workflow_dispatch' && inputs.platforms != 'linux')
|| contains(github.event.pull_request.labels.*.name, 'ci:full') }}
run: |
set -euo pipefail
meant_to_run() {
case "$1" in ios) echo "$RUNS_IOS" ;; android) echo "$RUNS_ANDROID" ;; *) echo true ;; esac
}
failed=0
for job in $(jq -r 'keys[]' <<<"$NEEDS"); do
result="$(jq -r --arg job "$job" '.[$job].result' <<<"$NEEDS")"
if [ "$result" = success ] || { [ "$result" = skipped ] && [ "$(meant_to_run "$job")" = false ]; }; then
echo "$job: $result"
else
echo "::error::$job: $result"
failed=1
fi
done
exit "$failed"