-
Notifications
You must be signed in to change notification settings - Fork 2
ci: add codspeed benchmarks #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bc84125
1cb7ecd
5aead11
bdd9609
35f1402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -192,3 +192,5 @@ mise.local.toml | |
| .windsurf | ||
|
|
||
| CLAUDE.md | ||
|
|
||
| .codspeed | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from tests.integration.fixtures import ( | ||
| aiosqlite_engine, | ||
| any_query, | ||
| any_session, | ||
| async_engine, | ||
| async_mutation, | ||
| async_query, | ||
| async_session, | ||
| asyncmy_engine, | ||
| asyncpg_engine, | ||
| before_create_all_statements, | ||
| config, | ||
| db_features, | ||
| dialect, | ||
| engine, | ||
| fx_metadata, | ||
| mapper, | ||
| no_session_query, | ||
| postgis_service, | ||
| postgres_database_service, | ||
| psycopg_async_engine, | ||
| psycopg_engine, | ||
| query_tracker, | ||
| raw_arrays, | ||
| raw_colors, | ||
| raw_date_times, | ||
| raw_farms, | ||
| raw_fruits, | ||
| raw_geo, | ||
| raw_geo_flipped, | ||
| raw_groups, | ||
| raw_intervals, | ||
| raw_json, | ||
| raw_topics, | ||
| raw_users, | ||
| seed_db_async, | ||
| seed_db_sync, | ||
| seed_insert_statements, | ||
| session, | ||
| sqlite_engine, | ||
| sync_mutation, | ||
| sync_query, | ||
| ) | ||
|
|
||
| from .fixtures import fx_strawchemy_mysql, fx_strawchemy_postgresql, fx_strawchemy_sqlite | ||
|
|
||
| __all__ = ( | ||
| "aiosqlite_engine", | ||
| "any_query", | ||
| "any_session", | ||
| "async_engine", | ||
| "async_mutation", | ||
| "async_query", | ||
| "async_session", | ||
| "asyncmy_engine", | ||
| "asyncpg_engine", | ||
| "before_create_all_statements", | ||
| "config", | ||
| "db_features", | ||
| "dialect", | ||
| "engine", | ||
| "fx_metadata", | ||
| "fx_strawchemy_mysql", | ||
| "fx_strawchemy_postgresql", | ||
| "fx_strawchemy_sqlite", | ||
| "mapper", | ||
| "no_session_query", | ||
| "postgis_service", | ||
| "postgres_database_service", | ||
| "psycopg_async_engine", | ||
| "psycopg_engine", | ||
| "query_tracker", | ||
| "raw_arrays", | ||
| "raw_colors", | ||
| "raw_date_times", | ||
| "raw_farms", | ||
| "raw_fruits", | ||
| "raw_geo", | ||
| "raw_geo_flipped", | ||
| "raw_groups", | ||
| "raw_intervals", | ||
| "raw_json", | ||
| "raw_topics", | ||
| "raw_users", | ||
| "seed_db_async", | ||
| "seed_db_sync", | ||
| "seed_insert_statements", | ||
| "session", | ||
| "sqlite_engine", | ||
| "sync_mutation", | ||
| "sync_query", | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
| from strawchemy import Strawchemy | ||
|
|
||
|
|
||
| @pytest.fixture(name="strawchemy_postgresql") | ||
| def fx_strawchemy_postgresql() -> Strawchemy: | ||
| return Strawchemy("postgresql") | ||
|
|
||
|
|
||
| @pytest.fixture(name="strawchemy_sqlite") | ||
| def fx_strawchemy_sqlite() -> Strawchemy: | ||
| return Strawchemy("sqlite") | ||
|
|
||
|
|
||
| @pytest.fixture(name="strawchemy_mysql") | ||
| def fx_strawchemy_mysql() -> Strawchemy: | ||
| return Strawchemy("mysql") |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||
|
|
||||||||||||||||||
| from typing import TYPE_CHECKING | ||||||||||||||||||
|
|
||||||||||||||||||
| import pytest | ||||||||||||||||||
| from pytest_lazy_fixtures import lf | ||||||||||||||||||
| from strawchemy import StrawchemySyncRepository | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify public export for StrawchemySyncRepository Confirm Run: 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
rg -nP 'class\s+StrawchemySyncRepository\b' -S
rg -nP 'from\s+strawchemy\s+import\s+.*StrawchemySyncRepository|__all__.*StrawchemySyncRepository' src -SLength of output: 224 Re-export StrawchemySyncRepository from package root or import it from its submodule StrawchemySyncRepository is defined at src/strawchemy/strawberry/repository/_sync.py and exported in src/strawchemy/strawberry/repository/init.py, but there’s no evidence it’s re-exported from the package root — update tests/benchmarks/test_build_schema.py (line 7) to: 🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| from tests.integration.models import User | ||||||||||||||||||
|
|
||||||||||||||||||
| if TYPE_CHECKING: | ||||||||||||||||||
| from pytest_codspeed import BenchmarkFixture | ||||||||||||||||||
| from strawchemy import Strawchemy | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @pytest.mark.benchmark(group="schema") | ||||||||||||||||||
| @pytest.mark.parametrize("strawchemy", [lf("strawchemy_postgresql"), lf("strawchemy_sqlite"), lf("strawchemy_mysql")]) | ||||||||||||||||||
| def test_build_user_type(strawchemy: Strawchemy) -> None: | ||||||||||||||||||
| strawchemy.type(User, include="all", override=True)(type("UserType", (), {})) | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+16
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bench not recorded: wrap in benchmark fixture CodSpeed records only Apply: @pytest.mark.benchmark(group="schema")
@pytest.mark.parametrize("strawchemy", [lf("strawchemy_postgresql"), lf("strawchemy_sqlite"), lf("strawchemy_mysql")])
-def test_build_user_type(strawchemy: Strawchemy) -> None:
- strawchemy.type(User, include="all", override=True)(type("UserType", (), {}))
+def test_build_user_type(strawchemy: Strawchemy, benchmark: BenchmarkFixture) -> None:
+ benchmark(lambda: strawchemy.type(User, include="all", override=True)(type("UserType", (), {})))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| @pytest.mark.benchmark(group="schema") | ||||||||||||||||||
| @pytest.mark.parametrize("strawchemy", [lf("strawchemy_postgresql"), lf("strawchemy_sqlite"), lf("strawchemy_mysql")]) | ||||||||||||||||||
| def test_build_user_filter(strawchemy: Strawchemy) -> None: | ||||||||||||||||||
| strawchemy.filter(User, include="all", override=True)(type("UserFilter", (), {})) | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+22
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bench not recorded: wrap filter build in benchmark Same issue as above. Apply: @pytest.mark.benchmark(group="schema")
@pytest.mark.parametrize("strawchemy", [lf("strawchemy_postgresql"), lf("strawchemy_sqlite"), lf("strawchemy_mysql")])
-def test_build_user_filter(strawchemy: Strawchemy) -> None:
- strawchemy.filter(User, include="all", override=True)(type("UserFilter", (), {}))
+def test_build_user_filter(strawchemy: Strawchemy, benchmark: BenchmarkFixture) -> None:
+ benchmark(lambda: strawchemy.filter(User, include="all", override=True)(type("UserFilter", (), {})))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| @pytest.mark.benchmark(group="schema") | ||||||||||||||||||
| @pytest.mark.parametrize("strawchemy", [lf("strawchemy_postgresql"), lf("strawchemy_sqlite"), lf("strawchemy_mysql")]) | ||||||||||||||||||
| def test_build_user_create_input(strawchemy: Strawchemy) -> None: | ||||||||||||||||||
| strawchemy.create_input(User, include="all", override=True)(type("UserFilter", (), {})) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @pytest.mark.benchmark(group="schema") | ||||||||||||||||||
| @pytest.mark.parametrize("strawchemy", [lf("strawchemy_postgresql"), lf("strawchemy_sqlite"), lf("strawchemy_mysql")]) | ||||||||||||||||||
| def test_build_user_pk_update_input(strawchemy: Strawchemy) -> None: | ||||||||||||||||||
| strawchemy.create_input(User, include="all", override=True)(type("UserFilter", (), {})) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @pytest.mark.benchmark(group="schema") | ||||||||||||||||||
| @pytest.mark.parametrize("strawchemy", [lf("strawchemy_postgresql"), lf("strawchemy_sqlite"), lf("strawchemy_mysql")]) | ||||||||||||||||||
| def test_build_user_query_field(strawchemy: Strawchemy, benchmark: BenchmarkFixture) -> None: | ||||||||||||||||||
| @strawchemy.filter(User, include="all", override=True) | ||||||||||||||||||
| class UserFilter: ... | ||||||||||||||||||
|
|
||||||||||||||||||
| @strawchemy.order(User, include="all", override=True) | ||||||||||||||||||
| class UserOrderBy: ... | ||||||||||||||||||
|
|
||||||||||||||||||
| @strawchemy.distinct_on(User, include="all", override=True) | ||||||||||||||||||
| class UserDistinctOn: ... | ||||||||||||||||||
|
|
||||||||||||||||||
| benchmark( | ||||||||||||||||||
| lambda: strawchemy.field( | ||||||||||||||||||
| filter_input=UserFilter, | ||||||||||||||||||
| order_by=UserOrderBy, | ||||||||||||||||||
| distinct_on=UserDistinctOn, | ||||||||||||||||||
| repository_type=StrawchemySyncRepository, | ||||||||||||||||||
| ) | ||||||||||||||||||
| ) | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.integration.typing import RawRecordData | ||
| from tests.typing import AnyQueryExecutor | ||
| from tests.utils import maybe_async | ||
|
|
||
|
|
||
| @pytest.mark.benchmark(group="queries") | ||
| async def test_single(any_query: AnyQueryExecutor, raw_users: RawRecordData) -> None: | ||
| await maybe_async( | ||
| any_query( | ||
| """ | ||
| query GetUser($id: Int!) { | ||
| user(id: $id) { | ||
| name | ||
| } | ||
| } | ||
| """, | ||
| {"id": raw_users[0]["id"]}, | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep