Skip to content

Commit e6adc00

Browse files
authoredFeb 1, 2025··
fix(ci): broken ci pipeline for python (#1778)
1 parent 6de1b10 commit e6adc00

File tree

6 files changed

+71
-24
lines changed

6 files changed

+71
-24
lines changed
 

‎.github/workflows/python.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ jobs:
66
python-checks:
77
runs-on: ubuntu-latest
88
env:
9-
PATH: ${{ github.workspace }}/go/bin:${{ github.workspace }}/.cargo/bin:${{ github.workspace }}/.local/share/pnpm:${{ github.workspace }}/.local/bin:${{ env.PATH }}
9+
PATH: ${{ github.workspace }}/go/bin:${{ github.workspace }}/.cargo/bin:${{ github.workspace }}/.local/share/pnpm:${{ github.workspace }}/.local/bin:/usr/local/bin:/usr/bin:/bin
1010
strategy:
1111
matrix:
1212
python-version:
1313
- "3.12"
14-
- "3.13"
1514
defaults:
1615
run:
1716
working-directory: py
@@ -35,7 +34,7 @@ jobs:
3534
run: uv run ruff check .
3635

3736
- name: Run tests
38-
run: uv run pytest .
37+
run: ./bin/run_tests
3938

4039
- name: Build documentation
4140
run: uv run mkdocs build --strict

‎py/bin/run_tests

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Run tests for all supported Python versions
4+
5+
set -euo pipefail
6+
7+
TOP_DIR=$(git rev-parse --show-toplevel)
8+
PYTHON_VERSIONS=(
9+
"3.12"
10+
"3.13"
11+
)
12+
13+
for VERSION in "${PYTHON_VERSIONS[@]}"; do
14+
echo "Running tests with Python ${VERSION}..."
15+
uv run --python "python${VERSION}" --directory "${TOP_DIR}/py" pytest .
16+
done

‎py/bin/setup

+33-16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
18+
#
19+
# SPDX-License-Identifier: Apache-2.0
1820

1921
if ((EUID == 0)) && [[ -z ${DANGEROUSLY_RUN_AS_ROOT+x} ]]; then
2022
echo "Please do not run as root unless DANGEROUSLY_RUN_AS_ROOT is set."
@@ -63,11 +65,6 @@ function genkit::update_path() {
6365
# Remove trailing slash if present.
6466
new_path="${new_path%/}"
6567

66-
if [ ! -d "$new_path" ]; then
67-
echo "Error: Directory $new_path does not exist"
68-
return 1
69-
fi
70-
7168
# Check if path is already in PATH
7269
if [[ ":$PATH:" != *":$new_path:"* ]]; then
7370
if [ -n "${ZSH_VERSION:-}" ]; then
@@ -100,26 +97,32 @@ function genkit::install_prerequisites() {
10097
# Darwin-based systems.
10198
brew install \
10299
curl \
100+
fd \
103101
gh \
104102
go \
105103
node \
106-
python3
104+
python3 \
105+
ripgrep
107106
elif [[ -x "$(command -v apt)" ]]; then
108107
# Debian-based systems.
109108
sudo apt install -y \
110109
curl \
110+
fd-find \
111111
gh \
112112
golang \
113113
nodejs \
114-
python3
114+
python3 \
115+
ripgrep
115116
elif [[ -x "$(command -v dnf)" ]]; then
116117
# Fedora-based systems.
117118
sudo dnf install -y \
118119
curl \
120+
fd-find \
119121
gh \
120122
go \
121123
node \
122-
python3
124+
python3 \
125+
ripgrep
123126
else
124127
echo "Unsupported OS. Please install protoc manually."
125128
fi
@@ -154,30 +157,39 @@ function genkit::install_google_cloud_sdk() {
154157
}
155158

156159
# Install all the required tools that have been written in Go.
157-
function genkit::install_go_cli_tools() {
160+
function genkit::install_go_cli_tools_ci() {
161+
go install github.com/google/go-licenses@latest
162+
go install golang.org/x/vuln/cmd/govulncheck@latest
163+
go install oss.terrastruct.com/d2@latest
164+
}
165+
166+
# Install all the required tools that have been written in Go.
167+
function genkit::install_go_cli_tools_eng() {
158168
go install github.com/Gelio/go-global-update@latest
159169
go install github.com/captainhook-go/captainhook/cmd/captainhook@latest
160170
go install github.com/google/addlicense@latest
161171
go install github.com/google/go-licenses@latest
162172
go install github.com/jesseduffield/lazygit@latest
163173
go install golang.org/x/vuln/cmd/govulncheck@latest
174+
go install oss.terrastruct.com/d2@latest
164175
}
165176

166177
# Install all the required tools that have been written in Rust. We're assuming
167178
# that the user has already installed rust and cargo.
168-
function genkit::install_cargo_cli_tools() {
179+
function genkit::install_cargo_cli_tools_eng() {
169180
cargo install --locked \
170181
convco \
171-
fd-find \
172-
ripgrep \
173182
rust-parallel \
174183
taplo-cli
175184
}
176185

177186
# Install NPM packages.
178187
function genkit::install_pnpm_cli_tools() {
179-
# Install the Genkit CLI. See: https://firebase.google.com/docs/genkit/devtools
180-
pnpm add -g genkit-cli
188+
# Genkit CLI: https://firebase.google.com/docs/genkit/devtools
189+
# Biome: https://biomejs.dev/
190+
pnpm add -g \
191+
@biomejs/biome \
192+
genkit-cli
181193
}
182194

183195
# Install all the Python-related formatter and static analysis tools.
@@ -189,6 +201,9 @@ function genkit::install_python_cli_tools() {
189201

190202
# Install documentation site generator.
191203
function genkit::install_docs_cli_tools() {
204+
# Install d2.
205+
curl -fsSL https://d2lang.com/install.sh | sh -s --
206+
192207
# Engineering documentation site generator.
193208
# See: https://squidfunk.github.io/mkdocs-material/
194209
uv tool install \
@@ -218,21 +233,23 @@ function genkit::setup_genkit() {
218233
# Install all the common packages.
219234
function genkit::install_common_packages() {
220235
genkit::install_prerequisites
221-
genkit::install_go_cli_tools
222-
genkit::install_cargo_cli_tools
223236
genkit::install_python_cli_tools
224237
genkit::install_docs_cli_tools
225238
genkit::install_pnpm_cli_tools
226239
}
227240

228241
# Install all the required tools for CI.
229242
function genkit::install_ci_packages() {
243+
export PNPM_HOME="$HOME/.local/share/pnpm"
230244
genkit::install_common_packages
245+
genkit::install_go_cli_tools_ci
231246
}
232247

233248
# Install all the required tools for engineering.
234249
function genkit::install_eng_packages() {
235250
genkit::install_common_packages
251+
genkit::install_go_cli_tools_eng
252+
genkit::install_cargo_cli_tools_eng
236253
genkit::install_google_cloud_sdk
237254
genkit::install_pre_commit_hooks
238255
genkit::setup_genkit

‎py/captainhook.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"run": "uvx --directory py ruff check --fix ."
4141
},
4242
{
43-
"run": "uv run --directory py pytest ."
43+
"run": "py/bin/run_tests"
4444
},
4545
{
4646
"run": "uv run --directory py mkdocs build"
@@ -88,7 +88,7 @@
8888
"run": "uvx --directory py ruff check --fix ."
8989
},
9090
{
91-
"run": "uv run --directory py pytest ."
91+
"run": "py/bin/run_tests"
9292
},
9393
{
9494
"run": "uv run --directory py mkdocs build"

‎py/packages/dotprompt/pyproject.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ classifiers = [
1414
"Topic :: Scientific/Engineering :: Artificial Intelligence",
1515
"Topic :: Software Development :: Libraries",
1616
]
17-
dependencies = [
18-
"handlebarz",
19-
]
17+
dependencies = ["handlebarz"]
2018
description = "Dotprompt is a language-neutral executable prompt template file format for Generative AI."
2119
license = { text = "Apache-2.0" }
2220
name = "dotprompt"
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
118
def hello() -> str:
219
return 'Hello from handlebarz!'

0 commit comments

Comments
 (0)
Please sign in to comment.