|
43 | 43 |
|
44 | 44 | - name: Test Ultraplot |
45 | 45 | run: | |
46 | | - pytest --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml ultraplot |
| 46 | + pytest -n auto --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml ultraplot |
47 | 47 |
|
48 | 48 | - name: Upload coverage reports to Codecov |
49 | 49 | uses: codecov/codecov-action@v5 |
@@ -71,29 +71,55 @@ jobs: |
71 | 71 | cache-environment: true |
72 | 72 | cache-downloads: false |
73 | 73 |
|
| 74 | + # Cache Baseline Figures (Restore step) |
| 75 | + - name: Cache Baseline Figures |
| 76 | + id: cache-baseline |
| 77 | + uses: actions/cache@v4 |
| 78 | + with: |
| 79 | + path: ./ultraplot/tests/baseline # The directory to cache |
| 80 | + # Key is based on OS, Python/Matplotlib versions, and the PR number |
| 81 | + key: ${{ runner.os }}-baseline-pr-${{ github.event.pull_request.number }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }} |
| 82 | + restore-keys: | |
| 83 | + ${{ runner.os }}-baseline-pr-${{ github.event.pull_request.number }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}- |
| 84 | +
|
| 85 | + # Conditional Baseline Generation (Only runs on cache miss) |
74 | 86 | - name: Generate baseline from main |
| 87 | + # Skip this step if the cache was found (cache-hit is true) |
| 88 | + if: steps.cache-baseline.outputs.cache-hit != 'true' |
75 | 89 | run: | |
76 | | - mkdir -p baseline |
| 90 | + mkdir -p ultraplot/tests/baseline |
| 91 | + # Checkout the base branch (e.g., 'main') to generate the official baseline |
77 | 92 | git fetch origin ${{ github.event.pull_request.base.sha }} |
78 | 93 | git checkout ${{ github.event.pull_request.base.sha }} |
| 94 | +
|
| 95 | + # Install the Ultraplot version from the base branch's code |
| 96 | + pip install --no-build-isolation --no-deps . |
| 97 | +
|
| 98 | + # Generate the baseline images and hash library |
79 | 99 | python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')" |
80 | | - pytest -W ignore \ |
81 | | - --mpl-generate-path=./baseline/ \ |
| 100 | + pytest -x -n auto -W ignore \ |
| 101 | + --mpl-generate-path=./ultraplot/tests/baseline/ \ |
82 | 102 | --mpl-default-style="./ultraplot.yml"\ |
83 | 103 | ultraplot/tests |
84 | | - git checkout ${{ github.sha }} # Return to PR branch |
85 | 104 |
|
| 105 | + # Return to the PR branch for the rest of the job |
| 106 | + git checkout ${{ github.sha }} |
| 107 | +
|
| 108 | + # Image Comparison (Uses cached or newly generated baseline) |
86 | 109 | - name: Image Comparison Ultraplot |
87 | 110 | run: | |
| 111 | + # Re-install the Ultraplot version from the current PR branch |
| 112 | + pip install --no-build-isolation --no-deps . |
| 113 | +
|
88 | 114 | mkdir -p results |
89 | 115 | python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')" |
90 | | - pytest -W ignore \ |
91 | | - --mpl \ |
92 | | - --mpl-baseline-path=./baseline/ \ |
93 | | - --mpl-results-path=./results/ \ |
94 | | - --mpl-generate-summary=html \ |
95 | | - --mpl-default-style="./ultraplot.yml" \ |
96 | | - ultraplot/tests |
| 116 | + pytest -x -n auto -W ignore -n auto\ |
| 117 | + --mpl \ |
| 118 | + --mpl-baseline-path=./ultraplot/tests/baseline \ |
| 119 | + --mpl-results-path=./results/ \ |
| 120 | + --mpl-generate-summary=html \ |
| 121 | + --mpl-default-style="./ultraplot.yml" \ |
| 122 | + ultraplot/tests |
97 | 123 |
|
98 | 124 | # Return the html output of the comparison even if failed |
99 | 125 | - name: Upload comparison failures |
|
0 commit comments