From 9c13400afe2460e14ec132a650f80682fc9535dc Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:59:14 +0200 Subject: [PATCH 1/4] :wrench: :arrow_up: add better tooling & pre-commit hook --- .github/workflows/_test-cli.yml | 2 +- .github/workflows/_test-smoke.yml | 1 - .pre-commit-config.yaml | 36 +++++++++++++++++++ CHANGELOG.md | 6 ++-- CONTRIBUTING.md | 17 +++++++++ README.md | 2 +- Steepfile | 1 - docs/code_samples/default_async.txt | 1 - docs/code_samples/v2_crop.txt | 2 +- docs/code_samples/workflow_polling.txt | 1 - lib/mindee/http/.rubocop.yml | 1 - lib/mindee/v1/http/.rubocop.yml | 1 - lib/mindee/v2/http/.rubocop.yml | 1 - mindee.gemspec | 1 + sig/custom/marcel.rbs | 2 +- sig/custom/net_http.rbs | 2 +- sig/custom/origami.rbs | 2 +- sig/mindee.rbs | 1 - .../v1/parsing/common/extras/rag_extra.rbs | 2 +- sig/mindee/v2/parsing/inference_file.rbs | 1 - 20 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/_test-cli.yml b/.github/workflows/_test-cli.yml index ff7218645..2a2793faf 100644 --- a/.github/workflows/_test-cli.yml +++ b/.github/workflows/_test-cli.yml @@ -40,7 +40,7 @@ jobs: - name: Tests V2 CLI run: | - ./spec/test_v2_cli.sh ./spec/data/file_types/pdf/blank_1.pdf ${{ matrix.os_config.rid }} + ./spec/test_v2_cli.sh ./spec/data/file_types/pdf/blank_1.pdf ${{ matrix.os_config.rid }} - name: Tests V1 CLI run: | diff --git a/.github/workflows/_test-smoke.yml b/.github/workflows/_test-smoke.yml index b177faaa1..a22fa8c68 100644 --- a/.github/workflows/_test-smoke.yml +++ b/.github/workflows/_test-smoke.yml @@ -52,4 +52,3 @@ jobs: MINDEE_LOG_LEVEL: DEBUG run: | ./spec/test_v1_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }} - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..e013967a1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + args: ["--maxkb=1024"] + + - repo: https://github.com/gitleaks/gitleaks + rev: v8.30.0 + hooks: + - id: gitleaks + exclude: ^(spec/data/|docs/code_samples/|local_test/) + + - repo: local + hooks: + - id: rubocop + name: RuboCop + entry: bundle exec rubocop --force-exclusion --no-server + language: system + pass_filenames: false + - id: steep + name: Steep + entry: bundle exec steep check + language: system + pass_filenames: false + stages: [pre-commit, pre-push] + - id: bundle-audit + name: Bundle Audit + entry: bundle exec bundle-audit check + language: system + pass_filenames: false + stages: [pre-commit, pre-push] diff --git a/CHANGELOG.md b/CHANGELOG.md index fc2cc9737..50a068ac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ * :recycle: make polling follow API urls instead of re-constructing them * :sparkles: add support for generic product accessors in V2 * :recycle: add proper tests for ruby 4 -### Fixes -* :recycle: fix tests file paths +### Fixes +* :recycle: fix tests file paths ## v4.12.0 - 2026-02-25 @@ -58,7 +58,7 @@ ## v4.7.0 - 2025-09-18 -Including RC changes and fixes. +Including RC changes and fixes. ### Changes * :sparkles: add support for V2 Mindee API * :sparkles: add missing accessors for PDF fixing options in `LocalInputSource` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f52fa7744..776fa9dd0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,3 +88,20 @@ Examples: We keep our code base consistent and expect Ruby code to adhere to our Rubocop styleguide, see the `.rubocop` file. + +### Local Quality Checks + +We use [`pre-commit`](https://pre-commit.com/) hooks to run quality and security checks before +changes are pushed: + +1. Install `pre-commit`, either using `pip` or `brew`: + - `pip install pre-commit` + - `brew install pre-commit` +2. Install project hooks: + - `pre-commit install` + - `pre-commit install --hook-type pre-push` + +Run hooks manually: + +* `pre-commit run --all-files` +* `pre-commit run --all-files --hook-stage pre-push` diff --git a/README.md b/README.md index 0668e778a..b49077b82 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,4 @@ Consult the ### License Copyright © Mindee -Available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). \ No newline at end of file +Available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). diff --git a/Steepfile b/Steepfile index 73b80857a..d81fac414 100644 --- a/Steepfile +++ b/Steepfile @@ -28,4 +28,3 @@ target :lib do configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default) end - diff --git a/docs/code_samples/default_async.txt b/docs/code_samples/default_async.txt index af98b8ba0..3cc9af5f2 100644 --- a/docs/code_samples/default_async.txt +++ b/docs/code_samples/default_async.txt @@ -27,4 +27,3 @@ result = mindee_client.parse( # Print a full summary of the parsed data in RST format puts result.document - diff --git a/docs/code_samples/v2_crop.txt b/docs/code_samples/v2_crop.txt index fa0c41019..e5760cfc7 100644 --- a/docs/code_samples/v2_crop.txt +++ b/docs/code_samples/v2_crop.txt @@ -27,4 +27,4 @@ response = mindee_client.enqueue_and_get_result( ) # Access the result crops -puts response.inference.result.crops \ No newline at end of file +puts response.inference.result.crops diff --git a/docs/code_samples/workflow_polling.txt b/docs/code_samples/workflow_polling.txt index ede57dd63..20e20135e 100644 --- a/docs/code_samples/workflow_polling.txt +++ b/docs/code_samples/workflow_polling.txt @@ -33,4 +33,3 @@ result = mindee_client.parse( # Print a full summary of the parsed data in RST format puts result.document - diff --git a/lib/mindee/http/.rubocop.yml b/lib/mindee/http/.rubocop.yml index edbfc9a92..fa1e6d506 100644 --- a/lib/mindee/http/.rubocop.yml +++ b/lib/mindee/http/.rubocop.yml @@ -5,4 +5,3 @@ Metrics/CyclomaticComplexity: Metrics/PerceivedComplexity: Max: 10 - diff --git a/lib/mindee/v1/http/.rubocop.yml b/lib/mindee/v1/http/.rubocop.yml index 3a07f430e..acea271ec 100644 --- a/lib/mindee/v1/http/.rubocop.yml +++ b/lib/mindee/v1/http/.rubocop.yml @@ -5,4 +5,3 @@ Metrics/CyclomaticComplexity: Metrics/PerceivedComplexity: Max: 10 - diff --git a/lib/mindee/v2/http/.rubocop.yml b/lib/mindee/v2/http/.rubocop.yml index 3a07f430e..acea271ec 100644 --- a/lib/mindee/v2/http/.rubocop.yml +++ b/lib/mindee/v2/http/.rubocop.yml @@ -5,4 +5,3 @@ Metrics/CyclomaticComplexity: Metrics/PerceivedComplexity: Max: 10 - diff --git a/mindee.gemspec b/mindee.gemspec index af6cc1bc9..e42488ecf 100644 --- a/mindee.gemspec +++ b/mindee.gemspec @@ -30,6 +30,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = Gem::Requirement.new('>= 3.0') spec.add_dependency 'base64', '~> 0.1' + spec.add_dependency 'bundle-audit', '~> 0.2.0' spec.add_dependency 'marcel', '~> 1.0' spec.add_dependency 'mini_magick', '>= 4', '< 6' spec.add_dependency 'origamindee', '~> 4.0' diff --git a/sig/custom/marcel.rbs b/sig/custom/marcel.rbs index d78347361..dd147354a 100644 --- a/sig/custom/marcel.rbs +++ b/sig/custom/marcel.rbs @@ -1,3 +1,3 @@ module Marcel MimeType: untyped -end \ No newline at end of file +end diff --git a/sig/custom/net_http.rbs b/sig/custom/net_http.rbs index 9d24bc515..c53bad3b8 100644 --- a/sig/custom/net_http.rbs +++ b/sig/custom/net_http.rbs @@ -40,4 +40,4 @@ module Net def body: -> untyped def code: -> String? end -end \ No newline at end of file +end diff --git a/sig/custom/origami.rbs b/sig/custom/origami.rbs index f203f39bb..4a71b78b3 100644 --- a/sig/custom/origami.rbs +++ b/sig/custom/origami.rbs @@ -56,4 +56,4 @@ module Origami def data= : (String | StringIO) -> void def dictionary : -> Hash[Symbol, untyped] end -end \ No newline at end of file +end diff --git a/sig/mindee.rbs b/sig/mindee.rbs index b3b5d79c0..c33abc741 100644 --- a/sig/mindee.rbs +++ b/sig/mindee.rbs @@ -60,4 +60,3 @@ module Mindee end end end - diff --git a/sig/mindee/v1/parsing/common/extras/rag_extra.rbs b/sig/mindee/v1/parsing/common/extras/rag_extra.rbs index f99b33817..b86991139 100644 --- a/sig/mindee/v1/parsing/common/extras/rag_extra.rbs +++ b/sig/mindee/v1/parsing/common/extras/rag_extra.rbs @@ -16,4 +16,4 @@ module Mindee end end end -end \ No newline at end of file +end diff --git a/sig/mindee/v2/parsing/inference_file.rbs b/sig/mindee/v2/parsing/inference_file.rbs index 34f5afeaf..310392d59 100644 --- a/sig/mindee/v2/parsing/inference_file.rbs +++ b/sig/mindee/v2/parsing/inference_file.rbs @@ -15,4 +15,3 @@ module Mindee end end end - From c27685a418d88d53043584520b24332b6608f74b Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 31 Mar 2026 16:03:59 +0200 Subject: [PATCH 2/4] add pre-commit run to static check --- .github/workflows/_static-analysis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/_static-analysis.yml b/.github/workflows/_static-analysis.yml index 9d9eabcc2..6b2a1ccf6 100644 --- a/.github/workflows/_static-analysis.yml +++ b/.github/workflows/_static-analysis.yml @@ -22,6 +22,22 @@ jobs: ruby-version: "3.0.0" bundler-cache: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Install pre-commit + run: | + python -m pip install --upgrade pip + python -m pip install pre-commit + + - name: Run pre-commit checks (security + hygiene) + env: + SKIP: rubocop,steep + run: | + pre-commit run --all-files --show-diff-on-failure + - name: Analyse the code with Rubocop run: | bundle install From 2bc72b90eb724035ac19929bd92cd967e570756b Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 31 Mar 2026 17:32:07 +0200 Subject: [PATCH 3/4] add editorconfig --- .editorconfig | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..ded085439 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,27 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[*.{rb,rake,gemspec,rbs,ru}] +indent_style = space +indent_size = 2 + +[*.{yml,yaml,json}] +indent_style = space +indent_size = 2 + +[*.sh] +indent_style = space +indent_size = 2 + +[Makefile] +indent_style = tab From 564818b7557a88722cdb1c09d44e1f87a1a40ea4 Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 31 Mar 2026 17:47:26 +0200 Subject: [PATCH 4/4] fix .editorconfig --- .editorconfig | 3 --- 1 file changed, 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index ded085439..3833f4606 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,9 +5,6 @@ charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true -indent_style = space -indent_size = 2 - [*.md] trim_trailing_whitespace = false