diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..6540150 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,44 @@ +name: ๐Ÿงน Lint + +on: + pull_request: + branches: [ "main" ] + types: [opened, synchronize] + + # push: + # Every push if left empty + +jobs: + + lint-code: + runs-on: macos-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Check last commit for skip keyword + run: python workflow_scripts/check_latest_commit_for_skip.py >> $GITHUB_ENV + + - name: โฉ SKIPPING REMAINING STEPS ๐Ÿ‘€ + if: env.should_skip == 'true' + run: exit 0 + + - name: Set up Ruby + if: env.should_skip == 'false' + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3.5' # latest stable as of 2 November 2024 + + - name: Install SwiftLint + if: env.should_skip == 'false' + run: brew install swiftlint + + - name: Lint code using SwiftLint + if: env.should_skip == 'false' + run: swiftlint --strict \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6e6ede7..11d020d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,8 @@ xcuserdata/ *.xcuserdatad *.xcbkptlist *.xcsettings +*.xcscheme *.xcworkspacedata *.DS_Store -*SpotifyConfig.swift +*.build diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..4e30d7b --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,71 @@ +included: + - Sources + +line_length: + warning: 110 + error: 150 + ignores_comments: true + +disabled_rules: + - trailing_whitespace + - trailing_comma + - void_function_in_ternary + +opt_in_rules: + - array_init + - attributes + - closure_end_indentation + - closure_spacing + - collection_alignment + - contains_over_filter_count + - contains_over_filter_is_empty + - contains_over_first_not_nil + - discouraged_object_literal + - empty_count + - empty_string + - empty_xctest_method + - explicit_init + - fallthrough + - file_header + - file_name + - first_where + - flatmap_over_map_reduce + - identical_operands + - joined_default_parameter + - legacy_random + - let_var_whitespace + - last_where + - literal_expression_end_indentation + - lower_acl_than_parent + - modifier_order + - nimble_operator + - nslocalizedstring_key + - number_separator + - object_literal + - operator_usage_whitespace + - overridden_super_call + - override_in_extension + - pattern_matching_keywords + - private_action + - private_outlet + - prohibited_interface_builder + - prohibited_super_call + - quick_discouraged_call + - quick_discouraged_focused_test + - quick_discouraged_pending_test + - reduce_into + - redundant_nil_coalescing + - redundant_type_annotation + - single_test_class + - sorted_first_last + - sorted_imports + - static_operator + - strong_iboutlet + - toggle_bool + - unavailable_function + - unneeded_parentheses_in_closure_argument + - unowned_variable_capture + - untyped_error_in_catch + - vertical_parameter_alignment_on_call + - xct_specific_matcher + - yoda_condition diff --git a/workflow_scripts/check_latest_commit_for_skip.py b/workflow_scripts/check_latest_commit_for_skip.py new file mode 100644 index 0000000..73ce2e4 --- /dev/null +++ b/workflow_scripts/check_latest_commit_for_skip.py @@ -0,0 +1,32 @@ +import subprocess +import sys + +# Define the keyword that should skip the workflow +SKIP_KEYWORDS = ["wip", "skip-ci", "no-build"] + +# Function to get the latest commit message +def get_latest_commit_message(): + try: + # Use subprocess to run the git command and get the output + commit_message = subprocess.check_output( + ["git", "log", "-1", "--pretty=%B"], + text=True + ).strip() + return commit_message + except subprocess.CalledProcessError as e: + print(f"Error getting commit message: {e}") + sys.exit(1) + +# Function to check if the commit message contains any skip keyword +def contains_skip_keyword(commit_message, keywords): + return any(keyword in commit_message for keyword in keywords) + +# Main logic +if __name__ == "__main__": + commit_message = get_latest_commit_message() + + # Output values that can be used in the workflow environment + if contains_skip_keyword(commit_message, SKIP_KEYWORDS): + print(f"should_skip={True}") + else: + print(f"should_skip={False}")