Skip to content

Commit 871cbdd

Browse files
committed
CI: Add condition to decide cache type
1 parent e0be9af commit 871cbdd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/workflows/pytests.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,24 @@ jobs:
1717
with:
1818
fetch-depth: 2
1919

20+
- name: Activate caching based on lockfile
21+
id: lockfile
22+
run: |
23+
if [ -f poetry.lock ]; then
24+
echo "cache_type=poetry" >> $GITHUB_OUTPUT
25+
elif [ -f requirements.txt ]; then
26+
echo "cache_type=pip" >> $GITHUB_OUTPUT
27+
else
28+
# no lockfile present: create empty requirements.txt and use pip caching
29+
touch requirements.txt
30+
echo "cache_type=pip" >> $GITHUB_OUTPUT
31+
fi
32+
2033
- name: Set up Python
2134
uses: actions/setup-python@v5
2235
with:
2336
python-version: '3.13'
37+
cache: ${{ steps.lockfile.outputs.cache_type }}
2438

2539
- name: Install Poetry
2640
uses: snok/install-poetry@v1

0 commit comments

Comments
 (0)