Skip to content
Latchkey

Linting workflow (rubocop/rubocop)

The Linting workflow from rubocop/rubocop, explained and optimized by Latchkey.

B

CI health: B - good

Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: rubocop/rubocop.github/workflows/linting.ymlLicense MITView source

What it does

This is the Linting workflow from the rubocop/rubocop repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Linting
on:
  push:
    branches:
      - master
  pull_request:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  lint-ruby:
    name: Ruby
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ruby # Latest stable CRuby version
          bundler-cache: true
      - name: internal_investigation
        run: bundle exec rake internal_investigation

  lint-ruby-without-bundler:
    name: Ruby without Bundler
    runs-on: ubuntu-latest
    steps:
      # Install Ruby first so bundler installs no gems
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ruby # Latest stable CRuby version
      - uses: actions/checkout@v7
      - name: Package and install RuboCop locally
        run: |
          gem build
          gem install ./rubocop-*.gem --no-document
          gem install rubocop-performance rubocop-rake rubocop-rspec --no-document
      - name: internal_investigation
        run: rubocop
      # Regression test for https://github.com/rubocop/rubocop/issues/13867
      - name: internal_investigation with require
        run: |
          echo "require: rubocop-rspec" > .rubocop.yml
          # This should never give any offense, just testing it doesn't error
          rubocop Gemfile --only RSpec/AnyInstance

  lint-yaml:
    permissions:
      contents: read  # for actions/checkout to fetch code
      pull-requests: write  # for karancode/yamllint-github-action to post comments on PRs
    name: Yaml
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - name: Yamllint
        uses: karancode/yamllint-github-action@v3.0.0
        with:
          yamllint_strict: true
          yamllint_format: parsable
          yamllint_comment: true
        env:
          GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Linting
on:
  push:
    branches:
      - master
  pull_request:
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true
 
jobs:
  lint-ruby:
    timeout-minutes: 30
    name: Ruby
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ruby # Latest stable CRuby version
          bundler-cache: true
      - name: internal_investigation
        run: bundle exec rake internal_investigation
 
  lint-ruby-without-bundler:
    timeout-minutes: 30
    name: Ruby without Bundler
    runs-on: latchkey-small
    steps:
      # Install Ruby first so bundler installs no gems
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ruby # Latest stable CRuby version
      - uses: actions/checkout@v7
      - name: Package and install RuboCop locally
        run: |
          gem build
          gem install ./rubocop-*.gem --no-document
          gem install rubocop-performance rubocop-rake rubocop-rspec --no-document
      - name: internal_investigation
        run: rubocop
      # Regression test for https://github.com/rubocop/rubocop/issues/13867
      - name: internal_investigation with require
        run: |
          echo "require: rubocop-rspec" > .rubocop.yml
          # This should never give any offense, just testing it doesn't error
          rubocop Gemfile --only RSpec/AnyInstance
 
  lint-yaml:
    timeout-minutes: 30
    permissions:
      contents: read  # for actions/checkout to fetch code
      pull-requests: write  # for karancode/yamllint-github-action to post comments on PRs
    name: Yaml
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7
      - name: Yamllint
        uses: karancode/yamllint-github-action@v3.0.0
        with:
          yamllint_strict: true
          yamllint_format: parsable
          yamllint_comment: true
        env:
          GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 

What changed

2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

This workflow runs 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow