diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 5bd66c9..de133cb 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -8,25 +8,53 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + timeout-minutes: 20 strategy: matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] + include: + - os: ubuntu-latest + ACTIVATE_ENV: ". env/bin/activate" + GITHUB_OUTPUT: "$GITHUB_OUTPUT" + # - os: windows-latest + # ACTIVATE_ENV: env/Scripts/activate.ps1 + # GITHUB_OUTPUT: "$env:GITHUB_OUTPUT" + name: unit testing with python ${{ matrix.python-version }} steps: - name: Clone the repo uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} on ${{ runner.os }} uses: actions/setup-python@v4 + id: setup_python with: python-version: ${{ matrix.python-version }} architecture: x64 - - name: Display Python version - run: python -c "import sys; print(sys.version)" - - name: Install dependencies + - name: Get package version + id: get-package-version run: | + echo "version=$(python setup.py --version)" | tee -a ${{ matrix.GITHUB_OUTPUT }} + - name: Try to restore env from ${{ runner.os }}-py${{ matrix.python-version }}-v${{ steps.get-package-version.outputs.version }} + id: restore-env + uses: actions/cache/restore@v3 + with: + path: env + key: ${{ runner.os }}-py${{ matrix.python-version }}-v${{ steps.get-package-version.outputs.version }} + - name: Create new env if no cache hit + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + python -m venv env + ${{ matrix.ACTIVATE_ENV }} python -m pip install --upgrade pip pip install -e .[dev] + - name: Cache new env for key ${{ steps.restore-env.outputs.cache-primary-key }} + if: steps.restore-env.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: env + key: ${{ steps.restore-env.outputs.cache-primary-key }} - name: Test with pytest run: | - pytest + ${{ matrix.ACTIVATE_ENV }} + python -m pytest diff --git a/setup.py b/setup.py index ceaa11f..d011d2e 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ setuptools.setup( ], }, entry_points={"console_scripts": ["kh=kotaemon.cli:main"]}, - python_requires=">=3", + python_requires=">=3.8", classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", diff --git a/tests/test_table_reader.py b/tests/test_table_reader.py index 682642d..05be17f 100644 --- a/tests/test_table_reader.py +++ b/tests/test_table_reader.py @@ -11,14 +11,17 @@ input_file_excel = Path(__file__).parent / "resources" / "dummy.xlsx" @pytest.fixture def fullocr_output(): - with open(Path(__file__).parent / "resources" / "fullocr_sample_output.json") as f: + with open( + Path(__file__).parent / "resources" / "fullocr_sample_output.json", + encoding="utf-8", + ) as f: fullocr = json.load(f) return fullocr @pytest.fixture def mathpix_output(): - with open(Path(__file__).parent / "resources" / "policy.md") as f: + with open(Path(__file__).parent / "resources" / "policy.md", encoding="utf-8") as f: content = f.read() return content