From de4b0103188a54eb9bcaf12fcdb76187220994cf Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Sun, 25 Jan 2026 18:09:47 +1000 Subject: [PATCH] Update GitHub workflows --- .github/workflows/build-ultraplot.yml | 113 ++++++++++++++++++++++---- .github/workflows/main.yml | 4 +- .github/workflows/test-map.yml | 2 +- 3 files changed, 100 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-ultraplot.yml b/.github/workflows/build-ultraplot.yml index 9899017df..6d6b51deb 100644 --- a/.github/workflows/build-ultraplot.yml +++ b/.github/workflows/build-ultraplot.yml @@ -54,17 +54,34 @@ jobs: - name: Test Ultraplot run: | + status=0 + filter_nodeids() { + local filtered="" + for nodeid in ${TEST_NODEIDS}; do + local path="${nodeid%%::*}" + if [ -f "$path" ]; then + filtered="${filtered} ${nodeid}" + fi + done + echo "${filtered}" + } if [ "${TEST_MODE}" = "selected" ] && [ -n "${TEST_NODEIDS}" ]; then - pytest -n auto --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml ${TEST_NODEIDS} + FILTERED_NODEIDS="$(filter_nodeids)" + if [ -z "${FILTERED_NODEIDS}" ]; then + echo "No valid nodeids found; running full suite." + pytest -q --tb=short --disable-warnings -n 0 ultraplot || status=$? + else + pytest -q --tb=short --disable-warnings -n 0 ${FILTERED_NODEIDS} || status=$? + if [ "$status" -eq 4 ] || [ "$status" -eq 5 ]; then + echo "No tests collected from selected nodeids; running full suite." + status=0 + pytest -q --tb=short --disable-warnings -n 0 ultraplot || status=$? + fi + fi else - pytest -n auto --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml ultraplot + pytest -q --tb=short --disable-warnings -n 0 ultraplot || status=$? fi - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - slug: Ultraplot/ultraplot + exit "$status" compare-baseline: name: Compare baseline Python ${{ inputs.python-version }} with MPL ${{ inputs.matplotlib-version }} @@ -98,9 +115,9 @@ jobs: with: path: ./ultraplot/tests/baseline # The directory to cache # Key is based on OS, Python/Matplotlib versions, and the base commit SHA - key: ${{ runner.os }}-baseline-base-${{ github.event.pull_request.base.sha }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }} + key: ${{ runner.os }}-baseline-base-v2-${{ github.event.pull_request.base.sha }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }} restore-keys: | - ${{ runner.os }}-baseline-base-${{ github.event.pull_request.base.sha }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}- + ${{ runner.os }}-baseline-base-v2-${{ github.event.pull_request.base.sha }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}- # Conditional Baseline Generation (Only runs on cache miss) - name: Generate baseline from main @@ -120,12 +137,41 @@ jobs: # Generate the baseline images and hash library python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')" if [ "${TEST_MODE}" = "selected" ] && [ -n "${TEST_NODEIDS}" ]; then - pytest -W ignore \ + status=0 + filter_nodeids() { + local filtered="" + for nodeid in ${TEST_NODEIDS}; do + local path="${nodeid%%::*}" + if [ -f "$path" ]; then + filtered="${filtered} ${nodeid}" + fi + done + echo "${filtered}" + } + FILTERED_NODEIDS="$(filter_nodeids)" + if [ -z "${FILTERED_NODEIDS}" ]; then + echo "No valid nodeids found; running full suite." + pytest -q --tb=short --disable-warnings -W ignore \ + --mpl-generate-path=./ultraplot/tests/baseline/ \ + --mpl-default-style="./ultraplot.yml" \ + ultraplot/tests || status=$? + else + pytest -q --tb=short --disable-warnings -W ignore \ --mpl-generate-path=./ultraplot/tests/baseline/ \ --mpl-default-style="./ultraplot.yml" \ - ${TEST_NODEIDS} + ${FILTERED_NODEIDS} || status=$? + if [ "$status" -eq 4 ] || [ "$status" -eq 5 ]; then + echo "No tests collected from selected nodeids on base; running full suite." + status=0 + pytest -q --tb=short --disable-warnings -W ignore \ + --mpl-generate-path=./ultraplot/tests/baseline/ \ + --mpl-default-style="./ultraplot.yml" \ + ultraplot/tests || status=$? + fi + fi + exit "$status" else - pytest -W ignore \ + pytest -q --tb=short --disable-warnings -W ignore \ --mpl-generate-path=./ultraplot/tests/baseline/ \ --mpl-default-style="./ultraplot.yml" \ ultraplot/tests @@ -145,15 +191,50 @@ jobs: mkdir -p results python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')" if [ "${TEST_MODE}" = "selected" ] && [ -n "${TEST_NODEIDS}" ]; then - pytest -W ignore \ + status=0 + filter_nodeids() { + local filtered="" + for nodeid in ${TEST_NODEIDS}; do + local path="${nodeid%%::*}" + if [ -f "$path" ]; then + filtered="${filtered} ${nodeid}" + fi + done + echo "${filtered}" + } + FILTERED_NODEIDS="$(filter_nodeids)" + if [ -z "${FILTERED_NODEIDS}" ]; then + echo "No valid nodeids found; running full suite." + pytest -q --tb=short --disable-warnings -W ignore \ + --mpl \ + --mpl-baseline-path=./ultraplot/tests/baseline \ + --mpl-results-path=./results/ \ + --mpl-generate-summary=html \ + --mpl-default-style="./ultraplot.yml" \ + ultraplot/tests || status=$? + else + pytest -q --tb=short --disable-warnings -W ignore \ --mpl \ --mpl-baseline-path=./ultraplot/tests/baseline \ --mpl-results-path=./results/ \ --mpl-generate-summary=html \ --mpl-default-style="./ultraplot.yml" \ - ${TEST_NODEIDS} + ${FILTERED_NODEIDS} || status=$? + if [ "$status" -eq 4 ] || [ "$status" -eq 5 ]; then + echo "No tests collected from selected nodeids; running full suite." + status=0 + pytest -q --tb=short --disable-warnings -W ignore \ + --mpl \ + --mpl-baseline-path=./ultraplot/tests/baseline \ + --mpl-results-path=./results/ \ + --mpl-generate-summary=html \ + --mpl-default-style="./ultraplot.yml" \ + ultraplot/tests || status=$? + fi + fi + exit "$status" else - pytest -W ignore \ + pytest -q --tb=short --disable-warnings -W ignore \ --mpl \ --mpl-baseline-path=./ultraplot/tests/baseline \ --mpl-results-path=./results/ \ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c035214ed..c383287cb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,9 +40,9 @@ jobs: uses: actions/cache/restore@v4 with: path: .ci/test-map.json - key: test-map-${{ github.event.pull_request.base.sha }} + key: test-map-v2-${{ github.event.pull_request.base.sha }} restore-keys: | - test-map- + test-map-v2- - name: Select impacted tests id: select diff --git a/.github/workflows/test-map.yml b/.github/workflows/test-map.yml index f5c23e1e5..a1e9ff107 100644 --- a/.github/workflows/test-map.yml +++ b/.github/workflows/test-map.yml @@ -36,7 +36,7 @@ jobs: - name: Generate test coverage map run: | mkdir -p .ci - pytest -n auto --cov=ultraplot --cov-branch --cov-context=test --cov-report= ultraplot + pytest -q --tb=short --disable-warnings -n 0 -p pytest_cov --cov=ultraplot --cov-branch --cov-context=test --cov-report= ultraplot python tools/ci/build_test_map.py --coverage-file .coverage --output .ci/test-map.json --root . - name: Cache test map