Skip to content

Commit b3c3d1d

Browse files
authored
Optimize github actions (#572)
1 parent e769b7c commit b3c3d1d

File tree

2 files changed

+32
-42
lines changed

2 files changed

+32
-42
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,28 @@ jobs:
2020

2121
- name: 🏗 Install uv
2222
uses: astral-sh/setup-uv@v2
23+
with:
24+
enable-cache: true
25+
cache-dependency-glob: "uv.lock"
26+
cache-local-path: ${{ env.UV_CACHE_DIR }}
2327

2428
- name: 🏗 Set up Python
2529
uses: actions/setup-python@v5
2630
with:
2731
python-version-file: ".python-version"
2832

29-
- name: 🏗 Restore uv cache
30-
uses: actions/cache@v4
31-
with:
32-
path: /tmp/.uv-cache
33-
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
34-
restore-keys: |
35-
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
36-
uv-${{ runner.os }}
37-
3833
- name: 🏗 Install the project
3934
run: uv sync --locked --dev
4035

4136
# Following steps cannot run by pre-commit.ci as repo = local
4237
- name: Run mypy
43-
run: uv run mypy deebot_client/
38+
run: uv run --frozen mypy deebot_client/
39+
4440
- name: Pylint review
45-
run: uv run pylint deebot_client/
41+
run: uv run --frozen pylint deebot_client/
42+
4643
- name: Verify no getLogger usages
4744
run: scripts/check_getLogger.sh
48-
- name: Minimize uv cache
49-
run: uv cache prune --ci
5045

5146
tests:
5247
runs-on: "ubuntu-latest"
@@ -56,29 +51,27 @@ jobs:
5651
python-version:
5752
- "3.12"
5853
steps:
59-
- uses: "actions/checkout@v4"
60-
- name: Set up uv
61-
# Install latest uv version using the installer
62-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
63-
- name: Set up Python ${{ matrix.python-version }}
64-
run: uv python install ${{ matrix.python-version }}
65-
- name: Restore uv cache
66-
uses: actions/cache@v4
54+
- name: ⤵️ Checkout repository
55+
uses: actions/checkout@v4
56+
57+
- name: 🏗 Install uv
58+
uses: astral-sh/setup-uv@v2
6759
with:
68-
path: /tmp/.uv-cache
69-
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ matrix.python-version }}
70-
restore-keys: |
71-
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ matrix.python-version }}
72-
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
73-
uv-${{ runner.os }}
74-
- name: Install the project
60+
enable-cache: true
61+
cache-dependency-glob: "uv.lock"
62+
cache-local-path: ${{ env.UV_CACHE_DIR }}
63+
64+
- name: 🏗 Set up Python ${{ matrix.python-version }}
65+
run: uv python install ${{ matrix.python-version }}
66+
67+
- name: 🏗 Install the project
7568
run: uv sync --locked --dev
69+
7670
- name: Run pytest
77-
run: uv run pytest tests --cov=./ --cov-report=xml
71+
run: uv run --frozen pytest tests --cov=./ --cov-report=xml
72+
7873
- name: Upload coverage to Codecov
7974
uses: codecov/codecov-action@v4
8075
with:
8176
token: ${{ secrets.CODECOV_TOKEN }}
8277
fail_ci_if_error: true
83-
- name: Minimize uv cache
84-
run: uv cache prune --ci

.github/workflows/python-publish.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
release:
1313
types: [published]
1414

15+
env:
16+
UV_CACHE_DIR: /tmp/.uv-cache
17+
1518
jobs:
1619
deploy:
1720
runs-on: ubuntu-latest
@@ -23,23 +26,17 @@ jobs:
2326
uses: actions/checkout@v4
2427

2528
- name: 🏗 Install uv
26-
# Install latest uv version using the installer
27-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
29+
uses: astral-sh/setup-uv@v2
30+
with:
31+
enable-cache: true
32+
cache-dependency-glob: "uv.lock"
33+
cache-local-path: ${{ env.UV_CACHE_DIR }}
2834

2935
- name: 🏗 Set up Python
3036
uses: actions/setup-python@v5
3137
with:
3238
python-version-file: ".python-version"
3339

34-
- name: 🏗 Restore uv cache
35-
uses: actions/cache@v4
36-
with:
37-
path: /tmp/.uv-cache
38-
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
39-
restore-keys: |
40-
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
41-
uv-${{ runner.os }}
42-
4340
- name: 🏗 Install the project
4441
run: uv sync --dev --locked
4542

0 commit comments

Comments
 (0)