Skip to content

Commit

Permalink
Feature/automation (#3)
Browse files Browse the repository at this point in the history
* Update issue templates

Added komondor with hooks

* Adds code climate test reporter

Cleaned up fastlane and CI related setup
  • Loading branch information
kevnm67 authored and github-actions[bot] committed Nov 3, 2019
1 parent 84daf18 commit 5c67882
Show file tree
Hide file tree
Showing 22 changed files with 428 additions and 176 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_WITHOUT: "documentation"
14 changes: 12 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ orbs:

defaults: &defaults
macos:
xcode: '11.1.0'
xcode: '11.2.0'
working_directory: /Users/distiller/CircleCI
shell: /bin/bash --login -o pipefail
environment:
Expand Down Expand Up @@ -33,8 +33,18 @@ jobs:
command: brew install blender/homebrew-tap/rome
- kjm-dev/lane:
named: carthage_ci
- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- kjm-dev/lane:
named: test_iphone_x
named: test_iphone_pro
- run:
name: Upload test results
command: |
./cc-test-reporter after-build
workflows:
build-and-test:
Expand Down
48 changes: 0 additions & 48 deletions .codeclimate.json

This file was deleted.

35 changes: 35 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
version: '2'
plugins:
swiftlint:
enabled: true
bundler-audit:
enabled: true
rubocop:
enabled: true
channel: rubocop-0-67
shellcheck:
enabled: true
exclude_patterns:
- Carthage/
- Pods/
- docs/
- fastlane/
- Resources/
- Templates/
- "**/*.css"
checks:
identical-code:
config:
threshold: 25
file-lines:
config:
threshold: 1000
similar-code:
config:
threshold: 50
duplication:
config:
languages:
swift:
mass_threshold: 25
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ fastlane/test_output

# Dotfiles
.env.*.local
.env
.env
.env.local
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.4
2.6.4
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.1
5.1.2
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 11 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
os: osx
osx_image: xcode11
rvm: 2.6.3
osx_image: xcode11.2
language: swift
rvm: 2.6.4

addons:
homebrew:
Expand All @@ -26,59 +27,35 @@ env:
- LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8

before_install:
- gem update --system
- gem install bundler
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- make setup

jobs:
include:
- &cache
stage: cache
name: Bootstrap dependencies
osx_image: xcode11
env:
- LANE="carthage_bootstrap"
- CACHE_SWIFT_VERSION="CircleCI"
if: "(commit_message =~ /(@cache bootstrap)/)"
script:
- bundle exec fastlane "$LANE"

- <<: *cache
name: Carthage update
env:
- LANE="do_cart_update"
- CACHE_SWIFT_VERSION="CircleCI"
if: "(commit_message =~ /(@cache update)/)"

- &test
stage: test
name: iPhone X tests
osx_image: xcode11
name: iPhone Pro tests
env:
- DESTINATION="test_iphone_x"
- DESTINATION="test_iphone_pro"
- CACHE_SWIFT_VERSION="CircleCI"
before_script:
- bundle exec fastlane carthage_ci
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- "./cc-test-reporter before-build"
script:
- bundle exec fastlane "$DESTINATION"
after_success:
- bundle exec danger
- make danger
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"

- <<: *test
name: iPhone 6
env: DESTINATION="test_iphone_6"

- <<: *test
name: iPad
env: DESTINATION="test_ipad"
if: (commit_message =~ /(@test ipad)/)

- stage: lint
name: pod lint
if: branch IN (master, develop) AND (type != pull_request)
script: bundle exec pod lib lint
script: make lint

- stage: carthage
name: Carthage build
Expand All @@ -87,7 +64,6 @@ jobs:
script: carthage build --no-skip-current --configuration Release

stages:
- cache
- test
- lint
- carthage
3 changes: 3 additions & 0 deletions CircleCI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = VFS2U5QDNC;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
Expand All @@ -510,6 +511,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = VFS2U5QDNC;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
Expand Down Expand Up @@ -622,6 +624,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = VFS2U5QDNC;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
Expand Down
52 changes: 28 additions & 24 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

has_app_changes = !git.modified_files.grep(/Circle-CI-Playground/).empty?

Expand All @@ -10,62 +11,65 @@ has_app_changes = !git.modified_files.grep(/Circle-CI-Playground/).empty?

# determine if any of the files were modified
def didModify(files_array)
did_modify_files = false
files_array.each do |file_name|
if git.modified_files.include?(file_name) || git.deleted_files.include?(file_name)
did_modify_files = true
did_modify_files = false
files_array.each do |file_name|
unless git.modified_files.include?(file_name) || git.deleted_files.include?(file_name)
next
end

config_files = git.modified_files.select { |path| path.include? file_name }
did_modify_files = true

message "This PR changes #{ github.html_link(config_files) }"
end
end
config_files = git.modified_files.select { |path| path.include? file_name }

return did_modify_files
message "This PR changes #{github.html_link(config_files)}"
end

did_modify_files
end

###
### Warnings
###

warn('Changes to CI/CD files') if didModify(@GL_DANGER_CI_CD_FILES)
warn('Changes to dependency related files') if didModify(@GL_DANGER_DEPENDENCY_FILES)

if didModify(@GL_DANGER_DEPENDENCY_FILES)
warn('Changes to dependency related files')
end

# Sometimes it's a README fix, or something like that - which isn't relevant for
# including in a project's CHANGELOG for example
not_declared_trivial = !(github.pr_title.downcase.include? "#trivial")
not_declared_trivial = !(github.pr_title.downcase.include? '#trivial')

# 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]"
warn('PR is classed as Work in Progress') if github.pr_title.include? '[WIP]'

###
### Auto label
###

if github.pr_title.include? "[WIP]"
auto_label.wip=(github.pr_json["number"])
if github.pr_title.include? '[WIP]'
auto_label.wip = github.pr_json['number']
else
auto_label.remove("WIP")
auto_label.remove('WIP')
end

warn('Big PR, try to keep changes smaller if you can') if git.lines_of_code > 500
if git.lines_of_code > 500
warn('Big PR, try to keep changes smaller if you can')
end

# Don't let testing shortcuts get into master by accident (e.g. fit -> focuses on a single test).
fail("fit left in tests") if `grep -r "fit Tests/ `.length > 1
raise('fit left in tests') if `grep -r "fit Tests/ `.length > 1

# Changelog entries are required for changes to library files.
no_changelog_entry = !git.modified_files.include?("CHANGELOG.md")
no_changelog_entry = !git.modified_files.include?('CHANGELOG.md')

# Don't warn about changelog.
temp_skip_changelog = true

if has_app_changes && no_changelog_entry && not_declared_trivial && !temp_skip_changelog
warn("Any changes to library code should be reflected in the Changelog. Please consider updating the changelog. [Changelog Guidelines](./CHANGELOG.md).")
warn('Any changes to library code should be reflected in the Changelog. Please consider updating the changelog. [Changelog Guidelines](./CHANGELOG.md).')
end

# Warn when library files changed without test coverage.
tests_updated = !git.modified_files.grep(/Tests/).empty?

if has_app_changes && !tests_updated
warn("Library files were updated without test coverage. Consider updating or adding tests to cover changes.")
warn('Library files were updated without test coverage. Consider updating or adding tests to cover changes.')
end
9 changes: 4 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'cocoapods'
gem 'danger'
gem 'danger-auto_label'
gem 'danger-swiftlint'
gem 'fastlane'
gem 'slather'
gem 'xcov'
gem 'xcpretty'
gem 'xcpretty-json-formatter'

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

0 comments on commit 5c67882

Please sign in to comment.