Merge pull request #1274 from MessageKit/dangerAndCI

(Infra) Switch to Gihub Actions, update Danger #trivial
This commit is contained in:
Jakub Kašpar
2020-03-12 09:48:06 +01:00
committed by GitHub
10 changed files with 259 additions and 18 deletions
+27
View File
@@ -0,0 +1,27 @@
name: PR Example app
on: pull_request
jobs:
tests:
name: Build Example app
runs-on: macOS-latest
steps:
- name: Checkout the Git repository
uses: actions/checkout@v2
- name: Cache Pods
uses: actions/cache@v1
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Example/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Cache SPM
uses: actions/cache@v1
with:
path: .build
key: ${{ runner.os }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Build and run example project
run: ./GitHubActions/build.sh example
+20
View File
@@ -0,0 +1,20 @@
name: PR Framework
on: pull_request
jobs:
tests:
name: Build Framework
runs-on: macOS-latest
steps:
- name: Checkout the Git repository
uses: actions/checkout@v2
- name: Cache Carthage
uses: actions/cache@v1
with:
path: Carthage
key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
restore-keys: |
${{ runner.os }}-carthage-
- name: Build framework
run: ./GitHubActions/build.sh framework
+20
View File
@@ -0,0 +1,20 @@
name: PR Tests
on: pull_request
jobs:
tests:
name: Run Tests
runs-on: macOS-latest
steps:
- name: Checkout the Git repository
uses: actions/checkout@v2
- name: Cache Carthage
uses: actions/cache@v1
with:
path: Carthage
key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
restore-keys: |
${{ runner.os }}-carthage-
- name: Build and run tests
run: ./GitHubActions/build.sh tests
+7 -4
View File
@@ -5,14 +5,17 @@ on: pull_request
jobs:
danger:
name: Run Danger
runs-on: ubuntu-latest
runs-on: macOS-latest
steps:
- name: Checkout the Git repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: actions/setup-ruby@v1
- name: Cache Gems
uses: actions/cache@v1
with:
ruby-version: '2.6'
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Run build script
run: gem install bundler && bundle install && bundle exec danger --fail-on-errors=true
env:
+1 -2
View File
@@ -13,7 +13,6 @@ custom_rules:
severity: warning # violation severity. optional.
opt_in_rules:
- explicit_top_level_acl
explicit_acl: error
explicit_top_level_acl: error
included:
- Sources
- Sources
+27 -7
View File
@@ -1,29 +1,49 @@
# MessageKit, 2020
#
# MIT License
#
# Copyright (c) 2017-2020 MessageKit
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# This runs on CI
mergeable_state = github.pr_json["mergeable_state"]
# Make it more obvious that a PR a draft
if mergeable_state == "draft"
warn("PR is marked as Draft")
warn("PR is marked as Draft")
end
# Mainly to encourage writing up some reasoning about the PR, rather than just leaving a title
if github.pr_body.length < 5
fail("Please provide a summary in the Pull Request description")
fail("Please provide a summary in the Pull Request description")
end
declared_hashtag = github.pr_title.include?("#trivial")
hasChangelogEntry = git.modified_files.include?("CHANGELOG.md")
if !hasChangelogEntry && !declared_hashtag
fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/MessageKit/MessageKit/blob/master/CHANGELOG.md).")
fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/MessageKit/MessageKit/blob/master/CHANGELOG.md).")
end
# Warn when there is a big PR
if git.lines_of_code > 1000
warn("Big Pull Request - Please consider splitting up your changes into smaller Pull Requests.")
warn("Big Pull Request - Please consider splitting up your changes into smaller Pull Requests.")
end
swiftlint.config_file = '.swiftlint.yml'
swiftlint.lint_files inline_mode:true
swiftlint.lint_files fail_on_error:true
swiftlint.lint_files inline_mode:true, fail_on_error:true
+25 -4
View File
@@ -1,5 +1,26 @@
# MessageKit, 2020
#
# MIT License
#
# Copyright (c) 2017-2020 MessageKit
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
source 'https://rubygems.org'
gem 'danger', '~> 6.2'
gem 'danger-swiftlint', '~> 0.24'
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
source 'https://rubygems.org'
gem 'danger', '~> 6.2'
gem 'danger-swiftlint', '~> 0.24'
+66
View File
@@ -0,0 +1,66 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
claide (1.0.3)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (6.3.1)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (~> 0.9)
faraday-http-cache (~> 2.0)
git (~> 1.6)
kramdown (~> 2.0)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
danger-swiftlint (0.24.1)
danger
rake (> 10)
thor (~> 0.19)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday-http-cache (2.0.0)
faraday (~> 0.8)
git (1.6.0)
rchardet (~> 1.8)
kramdown (2.1.0)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
multipart-post (2.1.1)
nap (1.1.0)
no_proxy_fix (0.1.2)
octokit (4.16.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
public_suffix (4.0.3)
rake (13.0.1)
rchardet (1.8.0)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (0.20.3)
unicode-display_width (1.6.1)
PLATFORMS
ruby
DEPENDENCIES
danger (~> 6.2)
danger-swiftlint (~> 0.24)
BUNDLED WITH
2.1.4
+65
View File
@@ -0,0 +1,65 @@
#!/bin/bash
#
# MIT License
#
# Copyright (c) 2017-2020 MessageKit
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -e
function trap_handler {
echo -e "\n\nOh no! You walked directly into the slavering fangs of a lurking grue!"
echo "**** You have died ****"
exit 255
}
trap trap_handler INT TERM EXIT
MODE="$1"
if [ "$MODE" = "tests" -o "$MODE" = "all" ]; then
echo "Running MessageKit tests."
carthage bootstrap --platform ios
set -o pipefail && xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "platform=iOS Simulator,name=iPhone 11 Pro" CODE_SIGNING_REQUIRED=NO | xcpretty -c
success="1"
fi
if [ "$MODE" = "framework" -o "$MODE" = "all" ]; then
echo "Building MessageKit Framework."
carthage bootstrap --platform ios
set -o pipefail && xcodebuild build -project MessageKit.xcodeproj -scheme MessageKit -destination "platform=iOS Simulator,name=iPhone 11 Pro" CODE_SIGNING_REQUIRED=NO | xcpretty -c
success="1"
fi
if [ "$MODE" = "example" -o "$MODE" = "all" ]; then
echo "Building & testing MessageKit Example app."
cd Example
gem install bundler
bundle check || bundle install
bundle exec pod install
set -o pipefail && xcodebuild build analyze -workspace ChatExample.xcworkspace -scheme ChatExample -destination "platform=iOS Simulator,name=iPhone 11 Pro" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c
success="1"
fi
if [ "$success" = "1" ]; then
trap - EXIT
exit 0
fi
echo "Unrecognised mode '$MODE'."
+1 -1
View File
@@ -25,7 +25,7 @@
import Foundation
/// Used to determine the `Horizontal` and `Vertical` position of
// an `AccessoryView` in a `MessageCollectionViewCell`.
/// an `AccessoryView` in a `MessageCollectionViewCell`.
public enum AccessoryPosition {
/// Aligns the `AccessoryView`'s top edge to the cell's top edge.