diff --git a/.github/scripts/test_music_data.py b/.github/scripts/test_music_data.py index 8dae72a..1214c22 100644 --- a/.github/scripts/test_music_data.py +++ b/.github/scripts/test_music_data.py @@ -4,8 +4,9 @@ python -m pytest -q -p no:cacheprovider .github/scripts/test_music_data.py The JSON Schema gate uses docs/schema/music-data.schema.json (or $MUSIC_DATA_SCHEMA) when the checkout has it; the -page smoke test runs when $MUSIC_DATA_PAGE names ournotes-player's examples/songs (and Node.js is installed). Real -files, when named: $MUSIC_DATA_SAMPLE (a file with the play scenario fields: the content gates pass; one made before +page smoke test runs when $MUSIC_DATA_PAGE names ournotes-player's examples/songs; a configured page requires its +modules and Node.js. Real files, when named: $MUSIC_DATA_SAMPLE (a file with the play scenario fields: the content +gates pass; one made before the ranges' luckPoints and the Gekisou skill aptitude, the deck and aptitude gates stop it on those alone) and $MUSIC_DATA_OLD_SAMPLE (one without the play scenario fields: the scenario gate stops it). """ @@ -43,7 +44,28 @@ def schema_path(): def page_path(): p = os.environ.get("MUSIC_DATA_PAGE") - return Path(p) if p and Path(p, "ranking.js").is_file() and shutil.which("node") else None + if not p: + return None + page = Path(p) + assert shutil.which("node"), "MUSIC_DATA_PAGE requires Node.js" + for name in ("catalog.js", "ranking.js"): + assert (page / name).is_file(), f"MUSIC_DATA_PAGE has no {name}" + assert "aptitudeFigures" in (page / "ranking.js").read_text(encoding="utf-8"), \ + "MUSIC_DATA_PAGE ranking.js has no aptitudeFigures API" + return page + + +@pytest.mark.parametrize("missing", ["node", "catalog.js", "ranking.js", "aptitudeFigures"]) +def test_configured_page_requires_its_modules_and_runtime(tmp_path, monkeypatch, missing): + monkeypatch.setenv("MUSIC_DATA_PAGE", str(tmp_path)) + monkeypatch.setattr(shutil, "which", lambda name: None if missing == "node" else "node") + (tmp_path / "catalog.js").write_text("export const catalog = {};", encoding="utf-8") + (tmp_path / "ranking.js").write_text("" if missing == "aptitudeFigures" else "export const aptitudeFigures = {};", + encoding="utf-8") + if missing.endswith(".js"): + (tmp_path / missing).unlink() + with pytest.raises(AssertionError, match="MUSIC_DATA_PAGE"): + page_path() # ---------------------------------------------------------------- a synthetic file @@ -293,8 +315,8 @@ def test_page_smoke(tmp_path): def test_page_aptitude_check_reconstruction(tmp_path): page = page_path() - if page is None or "aptitudeFigures" not in (page / "ranking.js").read_text(encoding="utf-8"): - pytest.skip("page does not yet expose the aptitude API") + if page is None: + pytest.skip("set MUSIC_DATA_PAGE to ournotes-player's examples/songs") doc = sample() # Stochastic check values are not reconstructible from means; changing them must not trigger reconstruction. var(doc, 0, 0, 1)["check"].update(exact=99999999, predicted=99999999) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c45889a..e8d0c1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,10 +42,20 @@ jobs: run: python -m nnnotes --help - name: Test run: python -m pytest - - name: Story and catalog workflow tests - run: python -m pytest -q .github/scripts/test_catalog_workflow.py .github/scripts/test_jp_workflow.py .github/scripts/test_story_workflow.py - - name: Recognition gallery workflow tests - run: python -m pytest -q .github/scripts/test_recognition.py + - uses: actions/setup-node@v7 + if: matrix.python-version == '3.13' + with: + node-version: "22" + - name: Chart data page + if: matrix.python-version == '3.13' + env: + PLAYER_REPOSITORY: ${{ vars.MUSIC_DATA_PLAYER_REPOSITORY || 'empty-sekai/ournotes-player' }} + PLAYER_REF: ${{ vars.MUSIC_DATA_PLAYER_REF }} + run: .github/scripts/songs_page.sh "$RUNNER_TEMP/music-data-player" + - name: Workflow tests + env: + MUSIC_DATA_PAGE: ${{ matrix.python-version == '3.13' && format('{0}/music-data-player/examples/songs', runner.temp) || '' }} + run: python -m pytest -q .github/scripts goldens: # The golden records of the stages (tests/golden/*.json) were made with these library versions; with the same