Skip to content

Commit 64d9f84

Browse files
SF Masked Tests (#430)
Co-authored-by: knassre-bodo <[email protected]>
1 parent 7860cc5 commit 64d9f84

File tree

184 files changed

+3499
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+3499
-1
lines changed

.github/workflows/pr_testing.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ on:
4141
type: boolean
4242
required: false
4343
default: false
44+
run-sf_masked:
45+
description: "Run Snowflake Masked Tests"
46+
type: boolean
47+
required: false
48+
default: false
4449

4550
# Limit CI to cancel previous runs in the same PR
4651
concurrency:
@@ -143,7 +148,7 @@ jobs:
143148
run: uv run ruff check .
144149

145150
- name: Run Tests
146-
run: uv run pytest tests/ -m "not (snowflake or mysql or postgres)" -rs
151+
run: uv run pytest tests/ -m "not (snowflake or mysql or postgres or sf_masked)" -rs
147152

148153
run-sf-tests:
149154
name: Snowflake Tests
@@ -193,3 +198,24 @@ jobs:
193198
python-versions: ${{ github.event_name == 'workflow_dispatch'
194199
&& needs.get-py-ver-matrix.outputs.matrix
195200
|| '["3.10", "3.11", "3.12"]' }}
201+
202+
run-sf-masked-tests:
203+
name: Masked Snowflake Tests
204+
needs: [get-msg, get-py-ver-matrix]
205+
if: |
206+
(github.event_name == 'pull_request' && contains(needs.get-msg.outputs.commitMsg, '[run all]')) ||
207+
(github.event_name == 'pull_request' && contains(needs.get-msg.outputs.commitMsg, '[run sf_masked]')) ||
208+
(github.event_name == 'workflow_dispatch' && (inputs.run-all || inputs.run-sf_masked))
209+
uses: ./.github/workflows/sf_masked_testing.yml
210+
secrets:
211+
SF_FULL_USERNAME: ${{ secrets.SF_FULL_USERNAME }}
212+
SF_FULL_PASSWORD: ${{ secrets.SF_FULL_PASSWORD }}
213+
SF_PARTIAL_USERNAME: ${{ secrets.SF_PARTIAL_USERNAME }}
214+
SF_PARTIAL_PASSWORD: ${{ secrets.SF_PARTIAL_PASSWORD }}
215+
SF_NONE_USERNAME: ${{ secrets.SF_NONE_USERNAME }}
216+
SF_NONE_PASSWORD: ${{ secrets.SF_NONE_PASSWORD }}
217+
SF_MASKED_ACCOUNT: ${{ secrets.SF_MASKED_ACCOUNT }}
218+
with:
219+
python-versions: ${{ github.event_name == 'workflow_dispatch'
220+
&& needs.get-py-ver-matrix.outputs.matrix
221+
|| '["3.10", "3.11", "3.12"]' }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Run Snowflake Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-versions:
7+
description: "JSON string of Python versions"
8+
type: string
9+
required: true
10+
secrets:
11+
SF_FULL_USERNAME:
12+
required: true
13+
SF_FULL_PASSWORD:
14+
required: true
15+
SF_PARTIAL_USERNAME:
16+
required: true
17+
SF_PARTIAL_PASSWORD:
18+
required: true
19+
SF_NONE_USERNAME:
20+
required: true
21+
SF_NONE_PASSWORD:
22+
required: true
23+
SF_MASKED_ACCOUNT:
24+
required: true
25+
26+
jobs:
27+
sf-tests:
28+
name: Snowflake Tests (Python ${{ matrix.python-version }})
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: ${{ fromJSON(inputs.python-versions) }}
33+
34+
env:
35+
SF_FULL_USERNAME: ${{ secrets.SF_FULL_USERNAME }}
36+
SF_FULL_PASSWORD: ${{ secrets.SF_FULL_PASSWORD }}
37+
SF_PARTIAL_USERNAME: ${{ secrets.SF_PARTIAL_USERNAME }}
38+
SF_PARTIAL_PASSWORD: ${{ secrets.SF_PARTIAL_PASSWORD }}
39+
SF_NONE_USERNAME: ${{ secrets.SF_NONE_USERNAME }}
40+
SF_NONE_PASSWORD: ${{ secrets.SF_NONE_PASSWORD }}
41+
SF_MASKED_ACCOUNT: ${{ secrets.SF_MASKED_ACCOUNT }}
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Setup Python ${{ matrix.python-version }}
47+
id: setup-python
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Install uv
53+
uses: astral-sh/setup-uv@v3
54+
with:
55+
version: "0.4.23"
56+
57+
- name: Create virtual environment
58+
# See note in sf_testing.yml about why we use `uv venv` here.
59+
run: uv venv
60+
61+
- name: Install dependencies
62+
run: uv pip install -e ".[snowflake]"
63+
64+
- name: Confirm Snowflake connector is installed
65+
run: uv run python -c "import snowflake.connector; print(snowflake.connector.__version__)"
66+
67+
- name: Run Snowflake Tests
68+
run: uv run pytest -m sf_masked tests/ -rs

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ markers =
44
snowflake: marks tests that require Snowflake credentials
55
mysql: marks tests that require MySQL credentials
66
postgres: marks tests that require PostgresSQL credentials
7+
sf_masked: marks tests that require Snowflake Masked credentials

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,24 @@ def sqlite_technograph_connection() -> DatabaseContext:
575575
return DatabaseContext(DatabaseConnection(connection), DatabaseDialect.SQLITE)
576576

577577

578+
@pytest.fixture(
579+
params=[
580+
pytest.param(("0", "raw"), id="raw"),
581+
pytest.param(("1", "rewrite"), id="rewrite"),
582+
]
583+
)
584+
def enable_mask_rewrites(request):
585+
"""
586+
Temporarily enable the mask rewrites by setting the environment variable to
587+
the specified value, returning the name that should be used to identify
588+
the situation ("raw" for disabled, "rewrite" for enabled).
589+
"""
590+
old_value: str = os.environ.get("PYDOUGH_ENABLE_MASK_REWRITES", "0")
591+
os.environ["PYDOUGH_ENABLE_MASK_REWRITES"] = request.param[0]
592+
yield request.param[1]
593+
os.environ["PYDOUGH_ENABLE_MASK_REWRITES"] = old_value
594+
595+
578596
@pytest.fixture(scope="session")
579597
def sqlite_cryptbank_connection() -> DatabaseContext:
580598
"""

0 commit comments

Comments
 (0)