diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml new file mode 100644 index 00000000..8ab262a5 --- /dev/null +++ b/.github/workflows/ci_pr_example.yml @@ -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 diff --git a/.github/workflows/ci_pr_framework.yml b/.github/workflows/ci_pr_framework.yml new file mode 100644 index 00000000..3093777a --- /dev/null +++ b/.github/workflows/ci_pr_framework.yml @@ -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 diff --git a/.github/workflows/ci_pr_tests.yml b/.github/workflows/ci_pr_tests.yml new file mode 100644 index 00000000..cf1a250f --- /dev/null +++ b/.github/workflows/ci_pr_tests.yml @@ -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 diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 677dddd7..5dbb31fc 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -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: diff --git a/.swiftlint.yml b/.swiftlint.yml index 5ebf9e77..f0172b38 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -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 \ No newline at end of file + - Sources diff --git a/Dangerfile b/Dangerfile index e8cb2911..3ef010fc 100644 --- a/Dangerfile +++ b/Dangerfile @@ -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 diff --git a/Gemfile b/Gemfile index a98db9de..ce1c92bd 100644 --- a/Gemfile +++ b/Gemfile @@ -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' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..71782c63 --- /dev/null +++ b/Gemfile.lock @@ -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 diff --git a/GitHubActions/build.sh b/GitHubActions/build.sh new file mode 100755 index 00000000..3f998f9a --- /dev/null +++ b/GitHubActions/build.sh @@ -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'." diff --git a/Sources/Models/AccessoryPosition.swift b/Sources/Models/AccessoryPosition.swift index 04092026..cd2c486e 100644 --- a/Sources/Models/AccessoryPosition.swift +++ b/Sources/Models/AccessoryPosition.swift @@ -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.