diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6fb7505 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,87 @@ +version: 2 + +defaults: &defaults + macos: + xcode: "10.2.0" + working_directory: /Users/distiller/project + environment: + FL_OUTPUT_DIR: /Users/distiller/project/output + GYM_OUTPUT_NAME: app + # For fix ruby error + shell: /bin/bash --login -eo pipefail + +jobs: + build: + <<: *defaults + steps: + - checkout + + - run: + name: Set Ruby Version + command: echo "ruby-2.4" > .ruby-version + + - restore_cache: + keys: + - v1-gems-{{ checksum "Gemfile.lock" }} + - v1-gems- + - run: + name: Install RubyGems + command: bundle install --path vendor/bundle + - save_cache: + key: v1-gems-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + + # - run: + # name: Install SwiftLint + # command: brew install swiftlint + + # - run: + # name: Decrypt resource + # command: openssl aes-256-cbc -k $DECRYPT_KEY -d -in JobChat/Resources/Staging/encrypted_GoogleService-Info.plist -out JobChat/Resources/Staging/GoogleService-Info.plist + + # - run: + # name: Run unit test + # command: bundle exec fastlane test + - run: + name: Run Danger + command: bundle exec danger + + - store_artifacts: + path: /Users/distiller/project/output + destination: output + - store_test_results: + path: /Users/distiller/project/output/scan + + - persist_to_workspace: + root: /Users/distiller/project + paths: + - . + + deploy: + <<: *defaults + steps: + - attach_workspace: + at: /Users/distiller/project + # - run: + # command: base64 -D -o certificates/Certificates.p12 <<< $Certificates + # - run: + # command: base64 -D -o certificates/JobChatStgAdHocProvision.mobileprovision <<< $profile + - run: + name: Build ipa & upload + command: bundle exec fastlane beta + - store_artifacts: + path: /Users/distiller/project/output + destination: output + +workflows: + version: 2 + build_and_deploy: + jobs: + - build: + filters: + tags: + only: /^v.*/ + - deploy: + requires: + - build diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..74ea59f --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,40 @@ +disabled_rules: +- identifier_name +- trailing_whitespace + +excluded: # paths to ignore during linting. Takes precedence over `included`. +- Pods +- Carthage +- JobChat/Utils/Libraries + +opt_in_rules: +- empty_count +- empty_string + +line_length: + warning: 150 + error: 200 + ignores_function_declarations: true + ignores_comments: true + ignores_urls: true + +function_body_length: + warning: 50 + error: 100 + +type_body_length: + warning: 300 + error: 500 + +cyclomatic_complexity: + warning: 15 + error: 25 + ignores_case_statements: true + +function_parameter_count: + warning: 4 + error: 6 + +file_length: + warning: 1000 + error: 1500 diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..facc84c --- /dev/null +++ b/Dangerfile @@ -0,0 +1,11 @@ +# github comment settings +github.dismiss_out_of_range_messages + +# for PR +if github.pr_title.include?('[WIP]') || github.pr_labels.include?('WIP') + warn('PR is classed as Work in Progress') +end + +# Warn when there is a big PR +warn('a large PR') if git.lines_of_code > 500 + diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..9c338aa --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem 'cocoapods' +gem 'fastlane' +gem 'danger' +gem 'danger-swiftlint' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..5bebba2 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,252 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.0) + activesupport (4.2.11.1) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + atomos (0.1.3) + babosa (1.0.2) + claide (1.0.2) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) + cocoapods (1.6.1) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.6.1) + cocoapods-deintegrate (>= 1.0.2, < 2.0) + cocoapods-downloader (>= 1.2.2, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.3.1, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.2.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.6.6) + nap (~> 1.0) + ruby-macho (~> 1.4) + xcodeproj (>= 1.8.1, < 2.0) + cocoapods-core (1.6.1) + activesupport (>= 4.0.2, < 6) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.2.2) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.3.1) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.1.0) + colored (1.2) + colored2 (3.1.2) + commander-fastlane (4.4.6) + highline (~> 1.7.2) + concurrent-ruby (1.1.5) + cork (0.3.0) + colored2 (~> 3.1) + danger (6.0.6) + claide (~> 1.0) + claide-plugins (>= 0.9.2) + colored2 (~> 3.1) + cork (~> 0.1) + faraday (~> 0.9) + faraday-http-cache (~> 1.0) + git (~> 1.5) + kramdown (~> 2.0) + kramdown-parser-gfm (~> 1.0) + no_proxy_fix + octokit (~> 4.7) + terminal-table (~> 1) + danger-swiftlint (0.20.1) + danger + rake (> 10) + thor (~> 0.19) + declarative (0.0.10) + declarative-option (0.1.0) + digest-crc (0.4.1) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.2) + emoji_regex (1.0.1) + escape (0.0.4) + excon (0.64.0) + faraday (0.15.4) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday-http-cache (1.3.1) + faraday (~> 0.8) + faraday_middleware (0.13.1) + faraday (>= 0.7.4, < 1.0) + fastimage (2.1.5) + fastlane (2.121.1) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.3, < 3.0.0) + babosa (>= 1.0.2, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander-fastlane (>= 4.4.6, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 2.0) + excon (>= 0.45.0, < 1.0.0) + faraday (~> 0.9) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 0.9) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-api-client (>= 0.21.2, < 0.24.0) + google-cloud-storage (>= 1.15.0, < 2.0.0) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) + mini_magick (~> 4.5.1) + multi_json + multi_xml (~> 0.5) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + public_suffix (~> 2.0.0) + rubyzip (>= 1.2.2, < 2.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + slack-notifier (>= 2.0.0, < 3.0.0) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.8.1, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) + fourflusher (2.2.0) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + git (1.5.0) + google-api-client (0.23.9) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.5, < 0.7.0) + httpclient (>= 2.8.1, < 3.0) + mime-types (~> 3.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + signet (~> 0.9) + google-cloud-core (1.3.0) + google-cloud-env (~> 1.0) + google-cloud-env (1.0.5) + faraday (~> 0.11) + google-cloud-storage (1.16.0) + digest-crc (~> 0.4) + google-api-client (~> 0.23) + google-cloud-core (~> 1.2) + googleauth (>= 0.6.2, < 0.10.0) + googleauth (0.6.7) + faraday (~> 0.12) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (~> 0.7) + highline (1.7.10) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + json (2.2.0) + jwt (2.1.0) + kramdown (2.1.0) + kramdown-parser-gfm (1.0.1) + kramdown (~> 2.0) + memoist (0.16.0) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.0331) + mini_magick (4.5.1) + minitest (5.11.3) + molinillo (0.6.6) + multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nanaimo (0.2.6) + nap (1.1.0) + naturally (2.2.0) + netrc (0.11.0) + no_proxy_fix (0.1.2) + octokit (4.14.0) + sawyer (~> 0.8.0, >= 0.5.3) + open4 (1.3.4) + os (1.0.1) + plist (3.5.0) + public_suffix (2.0.5) + rake (12.3.2) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rouge (2.0.7) + ruby-macho (1.4.0) + rubyzip (1.2.2) + sawyer (0.8.1) + addressable (>= 2.3.5, < 2.6) + faraday (~> 0.8, < 1.0) + security (0.1.3) + signet (0.11.0) + addressable (~> 2.3) + faraday (~> 0.9) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.5) + CFPropertyList + naturally + slack-notifier (2.3.2) + terminal-notifier (2.0.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + thor (0.20.3) + thread_safe (0.3.6) + tty-cursor (0.6.1) + tty-screen (0.6.5) + tty-spinner (0.9.0) + tty-cursor (~> 0.6.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.6) + unicode-display_width (1.5.0) + word_wrap (1.0.0) + xcodeproj (1.8.2) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.2.6) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.0) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods + danger + danger-swiftlint + fastlane + +BUNDLED WITH + 1.16.1 diff --git a/Structure_IOS.xcodeproj/project.pbxproj b/Structure_IOS.xcodeproj/project.pbxproj index ddbccd7..6fd301a 100644 --- a/Structure_IOS.xcodeproj/project.pbxproj +++ b/Structure_IOS.xcodeproj/project.pbxproj @@ -8,6 +8,10 @@ /* Begin PBXBuildFile section */ 95EBCB25DD5E94C08069B703 /* Pods_Structure_IOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 12350BBD90D5323169389B9C /* Pods_Structure_IOS.framework */; }; + BF4EB10B23443AE20056BC95 /* Dangerfile in Resources */ = {isa = PBXBuildFile; fileRef = BF4EB10A23443AE20056BC95 /* Dangerfile */; }; + BF4EB10E23443AFC0056BC95 /* fastlane in Resources */ = {isa = PBXBuildFile; fileRef = BF4EB10C23443AFC0056BC95 /* fastlane */; }; + BF4EB10F23443AFC0056BC95 /* Gemfile in Resources */ = {isa = PBXBuildFile; fileRef = BF4EB10D23443AFC0056BC95 /* Gemfile */; }; + BF4EB11123443B1B0056BC95 /* certificates in Resources */ = {isa = PBXBuildFile; fileRef = BF4EB11023443B1B0056BC95 /* certificates */; }; BFACA53F1F9B2499003EB555 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFACA53E1F9B2499003EB555 /* AppDelegate.swift */; }; BFACA5411F9B2499003EB555 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFACA5401F9B2499003EB555 /* ViewController.swift */; }; BFACA5441F9B2499003EB555 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BFACA5421F9B2499003EB555 /* Main.storyboard */; }; @@ -19,6 +23,10 @@ 12350BBD90D5323169389B9C /* Pods_Structure_IOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Structure_IOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2699674AA73EF5A16274B415 /* Pods-Structure_IOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Structure_IOS.release.xcconfig"; path = "Target Support Files/Pods-Structure_IOS/Pods-Structure_IOS.release.xcconfig"; sourceTree = ""; }; ACEB269FB87DA33989737CD6 /* Pods-Structure_IOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Structure_IOS.debug.xcconfig"; path = "Target Support Files/Pods-Structure_IOS/Pods-Structure_IOS.debug.xcconfig"; sourceTree = ""; }; + BF4EB10A23443AE20056BC95 /* Dangerfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Dangerfile; sourceTree = SOURCE_ROOT; }; + BF4EB10C23443AFC0056BC95 /* fastlane */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fastlane; sourceTree = SOURCE_ROOT; }; + BF4EB10D23443AFC0056BC95 /* Gemfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Gemfile; sourceTree = SOURCE_ROOT; }; + BF4EB11023443B1B0056BC95 /* certificates */ = {isa = PBXFileReference; lastKnownFileType = folder; path = certificates; sourceTree = SOURCE_ROOT; }; BFACA53B1F9B2499003EB555 /* Structure_IOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Structure_IOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; BFACA53E1F9B2499003EB555 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; BFACA5401F9B2499003EB555 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -46,7 +54,6 @@ ACEB269FB87DA33989737CD6 /* Pods-Structure_IOS.debug.xcconfig */, 2699674AA73EF5A16274B415 /* Pods-Structure_IOS.release.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -58,9 +65,21 @@ name = Frameworks; sourceTree = ""; }; + BF4EB10923443AD30056BC95 /* CI */ = { + isa = PBXGroup; + children = ( + BF4EB11023443B1B0056BC95 /* certificates */, + BF4EB10C23443AFC0056BC95 /* fastlane */, + BF4EB10D23443AFC0056BC95 /* Gemfile */, + BF4EB10A23443AE20056BC95 /* Dangerfile */, + ); + path = CI; + sourceTree = ""; + }; BFACA5321F9B2499003EB555 = { isa = PBXGroup; children = ( + BF4EB10923443AD30056BC95 /* CI */, BFACA53D1F9B2499003EB555 /* Structure_IOS */, BFACA53C1F9B2499003EB555 /* Products */, 2703D795CE736C68E8BCC318 /* Pods */, @@ -151,9 +170,13 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + BF4EB11123443B1B0056BC95 /* certificates in Resources */, + BF4EB10F23443AFC0056BC95 /* Gemfile in Resources */, BFACA5491F9B2499003EB555 /* LaunchScreen.storyboard in Resources */, BFACA5461F9B2499003EB555 /* Assets.xcassets in Resources */, BFACA5441F9B2499003EB555 /* Main.storyboard in Resources */, + BF4EB10B23443AE20056BC95 /* Dangerfile in Resources */, + BF4EB10E23443AFC0056BC95 /* fastlane in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/certificates/Certificates.p12 b/certificates/Certificates.p12 new file mode 100644 index 0000000..ae42505 Binary files /dev/null and b/certificates/Certificates.p12 differ diff --git a/certificates/JobChatStgAdHocProvision.mobileprovision b/certificates/JobChatStgAdHocProvision.mobileprovision new file mode 100644 index 0000000..989d531 Binary files /dev/null and b/certificates/JobChatStgAdHocProvision.mobileprovision differ diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 0000000..6a38b2b --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,6 @@ +app_identifier("com.ccc.jobchat.stg") # The bundle identifier of your app +team_id "PF7X72W59F" + + +# For more information about the Appfile, see: +# https://docs.fastlane.tools/advanced/#appfile diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000..8e48cfd --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,67 @@ +# This file contains the fastlane.tools configuration +# You can find the documentation at https://docs.fastlane.tools +# +# For a list of all available actions, check out +# +# https://docs.fastlane.tools/actions +# +# For a list of all available plugins, check out +# +# https://docs.fastlane.tools/plugins/available-plugins +# + +# Uncomment the line if you want fastlane to automatically update itself +# update_fastlane + +default_platform(:ios) + +SCHEME_NAME = 'Staging' + +TEAM_ID = 'PF7X72W59F' +BUNDLE_ID = 'com.ccc.jobchat.stg' +PROVISIONING_PROFILE_NAME = 'JobChatStgAdHocProvision' + + +platform :ios do + before_all do + setup_circle_ci + end + + desc "Upload to Fabric" + lane :beta do + setup_provisioning_profiles + + build_app( + scheme: SCHEME_NAME, + export_method: 'development', + export_options: { + provisioningProfiles: { + BUNDLE_ID => PROVISIONING_PROFILE_NAME + } + }, + xcargs: "DEVELOPMENT_TEAM='#{TEAM_ID}' PROVISIONING_PROFILE_SPECIFIER='#{PROVISIONING_PROFILE_NAME}'" + ) + + crashlytics( + api_token: ENV['CRASHLYTICS_API_KEY'], + build_secret: ENV['CRASHLYTICS_SECRET'], + groups: "QA3C", + notes: "Automatic iOS Build" + ) + end + + private_lane :setup_provisioning_profiles do |options| + next unless Helper.ci? + + import_certificate( + keychain_name: 'fastlane_tmp_keychain', + certificate_path: 'certificates/Certificates.p12', + certificate_password: ENV['IOS_CERTIFICATES_KEY_PASSWORD'], + keychain_password: ENV['MATCH_KEYCHAIN_PASSWORD']) + + Dir.glob('../certificates/*.mobileprovision').each {|filename| + puts filename + FastlaneCore::ProvisioningProfile.install(filename) + } + end +end