diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b54cd43..22e2abd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,11 @@ on: [pull_request] jobs: test: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + fail-fast: false + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set up Python 3.7 @@ -13,7 +17,7 @@ jobs: python-version: 3.7 - name: Install Python dependencies run: | - pip install -e .[all] + pip install -e ".[all]" pip install git+https://github.com/huggingface/transformers - name: Run Tests - run: make test + run: python -m pytest -n 1 --dist=loadfile -s -v ./tests/ diff --git a/kit/src/routes/endpoints/toc.ts b/kit/src/routes/endpoints/toc.ts index 97a429d5..c4889d01 100644 --- a/kit/src/routes/endpoints/toc.ts +++ b/kit/src/routes/endpoints/toc.ts @@ -1,6 +1,7 @@ import path from "path"; import fs from "fs"; import yaml from "js-yaml"; +import { fileURLToPath } from "url"; export interface RawChapter { title: string; @@ -23,7 +24,7 @@ const flattener = (_flatChapters: RawChapter[], chapter: RawChapter): RawChapter }; export async function get() { - const filepath = path.join(import.meta.url.replace('file://', ''), '../..', '_toctree.yml'); + const filepath = path.join(fileURLToPath(import.meta.url), '../..', '_toctree.yml'); const content = (await fs.promises.readFile(filepath)).toString("utf-8"); const chapters: RawChapter[] = yaml.load(content) as RawChapter[]; diff --git a/src/doc_builder/build_doc.py b/src/doc_builder/build_doc.py index 2f05b1c1..866892d4 100644 --- a/src/doc_builder/build_doc.py +++ b/src/doc_builder/build_doc.py @@ -463,7 +463,7 @@ def check_toc_integrity(doc_folder, output_dir): output_dir (`str` or `os.PathLike`): The folder where the doc is built. """ output_dir = Path(output_dir) - doc_files = [str(f.relative_to(output_dir).with_suffix("").as_posix()) for f in output_dir.glob("**/*.mdx")] + doc_files = [str(f.relative_to(output_dir).with_suffix("")) for f in output_dir.glob("**/*.mdx")] toc_file = Path(doc_folder) / "_toctree.yml" with open(toc_file, "r", encoding="utf-8") as f: @@ -489,6 +489,8 @@ def check_toc_integrity(doc_folder, output_dir): # Toc has some nested sections in the API doc for instance, so we recurse. toc.extend([sec for sec in part["sections"] if "sections" in sec]) + # normalize paths to current OS + toc_sections = [str(Path(path)) for path in toc_sections] files_not_in_toc = [f for f in doc_files if f not in toc_sections] doc_config = get_doc_config() disable_toc_check = getattr(doc_config, "disable_toc_check", False) diff --git a/src/doc_builder/commands/preview.py b/src/doc_builder/commands/preview.py index 232e3fd3..3b6667fb 100644 --- a/src/doc_builder/commands/preview.py +++ b/src/doc_builder/commands/preview.py @@ -16,6 +16,7 @@ import argparse import os +import platform import shutil import subprocess import tempfile @@ -135,6 +136,7 @@ def start_sveltekit_dev(tmp_dir, env, args): check=True, encoding="utf-8", cwd=working_dir, + shell=platform.system() == "Windows", ) # start sveltekit in dev mode @@ -144,6 +146,7 @@ def start_sveltekit_dev(tmp_dir, env, args): encoding="utf-8", cwd=working_dir, env=env, + shell=platform.system() == "Windows", )