mirror of https://github.com/docusealco/docuseal
fix: resolve all lint offenses + add local CI infrastructure (#9)
* fix: resolve all Rubocop and ERBLint offenses Rubocop (16 offenses): - Style/IfUnlessModifier in account_logo_controller - Lint/RedundantSafeNavigation in templates_documents_controller - Layout/LineLength in templates_documents_controller, account_config - Rails/WhereMissing in teams_controller - Rails/WhereExists in send_submitter_reminder_email_job - Style/StringLiterals in create_teams migration - Metrics/* (disabled via inline comments for complex case statements) ERBLint (10 errors): - Void element self-closing tags (img /> → img >) - Layout/ArgumentAlignment in reminder_queue - Style/StringLiterals + Rails/LinkToBlank in navbar_buttons - Layout/BlockAlignment in custom_content mailer - Style/WordArray in role_select * feat: add local CI via Docker and pre-push lint hook - Add docker-compose.ci.yml: lint, brakeman, rspec services - Add Dockerfile.ci: test environment with Ruby, Node, Chromium - Add bin/lint: quick lint-only check - Add bin/ci: full CI suite (lint + brakeman + rspec) - Add .githooks/pre-push: auto-runs linters before push - Update docker-compose.yml: use ghcr.io image instead of local build Setup: git config core.hooksPath .githooks Usage: bin/ci or bin/lint --------- Co-authored-by: Sebastian Noe <sebastian.schneider@boxine.de>pull/681/head
parent
a6fada7a99
commit
00ae27b206
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Pre-push hook: runs linting via Docker before pushing to GitHub.
|
||||
# Ensures Rubocop, ERBLint, and ESLint pass locally.
|
||||
# Skip with: git push --no-verify
|
||||
#
|
||||
# Enable this hook: git config core.hooksPath .githooks
|
||||
set -e
|
||||
|
||||
echo "🔍 Running lint checks before push..."
|
||||
|
||||
docker compose -f docker-compose.ci.yml build lint --quiet 2>/dev/null
|
||||
docker compose -f docker-compose.ci.yml run --rm --no-deps lint
|
||||
|
||||
echo "✅ All lint checks passed."
|
||||
@ -0,0 +1,29 @@
|
||||
FROM ruby:4.0.1-alpine
|
||||
|
||||
ENV RAILS_ENV=test
|
||||
ENV NODE_ENV=test
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk add --no-cache \
|
||||
build-base \
|
||||
git \
|
||||
libpq-dev \
|
||||
yaml-dev \
|
||||
nodejs \
|
||||
yarn \
|
||||
vips-dev \
|
||||
chromium \
|
||||
chromium-chromedriver \
|
||||
&& wget -O pdfium-linux.tgz "https://github.com/docusealco/pdfium-binaries/releases/latest/download/pdfium-linux-musl-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/').tgz" \
|
||||
&& mkdir -p /pdfium && tar -xzf pdfium-linux.tgz -C /pdfium \
|
||||
&& cp /pdfium/lib/libpdfium.so /usr/lib/ \
|
||||
&& rm -rf pdfium-linux.tgz /pdfium
|
||||
|
||||
COPY Gemfile Gemfile.lock ./
|
||||
RUN bundle install --jobs 4 --retry 3
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
COPY . .
|
||||
@ -1,5 +1,5 @@
|
||||
<% if @submission&.account&.logo&.attached? %>
|
||||
<img src="<%= url_for(@submission.account.logo) %>" class="max-h-10 max-w-[160px]" />
|
||||
<img src="<%= url_for(@submission.account.logo) %>" class="max-h-10 max-w-[160px]">
|
||||
<% else %>
|
||||
<%= render 'shared/logo', width: 40, height: 40 %>
|
||||
<% end %>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<div class="form-control">
|
||||
<%= f.label :role, class: 'label' %>
|
||||
<%= f.select :role, [['Admin', 'admin'], ['Editor', 'editor']], { selected: f.object.role }, class: 'base-select' %>
|
||||
<%= f.select :role, [%w[Admin admin], %w[Editor editor]], { selected: f.object.role }, class: 'base-select' %>
|
||||
</div>
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# Run the full CI suite locally via Docker (mirrors GitHub Actions).
|
||||
# Usage: bin/ci [service]
|
||||
# bin/ci — run lint + brakeman + rspec
|
||||
# bin/ci lint — run only linters
|
||||
# bin/ci rspec — run only tests
|
||||
# bin/ci brakeman — run only security scanner
|
||||
set -e
|
||||
|
||||
SERVICE="${1:-}"
|
||||
|
||||
echo "Building CI image (cached)..."
|
||||
docker compose -f docker-compose.ci.yml build --quiet
|
||||
|
||||
if [ -z "$SERVICE" ]; then
|
||||
echo "━━━ Lint ━━━"
|
||||
docker compose -f docker-compose.ci.yml run --rm --no-deps lint
|
||||
echo ""
|
||||
echo "━━━ Brakeman ━━━"
|
||||
docker compose -f docker-compose.ci.yml run --rm --no-deps brakeman
|
||||
echo ""
|
||||
echo "━━━ RSpec ━━━"
|
||||
docker compose -f docker-compose.ci.yml run --rm rspec
|
||||
else
|
||||
docker compose -f docker-compose.ci.yml run --rm "$SERVICE"
|
||||
fi
|
||||
|
||||
docker compose -f docker-compose.ci.yml down --volumes --remove-orphans 2>/dev/null
|
||||
|
||||
echo ""
|
||||
echo "✅ CI passed."
|
||||
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# Run all linters via Docker (same as CI pipeline).
|
||||
# Usage: bin/lint
|
||||
set -e
|
||||
|
||||
echo "Building CI image (cached)..."
|
||||
docker compose -f docker-compose.ci.yml build lint --quiet
|
||||
|
||||
echo "Running Rubocop + ERBLint + ESLint..."
|
||||
docker compose -f docker-compose.ci.yml run --rm --no-deps lint
|
||||
|
||||
echo "✅ All checks passed."
|
||||
@ -0,0 +1,61 @@
|
||||
services:
|
||||
lint:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.ci
|
||||
command: sh -c "bundle exec rubocop && bundle exec erb_lint ./app && yarn eslint 'app/javascript/**/*.js'"
|
||||
volumes:
|
||||
- .:/app:ro
|
||||
- bundle_cache:/usr/local/bundle
|
||||
- node_cache:/app/node_modules
|
||||
tmpfs:
|
||||
- /tmp
|
||||
|
||||
brakeman:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.ci
|
||||
command: bundle exec brakeman -q --exit-on-warn
|
||||
volumes:
|
||||
- .:/app:ro
|
||||
- bundle_cache:/usr/local/bundle
|
||||
- node_cache:/app/node_modules
|
||||
tmpfs:
|
||||
- /tmp
|
||||
|
||||
rspec:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.ci
|
||||
command: sh -c "bundle exec rake db:create db:migrate && bundle exec rake assets:precompile && bundle exec rspec"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
RAILS_ENV: test
|
||||
NODE_ENV: test
|
||||
DATABASE_URL: postgres://postgres:postgres@postgres:5432/docuseal_test
|
||||
volumes:
|
||||
- .:/app
|
||||
- bundle_cache:/usr/local/bundle
|
||||
- node_cache:/app/node_modules
|
||||
tmpfs:
|
||||
- /tmp
|
||||
|
||||
postgres:
|
||||
image: postgres:18
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: docuseal_test
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
tmpfs:
|
||||
- /var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
bundle_cache:
|
||||
node_cache:
|
||||
Loading…
Reference in new issue