Enable caching for github actions (#43)
This commit is contained in:
parent
84f1fa8cbd
commit
533fffa6db
40
.github/workflows/unit-test.yaml
vendored
40
.github/workflows/unit-test.yaml
vendored
|
@ -8,25 +8,53 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
timeout-minutes: 20
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
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 }}
|
name: unit testing with python ${{ matrix.python-version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Clone the repo
|
- name: Clone the repo
|
||||||
uses: actions/checkout@v3
|
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
|
uses: actions/setup-python@v4
|
||||||
|
id: setup_python
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- name: Display Python version
|
- name: Get package version
|
||||||
run: python -c "import sys; print(sys.version)"
|
id: get-package-version
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
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
|
python -m pip install --upgrade pip
|
||||||
pip install -e .[dev]
|
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
|
- name: Test with pytest
|
||||||
run: |
|
run: |
|
||||||
pytest
|
${{ matrix.ACTIVATE_ENV }}
|
||||||
|
python -m pytest
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -61,7 +61,7 @@ setuptools.setup(
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
entry_points={"console_scripts": ["kh=kotaemon.cli:main"]},
|
entry_points={"console_scripts": ["kh=kotaemon.cli:main"]},
|
||||||
python_requires=">=3",
|
python_requires=">=3.8",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: MIT License",
|
||||||
|
|
|
@ -11,14 +11,17 @@ input_file_excel = Path(__file__).parent / "resources" / "dummy.xlsx"
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fullocr_output():
|
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)
|
fullocr = json.load(f)
|
||||||
return fullocr
|
return fullocr
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mathpix_output():
|
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()
|
content = f.read()
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user