-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
85 lines (77 loc) · 2.9 KB
/
action.yml
File metadata and controls
85 lines (77 loc) · 2.9 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
82
83
84
85
---
name: 'Bootstrap the repository'
description: 'Sets up uv, adds Homebrew to PATH, installs Task, and initializes the repository'
inputs:
token:
description: 'A Github token'
required: true
python-version:
description: 'Python version to use'
required: false
default: '{{ cookiecutter.python_version }}'
working-directory:
description: 'The working directory'
required: false
default: '.'
runs:
using: 'composite'
steps:
- name: Create run_script for running scripts downstream
shell: 'bash --noprofile --norc -Eeuo pipefail {0}'
working-directory: ${{ "{{ inputs.working-directory }}" }}
run: |
run_script="uv run --frozen"
echo "run_script=${run_script}" | tee -a "${GITHUB_ENV}"
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "**/uv.lock"
python-version: ${{ "{{ inputs.python-version }}" }}
- name: Install Task
uses: go-task/setup-task@v2
with:
# Passing a repo token reduces the likelihood of API rate limit exceeded
repo-token: ${{ "{{ inputs.token }}" }}
- name: Add Homebrew to the path
shell: 'bash --noprofile --norc -Eeuo pipefail {0}'
# This ensures compatibility with macOS runners and Linux runners with Homebrew
run: |
# Check if we're on macOS
if [[ "$RUNNER_OS" == "macOS" ]]; then
# macOS homebrew locations
if [[ -d "/opt/homebrew/bin" ]]; then
PATH="${PATH}:/opt/homebrew/bin"
elif [[ -d "/usr/local/bin" ]]; then
PATH="${PATH}:/usr/local/bin"
fi
else
# Linux homebrew location
if [[ -d "/home/linuxbrew/.linuxbrew/bin" ]]; then
PATH="${PATH}:/home/linuxbrew/.linuxbrew/bin"
fi
fi
export PATH
echo "PATH=${PATH}" | tee -a "${GITHUB_ENV}"
# Smoke test - don't fail if brew isn't available
if command -v brew &> /dev/null; then
echo "Homebrew found at: $(which brew)"
brew --version
else
echo "Homebrew not found, continuing without it"
fi
working-directory: ${{ "{{ inputs.working-directory }}" }}
- name: Set Python hash for caching
shell: 'bash --noprofile --norc -Eeuo pipefail {0}'
run: |
# Create a hash of the Python version for better cache keys
echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" | tee -a "${GITHUB_ENV}"
- name: Cache pre-commit environments
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ "{{ env.PY }}" }}|${{ "{{ hashFiles(format('{0}/.pre-commit-config.yaml', inputs.working-directory)) }}" }}
- name: Initialize the repository
working-directory: ${{ "{{ inputs.working-directory }}" }}
shell: 'bash --noprofile --norc -Eeuo pipefail {0}'
run: task -v init