Skip to content

Commit 08f799f

Browse files
authored
Fix stats chart dates and release docs deployment (#349)
1 parent a605327 commit 08f799f

3 files changed

Lines changed: 49 additions & 11 deletions

File tree

.github/workflows/build-wheels.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,13 @@ jobs:
428428
needs: publish-to-pypi
429429
runs-on: ubuntu-latest
430430
name: Deploy versioned docs
431-
if: github.event_name == 'release' && github.event.action == 'published' && !github.event.release.prerelease
431+
if: >-
432+
(github.event_name == 'release' &&
433+
github.event.action == 'published' &&
434+
!github.event.release.prerelease) ||
435+
(github.event_name == 'workflow_dispatch' &&
436+
inputs.publish_to_pypi &&
437+
startsWith(github.ref, 'refs/tags/v'))
432438
permissions:
433439
contents: write
434440
concurrency:

docs/assets/js/blender-extension-stats.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
}).format(new Date(value + "T00:00:00Z"));
5151
}
5252

53+
function dateValue(value) {
54+
return Date.parse(value + "T00:00:00Z");
55+
}
56+
5357
function formatRating(value) {
5458
if (value === null || value === undefined || value === "") return "n/a";
5559
return Number(value).toFixed(1) + " / 5";
@@ -97,9 +101,9 @@
97101
const exactIndex = daily.findIndex((row) => row.date === date);
98102
if (exactIndex !== -1) return exactIndex;
99103

100-
const target = Date.parse(date + "T00:00:00Z");
104+
const target = dateValue(date);
101105
const laterIndex = daily.findIndex(
102-
(row) => Date.parse(row.date + "T00:00:00Z") >= target,
106+
(row) => dateValue(row.date) >= target,
103107
);
104108
return laterIndex === -1 ? daily.length - 1 : laterIndex;
105109
}
@@ -168,15 +172,15 @@
168172
const reviewMarkers = payload.reviews.map((review) => {
169173
const index = indexForDate(daily, review.date);
170174
return {
171-
x: index,
175+
x: dateValue(review.date),
172176
y: daily[index].downloads,
173177
review,
174178
};
175179
});
176180
const releaseMarkers = releaseEvents.map((event) => {
177181
const index = indexForDate(daily, event.date);
178182
return {
179-
x: index,
183+
x: dateValue(event.date),
180184
y: daily[index].downloads,
181185
event,
182186
};
@@ -188,8 +192,8 @@
188192
datasets: [
189193
{
190194
label: "Downloads",
191-
data: daily.map((row, index) => ({
192-
x: index,
195+
data: daily.map((row) => ({
196+
x: dateValue(row.date),
193197
y: row.downloads,
194198
row,
195199
})),
@@ -258,14 +262,14 @@
258262
scales: {
259263
x: {
260264
type: "linear",
261-
min: 0,
262-
max: daily.length - 1,
265+
min: dateValue(first.date),
266+
max: dateValue(latest.date),
263267
ticks: {
264268
color: colors.muted,
265269
maxTicksLimit: 7,
266270
callback: (value) => {
267-
const row = daily[Math.round(value)];
268-
return row ? formatDate(row.date).replace(", ", " ") : "";
271+
const date = new Date(Number(value)).toISOString().slice(0, 10);
272+
return formatDate(date).replace(", ", " ");
269273
},
270274
},
271275
grid: { color: colors.grid },

tests/docs_deployment_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Regression checks for documentation charting and release deployment."""
2+
3+
from pathlib import Path
4+
5+
ROOT = Path(__file__).resolve().parent.parent
6+
7+
8+
def test_download_chart_uses_elapsed_dates_for_x_coordinates() -> None:
9+
"""Missing tracker days must occupy their real width on the x-axis."""
10+
script = (ROOT / "docs/assets/js/blender-extension-stats.js").read_text(
11+
encoding="utf-8"
12+
)
13+
14+
assert "x: dateValue(row.date)" in script
15+
assert "x: dateValue(review.date)" in script
16+
assert "x: dateValue(event.date)" in script
17+
assert "min: dateValue(first.date)" in script
18+
assert "max: dateValue(latest.date)" in script
19+
20+
21+
def test_dispatched_release_build_deploys_versioned_docs() -> None:
22+
"""The release orchestrator dispatch must update Mike's latest alias."""
23+
workflow = (ROOT / ".github/workflows/build-wheels.yml").read_text(encoding="utf-8")
24+
deploy_job = workflow.split(" deploy-versioned-docs:", maxsplit=1)[1]
25+
26+
assert "github.event_name == 'workflow_dispatch'" in deploy_job
27+
assert "inputs.publish_to_pypi" in deploy_job
28+
assert "startsWith(github.ref, 'refs/tags/v')" in deploy_job

0 commit comments

Comments
 (0)