Skip to content

Commit a80de66

Browse files
authored
Migrate workflows to setup-uv github action (#22)
1 parent b25d6f4 commit a80de66

File tree

5 files changed

+31
-57
lines changed

5 files changed

+31
-57
lines changed

.github/actions/setup/action.yml

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,39 @@
11
---
22
name: Setup Environment
3-
description: Install requested pipx dependencies, configure the system python, and install uv and the package dependencies
3+
description: Install uv, configure the system python, and the package dependencies
44

55
inputs:
66
uv-install-options:
77
default: ""
88
uv-version:
9-
default: 0.4.5
9+
default: 0.4.16
1010
python-version:
1111
required: true
1212
cache-pre-commit:
1313
default: false
14+
cache-version:
15+
default: "v0.1"
1416

1517
runs:
1618
using: composite
1719
steps:
18-
- uses: "actions/setup-python@v5"
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v3
22+
with:
23+
enable-cache: true
24+
version: "${{ inputs.uv-version }}"
25+
26+
- name: "Setup python"
27+
uses: "actions/setup-python@v5"
1928
id: setup-python
2029
with:
2130
python-version: "${{ inputs.python-version }}"
2231
allow-prereleases: true
2332

24-
- name: Setup pipx environment Variables
25-
id: pipx-env-setup
26-
# pipx default home and bin dir are not writable by the cache action
27-
# so override them here and add the bin dir to PATH for later steps.
28-
# This also ensures the pipx cache only contains uv
29-
run: |
30-
SEP="${{ !startsWith(runner.os, 'windows') && '/' || '\\' }}"
31-
PIPX_CACHE="${{ github.workspace }}${SEP}pipx_cache"
32-
echo "pipx-cache-path=${PIPX_CACHE}" >> $GITHUB_OUTPUT
33-
echo "pipx-version=$(pipx --version)" >> $GITHUB_OUTPUT
34-
echo "PIPX_HOME=${PIPX_CACHE}${SEP}home" >> $GITHUB_ENV
35-
echo "PIPX_BIN_DIR=${PIPX_CACHE}${SEP}bin" >> $GITHUB_ENV
36-
echo "PIPX_MAN_DIR=${PIPX_CACHE}${SEP}man" >> $GITHUB_ENV
37-
echo "${PIPX_CACHE}${SEP}bin" >> $GITHUB_PATH
38-
shell: bash
39-
40-
- name: Pipx cache
41-
id: pipx-cache
42-
uses: actions/cache@v4
43-
with:
44-
path: ${{ steps.pipx-env-setup.outputs.pipx-cache-path }}
45-
key: cache-${{ inputs.cache-version }}-${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipx-${{ steps.pipx-env-setup.outputs.pipx-version }}-uv-${{ inputs.uv-version }}
46-
47-
- name: Install uv
48-
if: steps.pipx-cache.outputs.cache-hit != 'true'
49-
id: install-uv
50-
shell: bash
51-
run: |-
52-
pipx install uv==${{ inputs.uv-version }} --python "${{ steps.setup-python.outputs.python-path }}"
53-
54-
- name: Read uv cache location
55-
id: uv-cache-location
56-
shell: bash
57-
run: |-
58-
echo "uv-venv-location=$(uv cache dir)" >> $GITHUB_OUTPUT
59-
60-
- uses: actions/cache@v4
61-
name: uv cache
62-
with:
63-
path: |
64-
${{ steps.uv-cache-location.outputs.uv-venv-location }}
65-
key: cache-${{ inputs.cache-version }}-${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('uv.lock') }}-options-${{ inputs.uv-install-options }}
66-
67-
- name: "uv install"
33+
- name: "Install project"
6834
shell: bash
6935
run: |
70-
uv sync --python "${{ steps.setup-python.outputs.python-path }}" ${{ inputs.uv-install-options }}
36+
uv sync ${{ inputs.uv-install-options }}
7137
7238
- name: Read pre-commit version
7339
if: inputs.cache-pre-commit == 'true'
@@ -81,4 +47,4 @@ runs:
8147
name: Pre-commit cache
8248
with:
8349
path: ~/.cache/pre-commit/
84-
key: cache-${{ inputs.cache-version }}-${{ runner.os }}-pre-commit-${{ steps.pre-commit-version.outputs.pre-commit-version }}-python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
50+
key: cache-${{ inputs.cache-version }}-${{ runner.os }}-${{ runner.arch }}-pre-commit-${{ steps.pre-commit-version.outputs.pre-commit-version }}-python-${{ inputs.python-version }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: ["main"]
88

99
env:
10-
UV_VERSION: 0.4.5
10+
UV_VERSION: 0.4.17
1111
PACKAGE_NAME: firebase_messaging
1212

1313
jobs:

.github/workflows/publish.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ on:
66
tags:
77
- '*'
88
env:
9-
UV_VERSION: 0.4.5
9+
UV_VERSION: 0.4.17
1010
PYPI_PROJECT: firebase-messaging
11+
PYTHON_VERSION: 3.12
1112

1213
# GITHUB_TOKEN must have write access
1314
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/signing-the-distribution-packages
@@ -18,16 +19,22 @@ jobs:
1819
runs-on: ubuntu-latest
1920

2021
steps:
21-
- uses: actions/checkout@v4
22+
- name: Checkout source files
23+
uses: actions/checkout@v4
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
27+
with:
28+
version: ${{ env.UV_VERSION }}
29+
2230
- name: Set up Python
2331
uses: actions/setup-python@v5
2432
with:
25-
python-version: "3.x"
26-
- name: Install uv
27-
run: |-
28-
pipx install uv==${{ env.UV_VERSION }} --python "${{ steps.setup-python.outputs.python-path }}"
33+
python-version: ${{ env.PYTHON_VERSION }}
34+
2935
- name: Build with uv
3036
run: uv build
37+
3138
- name: Store the distribution packages
3239
uses: actions/upload-artifact@v4
3340
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ repos:
22

33
- repo: https://github.com/astral-sh/uv-pre-commit
44
# uv version.
5-
rev: 0.4.5
5+
rev: 0.4.17
66
hooks:
77
# Update the uv lockfile
88
- id: uv-lock

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ dev-dependencies = [
7474
testpaths = "tests"
7575
norecursedirs = ".git"
7676
asyncio_mode = "auto"
77+
asyncio_default_fixture_loop_scope = "function"
7778
addopts = "--disable-socket --allow-unix-socket"
7879

7980
[tool.coverage.run]

0 commit comments

Comments
 (0)