Skip to content

Commit

Permalink
feat: add GitHub actions for Python and pre-commit checks for go #1704
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yesudeep committed Jan 30, 2025
1 parent a0463a2 commit 92e4738
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 9 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Python Checks

on:
pull_request:
paths:
- 'py/**'

jobs:
python-checks:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.12"
- "3.13"
defaults:
run:
working-directory: py

steps:
- uses: actions/checkout@v4

- name: Pre-requisites
run: bin/setup -a ci

- name: Install uv and setup Python version
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Format check
run: uv run ruff format --check .

- name: Lint with ruff
run: uv run ruff check .

- name: Run tests
run: uv run pytest .

- name: Build documentation
run: uvx mkdocs build --strict

- name: Build distributions
run: ./bin/build_dists
9 changes: 5 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
go/
public/
.github/
.mypy_cache/*
.prettierrc.yaml
pnpm-lock.yaml
docs/*
docs-go/*
docs/*
genkit-tools/genkit-schema.json
go/
pnpm-lock.yaml
public/
py/*
7 changes: 5 additions & 2 deletions py/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ function genkit::install_prerequisites() {
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install pnpm for JavaScript package management.
curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=10.0.0 sh -
# See: https://github.com/pnpm/pnpm/issues/6217
curl -fsSL https://get.pnpm.io/install.sh | env ENV="$HOME/.bashrc" SHELL="$(which bash)" PNPM_VERSION=10.0.0 bash -
env SHELL="$(which bash)" "$HOME/.local/share/pnpm/pnpm" setup
#source "$HOME/.bashrc"
}

function genkit::install_google_cloud_sdk() {
Expand Down Expand Up @@ -143,7 +146,7 @@ function genkit::install_cargo_cli_tools() {
# Install NPM packages.
function genkit::install_pnpm_cli_tools() {
# Install the Genkit CLI. See: https://firebase.google.com/docs/genkit/devtools
pnpm add -g genkit-cli
"$HOME/.local/share/pnpm/pnpm" add -g genkit-cli
}

PYTHON_CLI_TOOLS=(
Expand Down
6 changes: 6 additions & 0 deletions py/captainhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
},
{
"run": "py/bin/build_dists"
},
{
"run": "go test go/..."
}
]
},
Expand Down Expand Up @@ -82,6 +85,9 @@
{
"run": "py/bin/build_dists"
},
{
"run": "go test go/..."
},
{
"run": "py/.hooks/commit-message-format-pre-push"
}
Expand Down
2 changes: 1 addition & 1 deletion py/engdoc/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ py/bin/setup
The following is the equivalent used for CI/CD systems.

```bash
py/bin/setup -e ci
py/bin/setup -a ci
```
4 changes: 2 additions & 2 deletions py/engdoc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ capabilities in code:

=== "Python"

```python
```python

```
```

=== "JavaScript"

Expand Down

0 comments on commit 92e4738

Please sign in to comment.