Skip to content

Commit f31f9e8

Browse files
committedJan 30, 2025·
feat: add GitHub actions for Python and pre-commit checks for go #1704
Changelog: - [ ] Adds GitHub actions to check the PR for Python code changes See: https://docs.astral.sh/uv/guides/integration/github/ - [ ] Adds pre-commit checks so that go tests pass per commit. - [ ] Configure prettier to ignore .mypy_cache/ - [ ] Fixes formatting for some engdoc
1 parent a0463a2 commit f31f9e8

File tree

6 files changed

+63
-10
lines changed

6 files changed

+63
-10
lines changed
 

‎.github/workflows/python.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Python Checks
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'py/**'
7+
8+
jobs:
9+
python-checks:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version:
14+
- "3.12"
15+
- "3.13"
16+
defaults:
17+
run:
18+
working-directory: py
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Pre-requisites
24+
run: bin/setup -a ci
25+
26+
- name: Install uv and setup Python version
27+
uses: astral-sh/setup-uv@v5
28+
with:
29+
enable-cache: true
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Format check
33+
run: uv run ruff format --check .
34+
35+
- name: Lint with ruff
36+
run: uv run ruff check .
37+
38+
- name: Run tests
39+
run: uv run pytest .
40+
41+
- name: Build documentation
42+
run: uv run mkdocs build --strict
43+
44+
- name: Build distributions
45+
run: ./bin/build_dists

‎.prettierignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
go/
2-
public/
31
.github/
2+
.mypy_cache/*
43
.prettierrc.yaml
5-
pnpm-lock.yaml
6-
docs/*
74
docs-go/*
5+
docs/*
86
genkit-tools/genkit-schema.json
7+
go/
8+
pnpm-lock.yaml
9+
public/
910
py/*

‎py/bin/setup

+4-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ function genkit::install_prerequisites() {
8888
curl -LsSf https://astral.sh/uv/install.sh | sh
8989

9090
# Install pnpm for JavaScript package management.
91-
curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=10.0.0 sh -
91+
# See: https://github.com/pnpm/pnpm/issues/6217
92+
curl -fsSL https://get.pnpm.io/install.sh | env ENV="$HOME/.bashrc" SHELL="$(which bash)" PNPM_VERSION=10.0.0 bash -
9293
}
9394

9495
function genkit::install_google_cloud_sdk() {
@@ -107,8 +108,8 @@ function genkit::install_google_cloud_sdk() {
107108
function genkit::install_ci_packages() {
108109
genkit::install_prerequisites
109110
genkit::install_python_cli_tools
111+
genkit::install_go_cli_tools
110112
genkit::install_docs_cli_tools
111-
genkit::install_pnpm_cli_tools
112113
}
113114

114115
# Install all the required tools for engineering.
@@ -143,7 +144,7 @@ function genkit::install_cargo_cli_tools() {
143144
# Install NPM packages.
144145
function genkit::install_pnpm_cli_tools() {
145146
# Install the Genkit CLI. See: https://firebase.google.com/docs/genkit/devtools
146-
pnpm add -g genkit-cli
147+
"$HOME/.local/share/pnpm/pnpm" add -g genkit-cli
147148
}
148149

149150
PYTHON_CLI_TOOLS=(

‎py/captainhook.json

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
},
4848
{
4949
"run": "py/bin/build_dists"
50+
},
51+
{
52+
"run": "go test go/..."
5053
}
5154
]
5255
},
@@ -82,6 +85,9 @@
8285
{
8386
"run": "py/bin/build_dists"
8487
},
88+
{
89+
"run": "go test go/..."
90+
},
8591
{
8692
"run": "py/.hooks/commit-message-format-pre-push"
8793
}

‎py/engdoc/contributing/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,5 @@ py/bin/setup
185185
The following is the equivalent used for CI/CD systems.
186186

187187
```bash
188-
py/bin/setup -e ci
188+
py/bin/setup -a ci
189189
```

‎py/engdoc/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ capabilities in code:
388388

389389
=== "Python"
390390

391-
```python
391+
```python
392392

393-
```
393+
```
394394

395395
=== "JavaScript"
396396

0 commit comments

Comments
 (0)