Skip to content

Commit 5a46f13

Browse files
authored
Merge pull request #33 from teams-notifier/feat/fingerprint-optim-and-tests
feat: refactor fingerprint (DB UPDATE REQUIRED) and add tests
2 parents b93a576 + c41f31a commit 5a46f13

31 files changed

Lines changed: 7760 additions & 468 deletions

.env.example

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Logging Configuration
2+
# LOG_FORMAT: "json" = force JSON, "line" = force line format, "auto" = TTY detection (default)
3+
LOG_FORMAT=auto
4+
5+
# LOG_LEVEL: DEBUG, INFO, WARNING, ERROR, CRITICAL (default: INFO)
6+
LOG_LEVEL=INFO
7+
8+
# Database
9+
# pragma: allowlist nextline secret
10+
DATABASE_URL=postgresql://user:password@localhost:5432/gitlab_mr_api?options=-c%20search_path%3Dgitlab_mr_api
11+
12+
# Activity API
13+
ACTIVITY_API=http://localhost:3981/
14+
15+
# GitLab Tokens (comma-separated)
16+
GITLAB_TOKENS=token1,token2
17+
18+
# OpenTelemetry (optional)
19+
OTEL_PYTHON_EXCLUDED_URLS=healthz
20+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v6
13+
- uses: actions/setup-python@v6
14+
with:
15+
python-version: "3.12"
16+
- uses: pre-commit/action@v3.0.1
17+
- uses: astral-sh/setup-uv@v7
18+
- run: uv venv
19+
- run: uv pip install -r requirements.txt -r requirements-dev.txt
20+
- run: .venv/bin/pytest --cov

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
__pycache__
44
misc
55
.vscode
6+
.coverage
7+
.pytest_cache
8+
*.pyc

.pre-commit-config.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ repos:
55
rev: 24.10.0
66
hooks:
77
- id: black
8-
args: [--safe, --line-length=110]
98

109
- repo: https://github.com/pre-commit/pre-commit-hooks
1110
rev: v5.0.0
@@ -50,20 +49,7 @@ repos:
5049
rev: v1.11.2
5150
hooks:
5251
- id: mypy
53-
# files: ^*.py
5452
additional_dependencies:
5553
- pydantic
5654
- types-PyYAML
5755
- types-python-dateutil
58-
args:
59-
- --check-untyped-defs
60-
- --disallow-any-generics
61-
- --ignore-missing-imports
62-
- --no-implicit-optional
63-
- --show-error-codes
64-
- --strict-equality
65-
- --warn-redundant-casts
66-
- --warn-return-any
67-
- --warn-unreachable
68-
- --warn-unused-configs
69-
- --no-implicit-reexport
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- migrate:up
2+
3+
-- Add fingerprint column to message ref table
4+
ALTER TABLE gitlab_mr_api.merge_request_message_ref
5+
ADD COLUMN last_processed_fingerprint VARCHAR(64);
6+
7+
-- Drop global fingerprint table (no longer needed)
8+
DROP TABLE gitlab_mr_api.webhook_fingerprint;
9+
10+
-- migrate:down
11+
12+
-- Recreate global fingerprint table
13+
CREATE TABLE gitlab_mr_api.webhook_fingerprint (
14+
fingerprint character varying(64) NOT NULL,
15+
processed_at timestamp with time zone DEFAULT now() NOT NULL
16+
);
17+
18+
ALTER TABLE ONLY gitlab_mr_api.webhook_fingerprint
19+
ADD CONSTRAINT webhook_fingerprint_pkey PRIMARY KEY (fingerprint);
20+
21+
-- Remove fingerprint column from message ref
22+
ALTER TABLE gitlab_mr_api.merge_request_message_ref
23+
DROP COLUMN last_processed_fingerprint;

db/schema.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ CREATE TABLE gitlab_mr_api.merge_request_message_ref (
8181
message_id uuid,
8282
failure jsonb,
8383
created_at timestamp with time zone DEFAULT now() NOT NULL,
84-
updated_at timestamp with time zone
84+
updated_at timestamp with time zone,
85+
last_processed_fingerprint character varying(64)
8586
);
8687

8788

@@ -226,6 +227,7 @@ ALTER TABLE ONLY gitlab_mr_api.msg_to_delete
226227
ADD CONSTRAINT msg_to_delete_pkey PRIMARY KEY (msg_to_delete_id);
227228

228229

230+
229231
--
230232
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: gitlab_mr_api; Owner: -
231233
--

0 commit comments

Comments
 (0)