2024-04-13 17:56:55 +00:00
|
|
|
---
|
|
|
|
name: Setup Environment
|
2024-09-27 09:27:53 +00:00
|
|
|
description: Install uv, configure the system python, and the package dependencies
|
2024-04-13 17:56:55 +00:00
|
|
|
|
|
|
|
inputs:
|
2024-09-06 14:48:43 +00:00
|
|
|
uv-install-options:
|
2024-04-13 17:56:55 +00:00
|
|
|
default: ""
|
2024-09-06 14:48:43 +00:00
|
|
|
uv-version:
|
2024-09-27 09:27:53 +00:00
|
|
|
default: 0.4.16
|
2024-04-13 17:56:55 +00:00
|
|
|
python-version:
|
|
|
|
required: true
|
|
|
|
cache-pre-commit:
|
|
|
|
default: false
|
2024-09-06 14:48:43 +00:00
|
|
|
cache-version:
|
|
|
|
default: "v0.1"
|
2024-04-13 17:56:55 +00:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: composite
|
|
|
|
steps:
|
2024-09-27 09:27:53 +00:00
|
|
|
- name: Install uv
|
|
|
|
uses: astral-sh/setup-uv@v3
|
|
|
|
with:
|
|
|
|
enable-cache: true
|
|
|
|
|
|
|
|
- name: "Setup python"
|
|
|
|
uses: "actions/setup-python@v5"
|
2024-04-13 17:56:55 +00:00
|
|
|
id: setup-python
|
|
|
|
with:
|
|
|
|
python-version: "${{ inputs.python-version }}"
|
2024-08-06 19:03:35 +00:00
|
|
|
allow-prereleases: true
|
2024-04-13 17:56:55 +00:00
|
|
|
|
2024-09-27 09:27:53 +00:00
|
|
|
- name: "Install project"
|
2024-04-13 17:56:55 +00:00
|
|
|
shell: bash
|
|
|
|
run: |
|
2024-09-27 09:27:53 +00:00
|
|
|
uv sync ${{ inputs.uv-install-options }}
|
2024-04-13 17:56:55 +00:00
|
|
|
|
|
|
|
- name: Read pre-commit version
|
|
|
|
if: inputs.cache-pre-commit == 'true'
|
|
|
|
id: pre-commit-version
|
|
|
|
shell: bash
|
|
|
|
run: >-
|
2024-09-27 09:27:53 +00:00
|
|
|
echo "pre-commit-version=$(uv run pre-commit -V | awk '{print $2}')" >> $GITHUB_OUTPUT
|
2024-04-13 17:56:55 +00:00
|
|
|
|
|
|
|
- uses: actions/cache@v4
|
|
|
|
if: inputs.cache-pre-commit == 'true'
|
|
|
|
name: Pre-commit cache
|
|
|
|
with:
|
|
|
|
path: ~/.cache/pre-commit/
|
2024-09-06 14:48:43 +00:00
|
|
|
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') }}
|