-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}") |