-
Notifications
You must be signed in to change notification settings - Fork 25
130 lines (114 loc) · 4.55 KB
/
build-ultraplot.yml
File metadata and controls
130 lines (114 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build and Test
on:
workflow_call:
inputs:
python-version:
required: true
type: string
matplotlib-version:
required: true
type: string
env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
jobs:
build-ultraplot:
name: Test Python ${{ inputs.python-version }} with MPL ${{ inputs.matplotlib-version }}
runs-on: ubuntu-latest
timeout-minutes: 60
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v2.0.7
with:
environment-file: ./environment.yml
init-shell: bash
create-args: >-
--verbose
python=${{ inputs.python-version }}
matplotlib=${{ inputs.matplotlib-version }}
cache-environment: true
cache-downloads: false
- name: Build Ultraplot
run: |
pip install --no-build-isolation --no-deps .
- name: Test Ultraplot
run: |
pytest -n auto ignore=ultraplot/tests/test_demos.py --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml ultraplot
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Ultraplot/ultraplot
compare-baseline:
name: Compare baseline Python ${{ inputs.python-version }} with MPL ${{ inputs.matplotlib-version }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v6
- uses: mamba-org/setup-micromamba@v2.0.7
with:
environment-file: ./environment.yml
init-shell: bash
create-args: >-
--verbose
python=${{ inputs.python-version }}
matplotlib=${{ inputs.matplotlib-version }}
cache-environment: true
cache-downloads: false
# Cache Baseline Figures (Restore step)
- name: Cache Baseline Figures
id: cache-baseline
uses: actions/cache@v4
with:
path: ./ultraplot/tests/baseline # The directory to cache
# Key is based on OS, Python/Matplotlib versions, and the PR number
key: ${{ runner.os }}-baseline-pr-${{ github.event.pull_request.number }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}
restore-keys: |
${{ runner.os }}-baseline-pr-${{ github.event.pull_request.number }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}-
# Conditional Baseline Generation (Only runs on cache miss)
- name: Generate baseline from main
# Skip this step if the cache was found (cache-hit is true)
if: steps.cache-baseline.outputs.cache-hit != 'true'
run: |
mkdir -p ultraplot/tests/baseline
# Checkout the base branch (e.g., 'main') to generate the official baseline
git fetch origin ${{ github.event.pull_request.base.sha }}
git checkout ${{ github.event.pull_request.base.sha }}
# Install the Ultraplot version from the base branch's code
pip install --no-build-isolation --no-deps .
# Generate the baseline images and hash library
python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')"
pytest -x -W ignore \
--mpl-generate-path=./ultraplot/tests/baseline/ \
--mpl-default-style="./ultraplot.yml"\
ultraplot/tests
# Return to the PR branch for the rest of the job
git checkout ${{ github.sha }}
# Image Comparison (Uses cached or newly generated baseline)
- name: Image Comparison Ultraplot
run: |
# Re-install the Ultraplot version from the current PR branch
pip install --no-build-isolation --no-deps .
mkdir -p results
python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')"
pytest -x -W ignore \
--mpl \
--mpl-baseline-path=./ultraplot/tests/baseline \
--mpl-results-path=./results/ \
--mpl-generate-summary=html \
--mpl-default-style="./ultraplot.yml" \
ultraplot/tests
# Return the html output of the comparison even if failed
- name: Upload comparison failures
if: always()
uses: actions/upload-artifact@v6
with:
name: failed-comparisons-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}-${{ github.sha }}
path: results/*