From 34f83bfc4eb8087182fa50eb2e665380f1fdf9af Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Wed, 22 Jul 2026 15:57:47 +0200 Subject: [PATCH] :wrench: switching over from pre-commit to ruby-only solution --- .git-hooks/pre_commit/gitleaks.rb | 19 +++++++++++ .github/workflows/_static-analysis.yml | 31 +++++------------ .overcommit.yml | 46 ++++++++++++++++++++++++++ .pre-commit-config.yaml | 36 -------------------- mindee.gemspec | 1 + 5 files changed, 74 insertions(+), 59 deletions(-) create mode 100644 .git-hooks/pre_commit/gitleaks.rb create mode 100644 .overcommit.yml delete mode 100644 .pre-commit-config.yaml diff --git a/.git-hooks/pre_commit/gitleaks.rb b/.git-hooks/pre_commit/gitleaks.rb new file mode 100644 index 000000000..d3e1d7591 --- /dev/null +++ b/.git-hooks/pre_commit/gitleaks.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Overcommit + module Hook + module PreCommit + # Local script to run gitleaks + class Gitleaks < Base + # Runs the command. + def run + result = execute(['gitleaks', 'git', '--staged', '-v', '.']) + + return :pass if result.success? + + [:fail, result.stdout + result.stderr] + end + end + end + end +end diff --git a/.github/workflows/_static-analysis.yml b/.github/workflows/_static-analysis.yml index d35199286..190010bbd 100644 --- a/.github/workflows/_static-analysis.yml +++ b/.github/workflows/_static-analysis.yml @@ -22,31 +22,16 @@ jobs: ruby-version: "3.2.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) + - name: Run Gitleaks + uses: gitleaks/gitleaks-action@v2 env: - SKIP: rubocop,steep - run: | - pre-commit run --all-files --show-diff-on-failure + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITLEAKS_EXCLUDE: "^(spec/data/|docs/code_samples/|local_test/)" - name: Analyse the code with Rubocop run: | bundle install - bundle exec rubocop ./ - - - name: Attempt to generate the documentation - run: | - bundle exec rake doc - - - name: Check types using Steep - run: | - bundle exec steep check + bundle exec overcommit --install + bundle exec overcommit --sign + bundle exec overcommit --sign pre-commit + SKIP=Gitleaks bundle exec overcommit --run diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 000000000..5e40e126b --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,46 @@ +PreCommit: + MergeConflicts: + enabled: true + + YamlSyntax: + enabled: true + + TrailingWhitespace: + enabled: true + + FileSize: + enabled: true + byte_limit: 1048576 + + RuboCop: + enabled: true + required_executable: 'bundle' + command: ['bundle', 'exec', 'rubocop', '--force-exclusion', '--no-server'] + + CustomScript: + enabled: true + description: 'Run Steep type checking' + required_executable: 'bundle' + command: ['bundle', 'exec', 'steep', 'check'] + + Gitleaks: + enabled: true + required_executable: 'gitleaks' + CommitMsg: + enabled: false + CapitalizedSubject: + enabled: false + TextWidth: + enabled: false + TrailingPeriod: + enabled: false + SingleLineSubject: + enabled: false + EmptyMessage: + enabled: false + +PrePush: + BundleAudit: + enabled: true + required_executable: 'bundle' + command: ['sh', '-c', 'bundle exec bundle-audit check'] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index e013967a1..000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,36 +0,0 @@ -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/mindee.gemspec b/mindee.gemspec index ed46b531c..b5f84741f 100644 --- a/mindee.gemspec +++ b/mindee.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'pdf-reader', '~> 2.15' spec.add_development_dependency 'bundle-audit', '~> 0.2.0' + spec.add_development_dependency 'overcommit', '~> 0.71' spec.add_development_dependency 'rbs', '~> 3.10' spec.add_development_dependency 'rubocop', '~> 1.86' spec.add_development_dependency 'steep', '~> 1.10'