Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 53 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Unittests

Check warning on line 15 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

excessive-permissions

pytest.yml:15: overly broad permissions: default permissions used due to no permissions: block

on:
push:
Expand All @@ -22,7 +22,52 @@
workflow_dispatch:

jobs:
check-lockfile:

Check warning on line 25 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

excessive-permissions

pytest.yml:25: overly broad permissions: default permissions used due to no permissions: block
name: "Check: pylock.toml Sync"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

Check failure on line 30 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 30 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

pytest.yml:30: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
fetch-depth: 0
- name: Check if pyproject.toml was modified
id: check_pyproject
env:
GH_EVENT_NAME: ${{ github.event_name }}
GH_BASE_REF: ${{ github.base_ref }}
run: |
if [ "$GH_EVENT_NAME" = "pull_request" ]; then
git fetch origin "$GH_BASE_REF" --depth=1
BASE_REF="origin/$GH_BASE_REF"
else
BASE_REF="HEAD~1"
fi
if git diff --name-only "$BASE_REF" HEAD | grep -q '^pyproject.toml$'; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "pyproject.toml was modified. Validating pylock.toml sync..."
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "pyproject.toml was not modified. Skipping lockfile sync check."
fi
- uses: astral-sh/setup-uv@v5

Check failure on line 52 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 52 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

pytest.yml:52: unpinned action reference: action is not pinned to a hash (required by blanket policy)
if: steps.check_pyproject.outputs.changed == 'true'
with:
enable-cache: true
- name: Verify pylock.toml is up to date with pyproject.toml
if: steps.check_pyproject.outputs.changed == 'true'
run: |
uv export --format pylock.toml --all-extras --default-index https://pypi.org/simple -o pylock_generated.toml --python 3.12
grep -v '^#' pylock.toml > pylock_current_clean.toml
grep -v '^#' pylock_generated.toml > pylock_new_clean.toml
diff -u pylock_current_clean.toml pylock_new_clean.toml || {
echo -e "\n---> pylock.toml is out of sync with pyproject.toml." >&2
echo -e "---> Run 'uv export --format pylock.toml --all-extras --default-index https://pypi.org/simple -o pylock.toml --python 3.12' locally and commit the changes." >&2
exit 1
}

pytest-job:

Check warning on line 68 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

excessive-permissions

pytest.yml:68: overly broad permissions: default permissions used due to no permissions: block
name: pytest-job
needs: check-lockfile
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -31,17 +76,21 @@
cancel-in-progress: true

steps:
- uses: actions/checkout@v4

Check failure on line 79 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 79 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

pytest.yml:79: unpinned action reference: action is not pinned to a hash (required by blanket policy)

# Install deps
- uses: actions/setup-python@v5

Check failure on line 82 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 82 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

pytest.yml:82: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
python-version: "3.12"
cache: pip

- run: pip --version
- run: pip install -e .[dev,pipeline,text]
- run: pip freeze
- uses: astral-sh/setup-uv@v5

Check failure on line 86 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 86 in .github/workflows/pytest.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

pytest.yml:86: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
enable-cache: true

- name: Install dependencies
run: |
uv pip install --system -r pylock.toml
uv pip install --system -e .

- name: Run core tests
run: pytest -vv -n auto --import-mode=importlib
61 changes: 61 additions & 0 deletions .github/workflows/update_lockfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Update pylock.toml

on:
schedule:
- cron: "0 3 1 * *" # Run monthly on the 1st of every month at 03:00 UTC
workflow_dispatch: # Allow manual trigger from GitHub Actions UI

jobs:
update-lockfile:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: "actions/checkout@v4"

Check failure on line 30 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 30 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

update_lockfile.yml:30: unpinned action reference: action is not pinned to a hash (required by blanket policy)

- name: Set up Python
uses: "actions/setup-python@v5"

Check failure on line 33 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 33 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

update_lockfile.yml:33: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
python-version: "3.12"

- name: Install uv
uses: "astral-sh/setup-uv@v5"

Check failure on line 38 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 38 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

update_lockfile.yml:38: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
enable-cache: true

- name: Regenerate pylock.toml
run: |
uv export --format pylock.toml --all-extras --default-index https://pypi.org/simple -o pylock.toml --python 3.12
go run github.com/google/addlicense@v1.1.1 -c "Google LLC" -y "2026" -l apache pylock.toml

- name: Create Pull Request
uses: "peter-evans/create-pull-request@v7"

Check failure on line 48 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 48 in .github/workflows/update_lockfile.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

update_lockfile.yml:48: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update dependencies in pylock.toml"
title: "Update pylock.toml dependencies"
body: |
Automated update of dependencies in `pylock.toml` triggered by ${{ github.event_name }}.

Generated via `uv export --format pylock.toml --all-extras --default-index https://pypi.org/simple -o pylock.toml --python 3.12`.
branch: "automated/update-pylock"
delete-branch: true
labels: |
dependencies
automated
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,44 @@ DP Synth deliberately keeps its dependency footprint small:
- If your contribution requires a new dependency, discuss it in the issue
tracker first.

## Development Setup

We use [uv](https://docs.astral.sh/uv/) for managing your development
environment. It provides support for managing `pylock.toml` lock files and
is significantly faster than `pip`.

> [!NOTE]
> The `pylock.toml` file is generated using `uv`, but it follows standard
> specifications as per PEP 751 and should work with modern package managers
> that support it.

1. **Install uv:** Follow the [official instructions](https://docs.astral.sh/uv/getting-started/installation/).
2. **Create an environment and install dependencies:**

```bash
# Create a virtual environment with Python 3.12
uv venv --python 3.12
# Activate it (Linux/macOS)
source .venv/bin/activate
# Install all dependencies from the lockfile and install the project in editable mode
uv pip install -r pylock.toml
uv pip install -e .
```

3. **Updating `pylock.toml`:** Regenerate `pylock.toml` using `uv` periodically
or when modifying dependencies in `pyproject.toml`:

```bash
uv export --format pylock.toml --all-extras --default-index https://pypi.org/simple -o pylock.toml --python 3.12
go run github.com/google/addlicense@v1.1.1 -c "Google LLC" -y "2026" -l apache pylock.toml
```

Commit the updated `pylock.toml` to ensure CI and contributors remain in
sync.

Note that any update to `pyproject.toml` must be accompanied by a
regeneration of `pylock.toml`.

## Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License
Expand Down
Loading
Loading