ci: Speed up tests.yml by caching dependencies (#6417)

* Speed up tests.yml by caching dependencies

* Trigger for testing

* Use restore only action to speedup restoring

* Use bash shell to get pip cache dir

* Set shell for caching step

* Cache correct path

* Remove trigger
This commit is contained in:
Silvano Cerza 2023-12-20 16:21:48 +01:00 committed by GitHub
parent a64cf25148
commit 5546c8144e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,6 @@ on:
- main
# release branches have the form v1.9.x
- "v[0-9].*[0-9].x"
- "!haystack/core/**/*.py"
pull_request:
types:
- opened
@ -79,9 +78,32 @@ jobs:
- "branch:${{ github.ref_name }}"
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
install-dependencies:
name: Install and cache ${{ matrix.os }} dependencies
needs: black
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Haystack and the dependencies needed for tests
run: pip install -r test/test_requirements.txt
- uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: pip-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
unit-tests:
name: Unit / ${{ matrix.os }}
needs: black
needs: install-dependencies
strategy:
fail-fast: false
matrix:
@ -97,8 +119,11 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Haystack and the dependencies needed for tests
run: pip install -r test/test_requirements.txt
- name: Restore Python dependencies
uses: actions/cache/restore@v3
with:
path: ${{ env.pythonLocation }}
key: pip-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Run
run: pytest -m "not integration" test
@ -155,8 +180,11 @@ jobs:
sudo apt update
sudo apt install ffmpeg # for local Whisper tests
- name: Install Haystack and the dependencies needed for tests
run: pip install -r test/test_requirements.txt
- name: Restore Python dependencies
uses: actions/cache/restore@v3
with:
path: ${{ env.pythonLocation }}
key: pip-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Run
run: pytest --maxfail=5 -m "integration" test
@ -211,8 +239,11 @@ jobs:
brew install docker
colima start
- name: Install Haystack and the dependencies needed for tests
run: pip install -r test/test_requirements.txt
- name: Restore Python dependencies
uses: actions/cache/restore@v3
with:
path: ${{ env.pythonLocation }}
key: pip-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Run Tika
run: docker run -d -p 9998:9998 apache/tika:2.9.0.0
@ -262,8 +293,11 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Haystack and the dependencies needed for tests
run: pip install -r test/test_requirements.txt
- name: Restore Python dependencies
uses: actions/cache/restore@v3
with:
path: ${{ env.pythonLocation }}
key: pip-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Run
run: pytest --maxfail=5 -m "integration" test -k 'not tika'