Skip to content

Commit ad9ecb3

Browse files
ci: switch to registry cache, split apt and pip caches
1 parent 055fcb8 commit ad9ecb3

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

.github/workflows/docker.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
permissions:
4444
packages: write
4545
contents: read
46+
actions: read
4647
steps:
4748
- name: Check out the repo
4849
uses: actions/checkout@v4
@@ -88,5 +89,7 @@ jobs:
8889
tags: ${{ steps.meta.outputs.tags }}
8990
labels: ${{ steps.meta.outputs.labels }}
9091
platforms: linux/amd64,linux/arm64/v8
91-
cache-from: type=gha
92-
cache-to: type=gha,mode=max
92+
cache-from: |
93+
type=registry,ref=ghcr.io/${{ github.repository_owner }}/build-cache:${{ steps.image_name.outputs.IMAGE }}-buildcache
94+
cache-to: |
95+
type=registry,ref=ghcr.io/${{ github.repository_owner }}/build-cache:${{ steps.image_name.outputs.IMAGE }}-buildcache,mode=max

.github/workflows/packages.txt

Whitespace-only changes.

.github/workflows/pytest.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,37 @@ jobs:
2727
with:
2828
python-version: '3.11.x'
2929

30+
- name: Cache apt packages
31+
uses: actions/cache@v4
32+
env:
33+
cache-name: cache-apt
34+
with:
35+
path: /var/lib/apt/lists
36+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('.github/workflows/packages.txt') }}
37+
restore-keys: |
38+
${{ runner.os }}-${{ env.cache-name }}-
39+
3040
- name: Cache pip packages
3141
uses: actions/cache@v4
42+
env:
43+
cache-name: cache-pip
3244
with:
3345
path: ~/.cache/pip
34-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
46+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/requirements.txt') }}
3547
restore-keys: |
36-
${{ runner.os }}-pip-
48+
${{ runner.os }}-${{ env.cache-name }}-
49+
50+
- name: Install system dependencies
51+
run: |
52+
if [ -s .github/workflows/packages.txt ]; then
53+
sudo apt-get update
54+
sudo xargs -a .github/workflows/packages.txt apt-get install -y
55+
fi
3756
38-
- name: Install dependencies
57+
- name: Install Python dependencies
3958
run: |
4059
python -m pip install --upgrade pip pytest
4160
pip install -r requirements.txt
4261
4362
- name: Run pytest
44-
run: pytest tests/test_main.py
63+
run: pytest -s

0 commit comments

Comments
 (0)