Skip to content

Commit 18940f9

Browse files
authored
Merge pull request #2 from khnumdev/cursor/generalize-datastore-analysis-and-cleanup-tools-f98b
ci updated
2 parents 8ab8693 + ecd4e41 commit 18940f9

File tree

6 files changed

+68
-52
lines changed

6 files changed

+68
-52
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,10 @@ on:
66
tags: [ "v*" ]
77
pull_request:
88

9+
910
jobs:
1011
ci:
11-
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
python-version: ["3.9", "3.10", "3.11", "3.12"]
15-
steps:
16-
- uses: actions/checkout@v4
17-
- uses: actions/setup-python@v5
18-
with:
19-
python-version: ${{ matrix.python-version }}
20-
- name: Install
21-
run: |
22-
python -m pip install -U pip
23-
python -m pip install .
24-
python -m pip install pytest
25-
- name: Test
26-
run: |
27-
pytest -q
12+
uses: ./.github/workflows/emulator-test.yml
2813

2914
publish:
3015
needs: ci

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
jobs:
5+
test:
6+
uses: ./.github/workflows/emulator-test.yml
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: emulator-test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: ["3.9", "3.10", "3.11", "3.12"]
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- uses: google-github-actions/setup-gcloud@v1
18+
with:
19+
project_id: dummy-project
20+
install_components: 'beta'
21+
- name: Start Datastore Emulator
22+
run: |
23+
gcloud beta emulators datastore start --host-port=localhost:8010 --project=dummy-project &
24+
sleep 10
25+
- name: Set environment variables
26+
run: |
27+
echo "DATASTORE_EMULATOR_HOST=localhost:8010" >> $GITHUB_ENV
28+
echo "DATASTORE_PROJECT_ID=dummy-project" >> $GITHUB_ENV
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -e .
33+
pip install pytest
34+
- name: Seed Emulator
35+
run: python scripts/seed_emulator.py
36+
- name: Run tests
37+
run: pytest -q

.github/workflows/pr.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,4 @@ on:
55

66
jobs:
77
test:
8-
runs-on: ubuntu-latest
9-
strategy:
10-
matrix:
11-
python-version: ["3.9", "3.10", "3.11", "3.12"]
12-
steps:
13-
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v5
15-
with:
16-
python-version: ${{ matrix.python-version }}
17-
cache: 'pip'
18-
- name: Install
19-
run: |
20-
python -m pip install -U pip
21-
python -m pip install .
22-
python -m pip install pytest ruff black build pip-audit
23-
- name: Lint
24-
run: |
25-
ruff check .
26-
black --check .
27-
- name: Test
28-
run: pytest -q
29-
- name: Build and verify
30-
run: |
31-
python -m build
32-
twine check dist/* || true
33-
- name: Security audit
34-
run: |
35-
pip-audit -r requirements.txt || true
8+
uses: ./.github/workflows/emulator-test.yml

.github/workflows/release.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ on:
55
branches: [ main ]
66

77
jobs:
8+
test:
9+
uses: ./.github/workflows/emulator-test.yml
10+
811
release:
912
runs-on: ubuntu-latest
13+
needs: test
1014
permissions:
1115
contents: write
1216
id-token: write
@@ -22,13 +26,7 @@ jobs:
2226
run: |
2327
python -m pip install -U pip
2428
python -m pip install .
25-
python -m pip install pytest ruff black build python-semantic-release pip-audit
26-
- name: Lint
27-
run: |
28-
ruff check .
29-
black --check .
30-
- name: Test
31-
run: pytest -q
29+
python -m pip install build python-semantic-release pip-audit
3230
- name: Build and verify
3331
run: |
3432
python -m build

scripts/seed_emulator.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from google.cloud import datastore
2+
3+
client = datastore.Client(project="dummy-project")
4+
5+
# Seed default namespace
6+
key = client.key("TestKind", "test-id")
7+
entity = datastore.Entity(key=key)
8+
entity.update({"foo": "bar"})
9+
client.put(entity)
10+
11+
# Seed custom namespace
12+
key_ns = client.key("TestKind", "test-id-ns", namespace="test-ns")
13+
entity_ns = datastore.Entity(key=key_ns)
14+
entity_ns.update({"foo": "baz"})
15+
client.put(entity_ns)
16+
17+
print("Seeded emulator with test entities in default and 'test-ns' namespaces.")

0 commit comments

Comments
 (0)