Skip to content

Commit

Permalink
[#2] Use one Dangerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Sep 14, 2022
1 parent 7d89ce8 commit c269a58
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ jobs:
gem --version
bundler --version
- name: Run Android Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec danger

- name: Cache Pods
uses: actions/cache@v2
id: cocoapodCache
Expand All @@ -65,8 +60,7 @@ jobs:
working-directory: ./iosApp
run: bundle exec pod install

- name: Run iOS Danger
working-directory: ./iosApp
- name: Run Android Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec danger
run: bundle exec danger
17 changes: 17 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
warn("PR is classed as Work in Progress") if github.pr_title.include? "WIP"

Expand Down Expand Up @@ -37,3 +38,19 @@ Dir[jacoco_dir].each do |file_name|
# or if any modified file's coverage is under 95%
shroud.report file_name, 80, 95, false
end

# SwiftFormat
swiftformat.binary_path = 'iosApp/Pods/SwiftFormat/CommandLineTool/swiftformat'
swiftformat.exclude = %w(iosApp/Pods/** **/*generated.swift)
swiftformat.check_format

# Swiftlint
swiftlint.binary_path = 'iosApp/Pods/SwiftLint/swiftlint'
swiftlint.config_file = 'iosApp/.swiftlint.yml'
swiftlint.max_num_violations = 20
swiftlint.lint_files(
inline_mode: true,
fail_on_error: true,
additional_swiftlint_args: '--strict'
)

16 changes: 5 additions & 11 deletions iosApp/Dangerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
# frozen_string_literal: true

require './fastlane/Constants/Constants'

# Warn when there is a big PR
warn("This pull request is quite big (#{git.lines_of_code} lines changed), please consider splitting it into multiple pull requests.") if git.lines_of_code > 500

# Warn to encourage that labels should have been used on the PR
warn("This pull request doesn't have any labels, please consider to add labels to this pull request.") if github.pr_labels.empty?
require 'ios/fastlane/Constants/Constants'

# SwiftFormat
swiftformat.binary_path = './Pods/SwiftFormat/CommandLineTool/swiftformat'
swiftformat.exclude = %w(Pods/** **/*generated.swift)
swiftformat.check_format

# Swiftlint
swiftlint.binary_path = './Pods/SwiftLint/swiftlint'
swiftlint.config_file = '.swiftlint.yml'
swiftlint.binary_path = 'ios/Pods/SwiftLint/swiftlint'
swiftlint.config_file = 'ios/.swiftlint.yml'
swiftlint.max_num_violations = 20
swiftlint.lint_files(
inline_mode: true,
fail_on_error: true,
additional_swiftlint_args: '--strict'
)

xcresultPath = "#{Constants.TEST_OUTPUT_DIRECTORY_PATH}/#{Constants.TESTS_SCHEME}.xcresult"
xcresultPath = "ios/#{Constants.TEST_OUTPUT_DIRECTORY_PATH}/#{Constants.TESTS_SCHEME}.xcresult"

# Xcode summary
changed_files = (git.modified_files - git.deleted_files) + git.added_files
Expand All @@ -34,7 +28,7 @@ xcode_summary.ignored_results { |result|
true
end
}
xcode_summary.ignored_files = 'Pods/**'
xcode_summary.ignored_files = 'ios/Pods/**'
xcode_summary.inline_mode = true
xcode_summary.report xcresultPath

Expand Down

0 comments on commit c269a58

Please sign in to comment.