-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathaction.yml
More file actions
81 lines (69 loc) · 2.26 KB
/
action.yml
File metadata and controls
81 lines (69 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Action: Setup Project (composite action)
#
# Purpose: Bootstrap a Python project within GitHub Actions by:
# - Installing uv and uvx into a local ./bin directory and adding it to PATH
# - Detecting the presence of pyproject.toml and exposing that as an output
# - Creating a virtual environment with uv and (optionally) syncing dependencies
#
# Inputs:
# - python-version: Python version for the uv-managed virtual environment (default: 3.12)
#
# Outputs:
# - pyproject_exists: "true" if pyproject.toml exists, otherwise "false"
#
# Notes:
# - Safe to run in repositories without pyproject.toml; dependency sync will be skipped.
# - Purely a CI helper — it does not modify repository files.
name: 'Setup Project'
description: 'Setup the project'
inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.12'
outputs:
pyproject_exists:
description: 'Flag indicating whether pyproject.toml exists'
value: ${{ steps.check_pyproject.outputs.exists }}
runs:
using: 'composite'
steps:
- name: Set up uv, uvx and the venv
shell: bash
run: |
mkdir -p bin
# Add ./bin to the PATH
echo "Adding ./bin to PATH"
echo "$(pwd)/bin" >> $GITHUB_PATH
# Install uv and uvx
curl -fsSL https://astral.sh/uv/install.sh | UV_INSTALL_DIR="./bin" sh
- name: Check version for uv
shell: bash
run: |
uv --version
- name: Check for pyproject.toml
id: check_pyproject
shell: bash
run: |
if [ -f "pyproject.toml" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Build the virtual environment
shell: bash
run: uv venv --python ${{ inputs.python-version }}
- name: "Sync the virtual environment for ${{ github.repository }} if pyproject.toml exists"
shell: bash
run: |
if [ -f "pyproject.toml" ]; then
uv sync --all-extras
else
echo "No pyproject.toml found, skipping package installation"
fi
- name: Show dependencies
shell: bash
run: uv pip list
- name: Show Python version
shell: bash
run: uv run python -c "import sys; print(sys.version)"