From 11632c161f003b51c0b7450499d1a30448fd9d9b Mon Sep 17 00:00:00 2001 From: Matt Griswold Date: Sat, 5 Oct 2024 00:28:18 -0500 Subject: [PATCH] Add uv (#4) * add uv support * feat: add uv action * use uv caching, drop cruft --------- Co-authored-by: Samsul --- .github/dependabot.yml | 8 ++++++++ README.md | 21 +++++++++++++++++++++ uv/action.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 uv/action.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..df4d15b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every week + interval: "weekly" diff --git a/README.md b/README.md index e2883cb..2df85d8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,27 @@ [![Tests](https://github.com/20c/workflows/workflows/ci/badge.svg)](https://github.com/20c/workflows/actions/workflows/ci.yaml) +## uv + +Action to install and cache uv and the virtualenv it installs to. + +```yaml +inputs: + python-version: + required: false + default: 3.x + type: string +outputs: + venv-path: + description: "virtualenv path" + value: ${{ steps.get-venv-path.outputs.venv-path }} +``` + +To use: +```yaml + - name: Install virtualenv from uv + uses: 20c/workflows/uv@v1 +``` ## poetry diff --git a/uv/action.yaml b/uv/action.yaml new file mode 100644 index 0000000..21ceea1 --- /dev/null +++ b/uv/action.yaml @@ -0,0 +1,40 @@ +name: "Install UV and project" +description: "Install and cache UV" +author: "@grizz" + +inputs: + python-version: + description: "Python version" + required: false + default: 3.x + +outputs: + uv-path: + description: "Path to uv environment" + value: ${{ steps.get-venv-path.outputs.venv-path }} + +runs: + using: "composite" + steps: + - name: Set up python ${{ inputs.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + + - name: Get Python version + shell: bash + run: | + echo "PYTHON_VERSION=$(python --version | awk '{ print $NF }')" >> $GITHUB_ENV + + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + + - name: Get virtualenv path + shell: bash + run: echo "VENV_PATH=$(python -c 'import sys; print(sys.prefix)')" >> $GITHUB_ENV + + - name: Check cache and install dependencies + shell: bash + run: uv sync --all-extras --dev