Skip to content
Merged
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
19 changes: 2 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,10 @@ on:
tags: [ "v*" ]
pull_request:


jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
python -m pip install -U pip
python -m pip install .
python -m pip install pytest
- name: Test
run: |
pytest -q
uses: ./.github/workflows/emulator-test.yml

publish:
needs: ci
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: CI

on: [push, pull_request]
jobs:
test:
uses: ./.github/workflows/emulator-test.yml
37 changes: 37 additions & 0 deletions .github/workflows/emulator-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: emulator-test

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/setup-gcloud@v1
with:
project_id: dummy-project
install_components: 'beta'
- name: Start Datastore Emulator
run: |
gcloud beta emulators datastore start --host-port=localhost:8010 --project=dummy-project &
sleep 10
- name: Set environment variables
run: |
echo "DATASTORE_EMULATOR_HOST=localhost:8010" >> $GITHUB_ENV
echo "DATASTORE_PROJECT_ID=dummy-project" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest
- name: Seed Emulator
run: python scripts/seed_emulator.py
- name: Run tests
run: pytest -q
29 changes: 1 addition & 28 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,4 @@ on:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install
run: |
python -m pip install -U pip
python -m pip install .
python -m pip install pytest ruff black build pip-audit
- name: Lint
run: |
ruff check .
black --check .
- name: Test
run: pytest -q
- name: Build and verify
run: |
python -m build
twine check dist/* || true
- name: Security audit
run: |
pip-audit -r requirements.txt || true
uses: ./.github/workflows/emulator-test.yml
12 changes: 5 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ on:
branches: [ main ]

jobs:
test:
uses: ./.github/workflows/emulator-test.yml

release:
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
id-token: write
Expand All @@ -22,13 +26,7 @@ jobs:
run: |
python -m pip install -U pip
python -m pip install .
python -m pip install pytest ruff black build python-semantic-release pip-audit
- name: Lint
run: |
ruff check .
black --check .
- name: Test
run: pytest -q
python -m pip install build python-semantic-release pip-audit
- name: Build and verify
run: |
python -m build
Expand Down
17 changes: 17 additions & 0 deletions scripts/seed_emulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from google.cloud import datastore

client = datastore.Client(project="dummy-project")

# Seed default namespace
key = client.key("TestKind", "test-id")
entity = datastore.Entity(key=key)
entity.update({"foo": "bar"})
client.put(entity)

# Seed custom namespace
key_ns = client.key("TestKind", "test-id-ns", namespace="test-ns")
entity_ns = datastore.Entity(key=key_ns)
entity_ns.update({"foo": "baz"})
client.put(entity_ns)

print("Seeded emulator with test entities in default and 'test-ns' namespaces.")
Loading