Skip to content

Commit

Permalink
Added ability to explicity flag "is_optional" for fields that we check
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Liebowitz committed Jun 22, 2017
1 parent 3a94113 commit d482921
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 43 deletions.
1 change: 1 addition & 0 deletions deliver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Get in contact with the developer on Twitter: [@FastlaneTools](https://twitter.c
- Easily implement a real Continuous Deployment process using [fastlane](https://fastlane.tools)
- Store the configuration in git to easily deploy from **any** Mac, including your Continuous Integration server
- Get a HTML preview of the fetched metadata before uploading the app metadata and screenshots to iTC
- Automatically uses [precheck](https://github.com/fastlane/fastlane/tree/master/precheck) to ensure your app has the highest chances of passing app review the first time

To upload builds to TestFlight check out [pilot](https://github.com/fastlane/fastlane/tree/master/pilot).

Expand Down
6 changes: 3 additions & 3 deletions deliver/lib/deliver/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ def self.available_options
description: "Clear all previously uploaded screenshots before uploading the new ones",
is_string: false,
default_value: false),
FastlaneCore::ConfigItem.new(key: :only_submit_on_precheck_success,
FastlaneCore::ConfigItem.new(key: :run_precheck_before_submit,
short_option: "-x",
env_name: "DELIVER_ONLY_SUBMIT_ON_PRECHECK_SUCCESS",
description: "Only submit for review once precheck has passed",
env_name: "DELIVER_RUN_PRECHECK_BEFORE_SUBMIT",
description: "Run precheck before submitting to app review",
is_string: false,
default_value: true),
FastlaneCore::ConfigItem.new(key: :precheck_default_rule_level,
Expand Down
3 changes: 2 additions & 1 deletion deliver/lib/deliver/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(options, skip_auto_detection = {})
end

def login
UI.message("Running precheck before submitting to review, if you'd like to disable this check you can set run_precheck_before_submit to false") unless options[:run_precheck_before_submit] == false
UI.message("Login to iTunes Connect (#{options[:username]})")
Spaceship::Tunes.login(options[:username])
Spaceship::Tunes.select_team
Expand All @@ -36,7 +37,7 @@ def run

# Make sure we pass precheck before uploading
def precheck_app
return true unless options[:only_submit_on_precheck_success]
return true unless options[:run_precheck_before_submit]

if options[:submit_for_review]
UI.message("Making sure we pass precheck 👮‍♀️ 👮 before we submit 🛫")
Expand Down
2 changes: 1 addition & 1 deletion fastlane/lib/fastlane/actions/precheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def self.is_supported?(platform)
def self.example_code
[
'precheck(
apple_things(level: :skip), # Set to skip to not run the `apple_things` rule
negative_apple_sentiment(level: :skip), # Set to skip to not run the `negative_apple_sentiment` rule
curse_words(level: :warn) # Set to warn to only warn on curse word check failures
)'
]
Expand Down
54 changes: 33 additions & 21 deletions precheck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ Precheck
[![Twitter: @FastlaneTools](https://img.shields.io/badge/[email protected]?style=flat)](https://twitter.com/FastlaneTools)
[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/fastlane/fastlane/blob/master/LICENSE)

###### Pass App Store precheck, the first time
###### Check your app using a community driven set of App Store review rules to avoid being rejected

Apple rejects builds for many avoidable metadata issues like including swear words 😮, other companies’ trademarks, or even mentioning an iOS bug 🐛. _fastlane precheck_ takes a lot of the guess work out by scanning your app’s details in iTunes Connect for avoidable problems. fastlane precheck helps you get your app through app review without rejections so you can ship faster 🚀


Get in contact with the developer on Twitter: [@FastlaneTools](https://twitter.com/FastlaneTools)
Get in contact with the developers on Twitter: [@FastlaneTools](https://twitter.com/FastlaneTools)

-------

Expand All @@ -59,16 +59,17 @@ Get in contact with the developer on Twitter: [@FastlaneTools](https://twitter.c

# Features

- Many scanning rules:
-  product bug 🐛 mentions
- swear word checker 🙅‍♂️
- mentioning other platforms 🤖
- url reachability checker 😵
- placeholder/test words/mentioning future features 📝
- Copyright date checking
- customizable word list checking 🙈
- You can use our pre-selected list of what we would use, or you can customize which rules to check for, so you run the rules you care most about.
- Customizable: you can decide if you want to warn 📢 about potential problems and continue or have fastlane show an error 🙅 and stop after all scans are done.

| | precheck Features |
|----------|-----------------|
|🐛|  product bug mentions|
|🙅‍♂️|Swear word checker|
|🤖|Mentioning other platforms|
|😵|URL reachability checker|
|📝|Placeholder/test words/mentioning future features|
|📅|Copyright date checking|
|🙈|Customizable word list checking|
|📢|You can decide if you want to warn about potential problems and continue or have _fastlane_ show an error and stop after all scans are done.|

##### [Do you like fastlane? Be the first to know about updates and new fastlane tools](https://tinyletter.com/fastlane-tools)

Expand All @@ -77,13 +78,15 @@ Get in contact with the developer on Twitter: [@FastlaneTools](https://twitter.c
sudo gem install fastlane

# Usage
Run fastlane precheck to check the app metadata from iTunes Connect
Run _fastlane precheck_ to check the app metadata from iTunes Connect

fastlane precheck

To get a list of available options run

fastlane precheck --help

<img src="assets/precheck.gif" />

# Example

Expand All @@ -92,23 +95,32 @@ Since you might want to manually trigger _precheck_ but don't want to specify al
Run `fastlane precheck init` to create a new configuration file. Example:

```ruby
apple_things(level: :skip) # indicates that your metadata will not be checked by this rule
curse_words(level: :warn) # when triggered, this rule will warn you of a potential problem
unreachable_urls(level: :error) # show error and prevent any further commands from running after fastlane precheck finishes
custom_text(data: ["fabric"], level: :warn) # pass in whatever words you want to check for
# indicates that your metadata will not be checked by this rule
negative_apple_sentiment(level: :skip)

# when triggered, this rule will warn you of a potential problem
curse_words(level: :warn)

# show error and prevent any further commands from running after fastlane precheck finishes
unreachable_urls(level: :error)

# pass in whatever words you want to check for
custom_text(data: ["chrome", "webos"],
level: :warn)
```

### Use with [`fastlane`](https://github.com/fastlane/fastlane/tree/master/fastlane)
### Use with [_fastlane_](https://github.com/fastlane/fastlane/tree/master/fastlane)

_precheck_ is totally integrated with [`deliver`](https://github.com/fastlane/fastlane/tree/master/deliver) another [`fastlane`](https://github.com/fastlane/fastlane/tree/master/fastlane) tool.
_precheck_ is fully integrated with [_deliver_](https://github.com/fastlane/fastlane/tree/master/deliver) another [_fastlane_](https://github.com/fastlane/fastlane/tree/master/fastlane) tool.

Update your `Fastfile` to contain the following code:

```ruby
lane :production do
...
# by default deliver will call precheck and warn you of any problems
# if you want precheck to halt submitting to app review, you can pass precheck_default_rule_level: :error
# if you want precheck to halt submitting to app review, you can pass
# precheck_default_rule_level: :error
deliver(precheck_default_rule_level: :error)
...
end
Expand All @@ -122,7 +134,7 @@ end

# How does it work?

`precheck` will access the `iTunes Connect` to download your app's metadata. It uses [spaceship](https://spaceship.airforce) to communicate with Apple's web services.
`precheck` will access `iTunes Connect` to download your app's metadata. It uses [spaceship](https://spaceship.airforce) to communicate with Apple's web services.


# Tips
Expand Down
Binary file modified precheck/assets/precheck.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed precheck/assets/precheckScreenshot.png
Binary file not shown.
2 changes: 1 addition & 1 deletion precheck/lib/assets/PrecheckfileTemplate
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# when triggered, this rule will cause an error to be displayed and it will prevent any further fastlane commands from running after precheck finishes

# Examples:
# apple_things(level: :skip)
# negative_apple_sentiment(level: :skip)
# curse_words(level: :warn)
# future_functionality(level: :error)
# other_platforms(level: :error)
Expand Down
12 changes: 7 additions & 5 deletions precheck/lib/precheck/item_to_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ module Precheck
class ItemToCheck
attr_accessor :item_name
attr_accessor :friendly_name
attr_accessor :is_optional

def initialize(item_name, friendly_name)
def initialize(item_name, friendly_name, is_optional = false)
@item_name = item_name
@friendly_name = friendly_name
@is_optional = is_optional
end

def item_data
Expand All @@ -29,9 +31,9 @@ def to_s
class TextItemToCheck < ItemToCheck
attr_accessor :text

def initialize(text, item_name, friendly_name)
def initialize(text, item_name, friendly_name, is_optional = false)
@text = text
super(item_name, friendly_name)
super(item_name, friendly_name, is_optional)
end

def item_data
Expand All @@ -44,9 +46,9 @@ def item_data
class URLItemToCheck < ItemToCheck
attr_accessor :url

def initialize(url, item_name, friendly_name)
def initialize(url, item_name, friendly_name, is_optional = false)
@url = url
super(item_name, friendly_name)
super(item_name, friendly_name, is_optional)
end

def item_data
Expand Down
2 changes: 1 addition & 1 deletion precheck/lib/precheck/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Precheck
class Options
def self.rules
[
AppleThingsRule,
NegativeAppleSentimentRule,
PlaceholderWordsRule,
OtherPlatformsRule,
FutureFunctionalityRule,
Expand Down
6 changes: 6 additions & 0 deletions precheck/lib/precheck/rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ def item_field_supported?(item_name: nil)
end

def perform_check(item: nil)
if item.item_data.to_s == "" && item.is_optional
# item is optional, and empty, so that's totally fine
check_result = RuleReturn.new(validation_state: Precheck::VALIDATION_STATES[:passed])
return RuleCheckResult.new(item, check_result, self)
end

check_result = self.rule_block.call(item.item_data)
return RuleCheckResult.new(item, check_result, self)
end
Expand Down
17 changes: 10 additions & 7 deletions precheck/lib/precheck/rule_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,20 @@ def self.generate_url_items_to_check(app: nil, app_version: nil)
friendly_name_postfix: "support URL")
items += collect_urls_from_hash(hash: app_version.marketing_url,
item_name: :marketing_url,
friendly_name_postfix: "marketing URL")
friendly_name_postfix: "marketing URL",
is_optional: true)

items += collect_urls_from_hash(hash: app.details.privacy_url,
item_name: :privacy_url,
friendly_name_postfix: "privacy URL")
friendly_name_postfix: "privacy URL",
is_optional: true)
return items
end

def self.collect_urls_from_hash(hash: nil, item_name: nil, friendly_name_postfix: nil)
def self.collect_urls_from_hash(hash: nil, item_name: nil, friendly_name_postfix: nil, is_optional: false)
items = []
hash.each do |key, value|
items << URLItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{key})")
items << URLItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{key})", is_optional)
end
return items
end
Expand Down Expand Up @@ -167,15 +169,16 @@ def self.generate_text_items_to_check(app: nil, app_version: nil)

items += collect_text_items_from_language_item(hash: app.details.subtitle,
item_name: :app_subtitle,
friendly_name_postfix: "app name subtitle")
friendly_name_postfix: "app name subtitle",
is_optional: true)
return items
end

# # a few attributes are LanguageItem this method creates a TextItemToCheck for each pair
def self.collect_text_items_from_language_item(hash: nil, item_name: nil, friendly_name_postfix: nil)
def self.collect_text_items_from_language_item(hash: nil, item_name: nil, friendly_name_postfix: nil, is_optional: false)
items = []
hash.each do |key, value|
items << TextItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{key})")
items << TextItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{key})", is_optional)
end
return items
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
require 'precheck/rules/abstract_text_match_rule'

module Precheck
class AppleThingsRule < AbstractTextMatchRule
class NegativeAppleSentimentRule < AbstractTextMatchRule
def self.key
:apple_things
:negative_apple_sentiment
end

def self.env_name
"RULE_APPLE_THINGS"
"RULE_NEGATIVE_APPLE_SENTIMENT"
end

def self.friendly_name
Expand Down

0 comments on commit d482921

Please sign in to comment.