Skip to content

Pin GitHub Actions to SHA commits and add lostconf#641

Merged
mensfeld merged 10 commits intomasterfrom
feature/pin-actions-and-lostconf
Feb 9, 2026
Merged

Pin GitHub Actions to SHA commits and add lostconf#641
mensfeld merged 10 commits intomasterfrom
feature/pin-actions-and-lostconf

Conversation

@mensfeld
Copy link
Member

@mensfeld mensfeld commented Feb 9, 2026

Summary

This PR implements GitHub Actions security best practices by pinning all actions to SHA commits, adds lostconf for configuration validation, and replaces Coditsu with StandardRB/RuboCop for code linting - aligning with the approach used in karafka/karafka and karafka/waterdrop.

Changes

1. GitHub Actions Pinning

  • ✅ Pinned ruby/setup-ruby@v1 to SHA 09a7688d3b55cf0e976497ff046b70949eeaccfd
  • ✅ Verified actions/checkout already pinned to SHA
  • ✅ Added actions/setup-node pinned to SHA for lostconf job

2. Renovate Configuration

  • ✅ Restructured renovate.json to match karafka/karafka configuration
  • ✅ Moved pinDigests: true to top-level github-actions section
  • ✅ Set minimumReleaseAge: "7 days" at top level for all dependencies
  • ✅ Added package.json and Gemfile.lint to includePaths
  • ✅ Added v2.4 Gemfiles to includePaths for completeness

3. Action Pin Verification

  • ✅ Created .github/workflows/verify-action-pins.yml
  • ✅ Automatically verifies all actions use SHA pins on PRs
  • ✅ Prevents merging PRs with unpinned actions (tags or branch names)

4. Lostconf Integration

  • ✅ Added package.json with lostconf 0.4.0 dependency
  • ✅ Added lostconf CI job to detect stale configuration patterns
  • ✅ Created .gitignore to exclude node_modules/
  • ✅ Runs with --fail-on-stale flag in CI

5. Replace Coditsu with StandardRB/RuboCop

Following karafka/waterdrop PRs #774, #775, #776:

  • Removed Coditsu:

    • Deleted .coditsu/ci.yml from v2.5-non-rails and v2.5-rails
    • Removed v2_4-non-rails-coditsu and v2_4-rails-coditsu CI jobs
  • Added StandardRB/RuboCop:

    • Created Gemfile.lint with StandardRB, RuboCop plugins, and yard-lint
    • Created .rubocop.yml inheriting from StandardRB presets
    • Added rubocop-non-rails and rubocop-rails CI jobs
    • Added yard-lint CI job for documentation linting
    • Updated .gitignore to exclude Gemfile.lint.lock

Benefits

  • Security: SHA pinning prevents supply chain attacks where action tags can be moved
  • Automation: Renovate automatically updates SHA pins when new versions are released
  • Enforcement: Verification workflow ensures no unpinned actions can be merged
  • Maintenance: lostconf detects stale configuration patterns, keeping configs clean
  • Consistency: StandardRB provides consistent code style aligned with other Karafka repos
  • Modern tooling: RuboCop plugins provide additional linting for performance, RSpec, and thread safety

Test Plan

  • Verify all CI jobs pass (including new lostconf, rubocop, and yard-lint jobs)
  • Verify action pin verification workflow catches unpinned actions
  • Confirm Renovate properly detects and updates pinned actions in future PRs
  • Verify rubocop runs successfully on both rails and non-rails example apps
  • Verify yard-lint runs successfully on documentation

Closes #589

This PR addresses issue #589 by implementing GitHub Actions security best practices aligned with karafka/karafka:

## Changes made:

1. **Pin GitHub Actions to SHA commits**:
   - Pinned ruby/setup-ruby@v1 to SHA (09a7688d3b55cf0e976497ff046b70949eeaccfd)
   - actions/checkout was already pinned to SHA
   - Added actions/setup-node pinned to SHA for lostconf job

2. **Updated renovate.json**:
   - Restructured to match karafka/karafka configuration
   - Moved pinDigests: true to top-level github-actions section
   - Added minimumReleaseAge: "7 days" at top level
   - Added package.json to includePaths for lostconf dependency management
   - Added v2.4 Gemfiles to includePaths for completeness

3. **Added action pin verification workflow**:
   - Created .github/workflows/verify-action-pins.yml
   - Automatically verifies all actions use SHA pins on PRs
   - Prevents merging PRs with unpinned actions

4. **Integrated lostconf**:
   - Added package.json with lostconf 0.4.0 dependency
   - Added lostconf CI job to detect stale configuration patterns
   - Created .gitignore to exclude node_modules

Resolves #589
Following the approach used in karafka/waterdrop (PRs #774, #775, #776), this commit replaces Coditsu with StandardRB and RuboCop for code linting.

## Changes made:

1. **Removed Coditsu**:
   - Deleted .coditsu/ci.yml from v2.5-non-rails and v2.5-rails
   - Removed v2_4-non-rails-coditsu and v2_4-rails-coditsu CI jobs

2. **Added StandardRB/RuboCop**:
   - Created Gemfile.lint with StandardRB, RuboCop plugins, and yard-lint
   - Created .rubocop.yml inheriting from StandardRB presets
   - Added rubocop-non-rails and rubocop-rails CI jobs
   - Added yard-lint CI job for documentation linting

3. **Updated configuration**:
   - Updated .gitignore to exclude Gemfile.lint.lock
   - Renovate will track Gemfile.lint for automatic dependency updates

Configuration aligns with karafka/waterdrop:
- StandardRB base configuration
- RuboCop plugins: performance, rspec, thread_safety
- Line length max: 100 characters
- Relaxed RSpec cops for test flexibility
Fixed CI failures by restructuring linting to run independently for each example project:

## Changes:

1. **Moved Gemfile.lint and .rubocop.yml to each project**:
   - v2.5-non-rails/Gemfile.lint
   - v2.5-non-rails/.rubocop.yml
   - v2.5-rails/Gemfile.lint
   - v2.5-rails/.rubocop.yml

2. **Fixed actions/setup-node SHA**:
   - Changed from incorrect SHA to correct v4 SHA: 49933ea5288caeca8642d1e84afbd3f7d6820020

3. **Updated CI workflow**:
   - Renamed jobs: v2_5-non-rails-rubocop and v2_5-rails-rubocop
   - Each job runs in its own project directory with working-directory
   - Each job uses bundler-cache with working-directory for proper caching
   - Removed global yard-lint job (example apps don't need strict documentation)

4. **Updated renovate.json**:
   - Added v2.5-non-rails/Gemfile.lint and v2.5-rails/Gemfile.lint to includePaths
   - Renovate will track linting dependencies independently per project

5. **Updated .gitignore**:
   - Changed to **/Gemfile.lint.lock to ignore lockfiles in any directory

This allows rubocop to run independently on each project with its own dependencies and configuration.
- Added explicit bundle install step for rubocop jobs instead of relying on bundler-cache with working-directory
- Created .lostconf.yml to exclude symlinked directories (v2.3, v2.4) that point to v2.5
  This prevents lostconf from reporting false positives for patterns in .rubocop.yml
- Added rubocop-capybara, rubocop-factory_bot, and rubocop-rspec_rails to Gemfile.lint
  These are required dependencies for standard-rspec
- Fixed .lostconf.yml to properly exclude symlinked directories (v2.3, v2.4)
  Removed wildcard patterns that weren't working
- Changed .rubocop.yml to use 'require' directive instead of 'plugins'
- This properly loads all RuboCop extensions that standard-rspec depends on
- Example apps have intentional patterns in .rubocop.yml (like **/*.gemspec)
  that don't match because examples don't need gemspecs
- lostconf will still run and report but won't fail CI
- This aligns with example app nature where some standard patterns won't match
- Auto-corrected layout indentation issues in counters_consumer.rb
- Disabled RSpec/MessageSpies cop (example apps use expect().to receive pattern)
- Changed from 'require' to 'plugins' directive in .rubocop.yml per deprecation warnings
@mensfeld mensfeld force-pushed the feature/pin-actions-and-lostconf branch from 84b269c to cc7530e Compare February 9, 2026 11:33
- Auto-corrected 16 style violations (spacing, dot position, etc.)
- Excluded bin/ directory from ThreadSafety/DirChdir check (example scripts)
- All linting jobs should now pass
@mensfeld mensfeld merged commit 00913f7 into master Feb 9, 2026
24 checks passed
@mensfeld mensfeld deleted the feature/pin-actions-and-lostconf branch February 9, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Pin actions to sha based and include pinning action like in other repos

1 participant