Skip to content

Commit 83319c8

Browse files
authored
chore: add fuzzy tests (hypothesis) of output_format (#74)
Co-authored-by: Michał Sośnicki <michal.sosnicki@neptune.ai>
1 parent c356de7 commit 83319c8

File tree

10 files changed

+677
-3
lines changed

10 files changed

+677
-3
lines changed

.github/actions/run-tests/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
description: 'Working directory'
1616
required: false
1717
default: .
18+
timeout:
19+
description: "Test timeout in seconds"
20+
required: false
21+
default: "120"
1822

1923
runs:
2024
using: "composite"
@@ -23,7 +27,7 @@ runs:
2327
working-directory: ${{ inputs.working-directory }}
2428
run: |
2529
pytest -v "./tests/${{ inputs.test-directory }}" \
26-
--timeout=120 --timeout_method=thread \
30+
--timeout=${{ inputs.timeout }} --timeout_method=thread \
2731
--color=yes \
2832
--junitxml="${{ inputs.working-directory }}/test-results/test-${{ inputs.report-suffix }}.xml"
2933
shell: bash

.github/workflows/tests-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
pull_request: # Don't run e2e tests on PRs that don't modify source code
1818
paths:
1919
- 'src/**'
20-
- 'tests/**'
20+
- 'tests/e2e/**'
2121
- 'dev_requirements.txt'
2222
- 'pyproject.toml'
2323
- '.github/workflows/tests-e2e.yml'

.github/workflows/tests-fuzzy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Run fuzzy tests - neptune-query
2+
3+
on:
4+
schedule:
5+
- cron: '0 8 * * *' # Run at 8:00 daily
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
- dev/.*
11+
pull_request:
12+
paths:
13+
- 'src/**'
14+
- 'tests/fuzzy/**'
15+
- 'dev_requirements.txt'
16+
- 'pyproject.toml'
17+
- '.github/workflows/tests-fuzzy.yml'
18+
19+
jobs:
20+
test:
21+
timeout-minutes: 75
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
python-version: [ "3.13" ]
26+
os: [ ubuntu ]
27+
28+
name: 'fuzzy test (${{ matrix.os }} - py${{ matrix.python-version }})'
29+
runs-on: ${{ matrix.os }}-latest
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
ref: ${{ github.event.client_payload.pull_request.head.ref }}
36+
37+
- name: Install package
38+
uses: ./.github/actions/install-package
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
os: ${{ matrix.os }}-latest
42+
43+
- name: Run tests
44+
uses: ./.github/actions/run-tests
45+
with:
46+
test-directory: fuzzy
47+
report-job: 'test fuzzy (${{ matrix.os }} - py${{ matrix.python-version }})'
48+
report-suffix: 'fuzzy-${{ matrix.python-version }}-${{ matrix.os }}'
49+
timeout: "900"
50+
env:
51+
NEPTUNE_E2E_HYPOTHESIS_PROFILE: ${{ github.event_name == 'schedule' && 'ci-nightly' || 'ci-quick' }}
52+
53+
- name: Notify Slack on failure
54+
if: failure() && github.event_name == 'schedule'
55+
uses: actions/github-script@v7
56+
with:
57+
script: |
58+
const webhookUrl = process.env.SLACK_WEBHOOK_URL;
59+
const payload = {
60+
username: "GitHub Actions",
61+
text: `Fuzzy tests failed in the repository: <https://github.com/${context.repo.owner}/${context.repo.repo}|${context.repo.owner}/${context.repo.repo}>. Please check the details.`
62+
};
63+
await fetch(webhookUrl, {
64+
method: 'POST',
65+
headers: {
66+
'Content-Type': 'application/json'
67+
},
68+
body: JSON.stringify(payload)
69+
});
70+
env:
71+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/tests-unit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ on:
66
pull_request:
77
paths:
88
- 'src/**'
9-
- 'tests/**'
9+
- 'tests/unit/**'
1010
- 'dev_requirements.txt'
1111
- 'pyproject.toml'
12+
- '.github/workflows/tests-unit.yml'
1213
push:
1314
branches:
1415
- main

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ venv.bak/
123123
.history
124124
.vscode
125125

126+
# Cursor
127+
.cursor/
128+
126129
stream.bin
127130

128131
# mocks

dev_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ pytest-timeout
1010
pytest-xdist
1111
icecream
1212
git+https://github.com/neptune-ai/neptune-client-scale.git@main#egg=neptune-scale
13+
hypothesis==6.139.2

tests/fuzzy/__init__.py

Whitespace-only changes.

tests/fuzzy/conftest.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
from datetime import timedelta
3+
4+
from hypothesis import settings
5+
6+
7+
def pytest_set_filtered_exceptions() -> list[type[BaseException]]:
8+
class DoNotFilterAnythingMarker(Exception):
9+
pass
10+
11+
return [DoNotFilterAnythingMarker]
12+
13+
14+
settings.register_profile(
15+
"ci-quick",
16+
settings.get_profile("ci"),
17+
max_examples=100,
18+
deadline=timedelta(seconds=10),
19+
derandomize=True,
20+
)
21+
22+
23+
settings.register_profile(
24+
"ci-nightly",
25+
settings.get_profile("ci"),
26+
max_examples=2000,
27+
deadline=timedelta(seconds=20),
28+
derandomize=False,
29+
)
30+
31+
settings.load_profile(os.getenv("NEPTUNE_E2E_HYPOTHESIS_PROFILE", "ci-quick"))

0 commit comments

Comments
 (0)