|
1 | 1 | ---
|
2 | 2 | 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 |
4 | 4 |
|
5 | 5 | inputs:
|
6 | 6 | uv-install-options:
|
7 | 7 | default: ""
|
8 | 8 | uv-version:
|
9 |
| - default: 0.4.5 |
| 9 | + default: 0.4.16 |
10 | 10 | python-version:
|
11 | 11 | required: true
|
12 | 12 | cache-pre-commit:
|
13 | 13 | default: false
|
| 14 | + cache-version: |
| 15 | + default: "v0.1" |
14 | 16 |
|
15 | 17 | runs:
|
16 | 18 | using: composite
|
17 | 19 | 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" |
19 | 28 | id: setup-python
|
20 | 29 | with:
|
21 | 30 | python-version: "${{ inputs.python-version }}"
|
22 | 31 | allow-prereleases: true
|
23 | 32 |
|
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" |
68 | 34 | shell: bash
|
69 | 35 | run: |
|
70 |
| - uv sync --python "${{ steps.setup-python.outputs.python-path }}" ${{ inputs.uv-install-options }} |
| 36 | + uv sync ${{ inputs.uv-install-options }} |
71 | 37 |
|
72 | 38 | - name: Read pre-commit version
|
73 | 39 | if: inputs.cache-pre-commit == 'true'
|
|
81 | 47 | name: Pre-commit cache
|
82 | 48 | with:
|
83 | 49 | 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') }} |
0 commit comments