Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Test
# ソースコードに変更があるがテストコードが変更されていない場合messageを出す
is_source_changed = !git.modified_files.grep(/^Sources\/.*?\.(h|m|swift)$/).empty? || !git.added_files.grep(/^Sources\/.*?\.(h|m|swift)$/).empty?
is_test_changed = !git.modified_files.grep(/Tests\//).empty?
if is_source_changed && !is_test_changed
message('Tests did not changed🤔')
end
# タイトルに[WIP]が含まれていたらwarningを出す
is_wip = github.pr_title.include? '[WIP]'
if is_wip
warn('Work in progress now...✏️')
end
# 本文に関連するissue番号が無ければwarningを出す
no_issue_number = nil == github.pr_body.match(/\#[0-9]+/)
if no_issue_number
warn('Issue number not found...🙅🏻')
end
# diff size
is_big_pr = git.lines_of_code > 500
if is_big_pr
warn('Too big pull request...💥')
end
# Typo
added_and_modified_files = git.added_files + git.modified_files
added_and_modified_files.each do |file_path|
next unless file_path =~ /.swift$/
stdout, status = Open3.capture2("npx", "cspell", file_path, "-c", "cspell.json")
next if status.success?
stdout.split("\n").each do |line|
next unless matches = /\w.swift:(\d+).*-\sUnknown\sword\s\((\w+)\)/.match(line)
line_number = matches[1].to_i
word = matches[2]
warning = "typo? #{word}"
warn(warning, file: file_path, line: line_number)
end
end
# Xcode Summary
build_report_file = 'build_results.json'
xcode_summary.ignored_files = 'Pods/**'
xcode_summary.ignores_warnings = true
xcode_summary.inline_mode = true
xcode_summary.report build_report_file
# swiftlint
github.dismiss_out_of_range_messages
# swiftlint.config_file = '.swiftlint.yml'
swiftlint.lint_files inline_mode: true
# LGTM
lgtm.check_lgtm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.