-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
120 lines (108 loc) · 4.11 KB
/
action.yml
File metadata and controls
120 lines (108 loc) · 4.11 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
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: '3.13'
working-directory:
description: 'The working directory'
required: false
default: '.'
runs:
using: 'composite'
steps:
- name: Create run_script for running scripts downstream (Unix)
if: runner.os != 'Windows'
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: Create run_script for running scripts downstream (Windows)
if: runner.os == 'Windows'
shell: pwsh
working-directory: ${{ inputs.working-directory }}
run: |
echo "run_script=uv run --frozen" | Tee-Object -Append $env: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
if: runner.os != 'Windows'
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: Install trufflehog
if: runner.os != 'Windows'
shell: 'bash --noprofile --norc -Eeuo pipefail {0}'
run: |
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
- name: Set Python hash for caching (Unix)
if: runner.os != 'Windows'
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: Set Python hash for caching (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$pyVersion = python -VV 2>&1
$hash = [System.BitConverter]::ToString(
[System.Security.Cryptography.SHA256]::Create().ComputeHash(
[System.Text.Encoding]::UTF8.GetBytes($pyVersion)
)
).Replace("-", "").ToLower()
echo "PY=$hash" | Tee-Object -Append $env: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 (Unix)
if: runner.os != 'Windows'
working-directory: ${{ inputs.working-directory }}
shell: 'bash --noprofile --norc -Eeuo pipefail {0}'
run: task -v init
- name: Initialize the repository (Windows)
if: runner.os == 'Windows'
working-directory: ${{ inputs.working-directory }}
shell: pwsh
run: task -v init