Skip to content

Commit 5b80489

Browse files
committed
cache testing resources on version and dep changes
Signed-off-by: Jeffrey Martin <[email protected]>
1 parent 55da36b commit 5b80489

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

.github/workflows/test_linux.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,36 @@ jobs:
3535
uses: actions/setup-python@v4
3636
with:
3737
python-version: ${{ matrix.python-version }}
38+
39+
- name: Restore test cache artifacts
40+
id: cache-artifacts-restore
41+
uses: actions/cache/restore@v4
42+
with:
43+
path: |
44+
~/.cache/garak/data
45+
~/.cache/huggingface
46+
key: ${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
47+
3848
- name: Install dependencies
3949
run: |
4050
python -m pip install --upgrade pip
4151
pip install -r requirements.txt
4252
python -m pip cache purge
53+
4354
- name: Test with pytest
4455
run: |
4556
python -m pytest tests/
57+
58+
- name: Prepare resources for cache
59+
run: |
60+
rm -rf ~/.cache/huggingface/hub/*facebook*
61+
rm -rf ~/.cache/huggingface/hub/*Helsinki*
62+
63+
- name: Save test cache
64+
if: steps.cache-artifacts-restore.outputs.cache-hit != 'true'
65+
uses: actions/cache@v4
66+
with:
67+
path: |
68+
~/.cache/garak/data
69+
~/.cache/huggingface
70+
key: ${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}

.github/workflows/test_macos.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ jobs:
3939
with:
4040
python-version: ${{ matrix.python-version }}
4141

42+
- name: Restore test cache artifacts
43+
id: cache-artifacts-restore
44+
uses: actions/cache/restore@v4
45+
with:
46+
path: |
47+
~/.cache/garak/data
48+
~/.cache/huggingface
49+
key: ${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
50+
4251
- name: Install dependencies
4352
run: |
4453
brew install libmagic
@@ -51,3 +60,17 @@ jobs:
5160
run: |
5261
cd garak
5362
python -m pytest tests/
63+
64+
- name: Prepare resources for cache
65+
run: |
66+
rm -rf ~/.cache/huggingface/hub/*facebook*
67+
rm -rf ~/.cache/huggingface/hub/*Helsinki*
68+
69+
- name: Save test cache
70+
if: steps.cache-artifacts-restore.outputs.cache-hit != 'true'
71+
uses: actions/cache@v4
72+
with:
73+
path: |
74+
~/.cache/garak/data
75+
~/.cache/huggingface
76+
key: ${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}

.github/workflows/test_windows.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ jobs:
3939
with:
4040
python-version: ${{ matrix.python-version }}
4141

42+
- name: Restore test cache artifacts
43+
id: cache-artifacts-restore
44+
uses: actions/cache/restore@v4
45+
with:
46+
path: |
47+
~/.cache/garak/data
48+
~/.cache/huggingface
49+
key: ${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
50+
4251
- name: Install dependencies
4352
run: |
4453
python -m pip install --upgrade pip
@@ -50,3 +59,17 @@ jobs:
5059
run: |
5160
cd garak
5261
python -m pytest tests/
62+
63+
- name: Prepare resources for cache
64+
run: |
65+
rm -rf ~/.cache/huggingface/hub/*facebook*
66+
rm -rf ~/.cache/huggingface/hub/*Helsinki*
67+
68+
- name: Save test cache
69+
if: steps.cache-artifacts-restore.outputs.cache-hit != 'true'
70+
uses: actions/cache@v4
71+
with:
72+
path: |
73+
~/.cache/garak/data
74+
~/.cache/huggingface
75+
key: ${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}

0 commit comments

Comments
 (0)