realm / realm/SwiftLint

"Strict" param seems to break pipeline

Open
#5,468 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

Describe the bug

I've setup a Gitlab pipeline that executes the fastlane swiftlint command as follows:

lane :lint do |options|
    swiftlint(
      mode: :lint,
      output_file: "swiftlint.result.html",
      config_file: ".swiftlint.yml",
      strict: true,
      files: options[:swiftLintFiles],
      ignore_exit_status: false,
      raise_if_swiftlint_error: true,
      reporter: "html",
      executable: "Pods/SwiftLint/swiftlint"
    )
  end

The command gets correctly executed as follow:

Pods/SwiftLint/swiftlint lint --strict --config .swiftlint.yml --reporter html --use-script-input-files > swiftlint.result.html
`

##### Complete output when running SwiftLint, including the stack trace and command used

```bash
DEBUG [2024-02-12 10:16:15.58]: All plugins are up to date
bundler: failed to load command: fastlane (/Users/macstudio1-teammobile/.gem/bin/fastlane)
/Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane_core/lib/fastlane_core/ui/interface.rb:141:in `user_error!': [!] SwiftLint finished with errors (exit code: 0) (FastlaneCore::Interface::FastlaneError)
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/actions/swiftlint.rb:238:in `handle_swiftlint_error'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/actions/swiftlint.rb:45:in `rescue in run'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/actions/swiftlint.rb:42:in `run'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:229:in `chdir'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
	from ../../../../../../../../var/folders/88/8x9qkqds4kqd9tp06fspnkh00000gn/T/fl_clone20240212-61397-fa3v5x/CiCd.git/Fastfile:110:in `block (2 levels) in parsing_binding'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/lane.rb:41:in `call'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/lane_manager.rb:46:in `cruise_lane'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/command_line_handler.rb:34:in `handle'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/commands_generator.rb:110:in `block (2 levels) in run'
	from /Users/macstudio1-teammobile/.gem/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
	from /Users/macstudio1-teammobile/.gem/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
	from /Users/macstudio1-teammobile/.gem/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
	from /Users/macstudio1-teammobile/.gem/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/commands_generator.rb:354:in `run'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/commands_generator.rb:43:in `start'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in `take_off'
	from /Users/macstudio1-teammobile/.gem/gems/fastlane-2.219.0/bin/fastlane:23:in `<top (required)>'
	from /Users/macstudio1-teammobile/.gem/bin/fastlane:23:in `load'
	from /Users/macstudio1-teammobile/.gem/bin/fastlane:23:in `<top (required)>'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/cli.rb:492:in `exec'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/cli.rb:28:in `start'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/exe/bundle:37:in `block in <top (required)>'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/macstudio1-teammobile/.gem/gems/bundler-2.4.22/exe/bundle:29:in `<top (required)>'
	from /usr/local/bin/bundle:23:in `load'
	from /usr/local/bin/bundle:23:in `<main>'
Environment
  • SwiftLint version (run swiftlint version to be sure)?
    SwiftLint (0.54.0)

  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    Cocoapods

Ad additional info: the analysis gets correctly executed, the output file created and the warnings are considered as errors, but the pipeline fails with that error.
If I remove the strict param then it doesn't raise an error, but of course the pipeline job completes successfully because the warnings are not considered errors.

Thanks for your help,
Alessandro

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the fastlane swiftlint invocation shown in the issue with strict: true, raise_if_swiftlint_error: true, and an HTML reporter. Start by comparing the reported SwiftLint exit code with the failure raised in fastlane/lib/fastlane/actions/swiftlint.rb. Done means lint violations make the pipeline fail with a meaningful status, without treating exit code 0 as an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
ci-cd, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.