Skip to content

Commit

Permalink
[#2] Use two Dangerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Sep 14, 2022
1 parent a435fc0 commit 6345d3c
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 43 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/android_review_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Android Review pull request

on:
pull_request

jobs:
review_pull_request:
name: Review pull request
runs-on: ubuntu-latest
timeout-minutes: 30
steps:

- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}

- name: Set up JAVA 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Checkout source code
uses: actions/checkout@v2.3.2

- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'

- name: Cache gems
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Bundle and check environment versions
run: |
echo 'Install Bundle'
bundle config path vendor/bundle
bundle install
echo 'Check environment setup versions'
ruby --version
gem --version
bundler --version
- name: Run Android Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec danger
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Review pull request
name: iOS Review pull request

on:
pull_request

defaults:
run:
working-directory: iosApp

jobs:
review_pull_request:
name: Review pull request
Expand All @@ -24,11 +28,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v2.3.2

- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'

- name: Cache gems
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -57,10 +56,9 @@ jobs:
${{ runner.os }}-pods-
- name: Install Pods Dependencies
working-directory: ./iosApp
run: bundle exec pod install

- name: Run Android Danger
- name: Run iOS Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec danger
run: bundle exec danger
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
/captures
.externalNativeBuild
.cxx
local.properties
local.properties
.env
16 changes: 0 additions & 16 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# 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 @@ -38,18 +37,3 @@ 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.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'
)

12 changes: 0 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,3 @@ gem 'danger-android_lint'
gem 'danger-commit_lint'
gem 'danger-kotlin_detekt'
gem 'danger-shroud'

# iOS
gem "cocoapods"
gem "fastlane"
gem "xcov"
gem "danger-swiftlint"
gem "danger-xcode_summary"
gem 'danger-swiftformat'
gem 'danger-xcov'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
10 changes: 5 additions & 5 deletions iosApp/Dangerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# frozen_string_literal: true

require 'ios/fastlane/Constants/Constants'
require './fastlane/Constants/Constants'

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

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

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

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

Expand Down
13 changes: 13 additions & 0 deletions iosApp/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source "https://rubygems.org"

gem "cocoapods"
gem "fastlane"
gem "xcov"
gem "danger"
gem "danger-swiftlint"
gem "danger-xcode_summary"
gem 'danger-swiftformat'
gem 'danger-xcov'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)

0 comments on commit 6345d3c

Please sign in to comment.