Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin not producing any output in CI on version 0.56.0 and above #5787

Closed
2 tasks done
simone-smith opened this issue Sep 11, 2024 · 2 comments · Fixed by #5789
Closed
2 tasks done

Plugin not producing any output in CI on version 0.56.0 and above #5787

simone-smith opened this issue Sep 11, 2024 · 2 comments · Fixed by #5789
Assignees
Labels
bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains.

Comments

@simone-smith
Copy link

simone-smith commented Sep 11, 2024

New Issue Checklist

Bug Description

We have a GitHub action that runs when a pull request is opened/updated, which calls a script in our repository to run Swiftlint as a Swift package plugin. The script is located at ios-live/GLA/GLA/Scripts/swiftlint_action.sh, and it is called from ios-live/GLA. It contains the following line:

swift package plugin swiftlint --strict --config GLA/.swiftlint.yml GLA/GLA

Our swiftlint.yml configuration file is located at ios-live/GLA/GLA/.swiftlint.yml.

The contents of our Package.swift are as follows:

// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

// swiftlint:disable:next prefixed_toplevel_constant
let package = Package(
    name: "CI-Helpers",
    platforms: [.iOS(.v16)],
    products: [],
    dependencies: [
        .package(url: "https://github.com/realm/SwiftLint.git", from: "0.55.1")
    ],
    targets: []
)

When 0.56.0 was released on 6th August, SwiftLint stopped working properly in CI and stopped producing any output. It doesn’t throw any errors, but just finishes with exit code 0, without any output after downloading all the dependencies:

image

We've tried the following things to resolve the problem:

  • Running the script from different locations/changing the filepaths for the config file and path to lint
  • Running swift package plugin swiftlint --strict --config GLA/.swiftlint.yml GLA/GLA locally - on 0.55.1 this produces results, and on 0.56.0 (and upwards) there is no output.
  • Switching to consume the plugins from the dedicated SwiftLintPlugins repository, as recommended in the README. This didn’t make any difference to the output.
  • Installing via Homebrew instead of the plugin. This worked, but we’d prefer to use the plugin in both our local and CI environments.

Environment

  • SwiftLint version: works on 0.55.1, broken on all versions higher than that
  • Xcode version: 15.4
  • Installation method used: Swift Package Manager
  • Configuration file:
swiftlint.yml
# The list of rules can be found at
# https://realm.github.io/SwiftLint/rule-directory.html

disabled_rules: 
  - force_cast
  - line_length
  - cyclomatic_complexity
  - nesting
  - function_parameter_count
  - multiple_closures_with_trailing_closure

  # phase 3
  - closure_body_length
  - function_body_length
  - type_body_length
  - file_length
  - block_based_kvo
  - notification_center_detachment
  - unused_import # needs analyzer

custom_rules:
  direct_color_rgb_initialisation:
    regex: '(UIColor|\.init)\(red:.*, green:.*, blue:.*\)'
    message: "Color initialised directly instead of using a semantic colour"
  direct_color_hsv_initialisation:
    regex: '(UIColor|\.init)\(hue:.*, saturation:.*, brightness:.*\)'
    message: "Color initialised directly instead of using a semantic colour"
  direct_color_hex_initialisation:
    regex: '(UIColor|\.init)\(hexString:.*\)'
    message: "Color initialised directly instead of using a semantic colour"
  direct_color_white_initialisation:
    regex: '(UIColor|\.init)\(white:.*, alpha:.*\)'
    message: "Color initialised directly instead of using a semantic colour"
  color_named_reference:
    regex: '(UIColor|\.init)\(named:.*\)'
    message: "Color referenced by name instead of using a generated colour"

opt_in_rules:
  - array_init
  - attributes
  - closure_end_indentation
  - closure_spacing
  - collection_alignment
  - contains_over_first_not_nil
  - convenience_type
  - discouraged_object_literal
  - duplicate_imports
  - empty_string
  - empty_xctest_method
  - explicit_init
  - extension_access_modifier
  - first_where
  - function_parameter_count
  - identical_operands
  - implicit_return
  - joined_default_parameter
  - last_where
  - legacy_hashing
  - legacy_random
  - lower_acl_than_parent
  - modifier_order
  - nslocalizedstring_key
  - number_separator
  - operator_usage_whitespace
  - overridden_super_call
  - pattern_matching_keywords
  - prefixed_toplevel_constant
  - private_action
  - prohibited_super_call
  - redundant_nil_coalescing
  - redundant_objc_attribute
  - redundant_type_annotation 
  - single_test_class
  - sorted_first_last
  - static_operator
  - strong_iboutlet
  - switch_case_on_newline
  - toggle_bool
  - trailing_closure
  - type_body_length
  - unavailable_function
  - unneeded_parentheses_in_closure_argument
  - untyped_error_in_catch
  - unused_control_flow_label
  - unused_setter_value
  - vertical_parameter_alignment_on_call
  - vertical_whitespace_closing_braces
  - yoda_condition
  - expiring_todo
  - multiline_arguments
  - multiline_arguments_brackets
  - multiline_parameters
  - multiline_parameters_brackets

excluded:
  - GLATests
  - Scripts
  - vendor
  - SwiftPackages
  - GLA/Legacy/SVProgressHUD
  - GLA/GXW/Dependencies
  - Frameworks/BlueprintModels/Sources/BlueprintModels/Protobuf/blueprint.pb.swift
  - Frameworks/MyGuardian/.build/checkouts

# configuration options
number_separator:
  minimum_length: 5
  
identifier_name:
  excluded:
    - id
    - x
    - y
  max_length: 50
  min_length: 2

type_name:
  min_length: 2

trailing_closure:
  only_single_muted_parameter: true
@SimplyDanny SimplyDanny added bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains. labels Sep 11, 2024
@SimplyDanny SimplyDanny self-assigned this Sep 11, 2024
@SimplyDanny
Copy link
Collaborator

SimplyDanny commented Sep 11, 2024

This is caused by the fact that your list of targets is empty. The current implementation doesn't account for this special case. I've prepared a fix in #5789 which runs the plugin in the package directory if no targets can be found. That should match the behavior of 0.55.1 and earlier.

@simone-smith
Copy link
Author

Thanks for addressing this so quickly! I'll keep an eye out for the next release so we can get back up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants