From b3c8d658cbf413f6b53a102886668075295c2b25 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 13:09:18 +0100 Subject: [PATCH 1/8] Switch to Github Actions, Update Danger --- .github/workflows/ci_pr_example.yml | 27 +++++++++++ .github/workflows/ci_pr_framework.yml | 20 ++++++++ .github/workflows/ci_pr_tests.yml | 20 ++++++++ .github/workflows/danger.yml | 7 +++ .swiftlint.yml | 2 +- Dangerfile | 13 +++--- Gemfile | 8 ++-- Gemfile.lock | 66 +++++++++++++++++++++++++++ build.sh | 44 ++++++++++++++++++ 9 files changed, 195 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/ci_pr_example.yml create mode 100644 .github/workflows/ci_pr_framework.yml create mode 100644 .github/workflows/ci_pr_tests.yml create mode 100644 Gemfile.lock create mode 100755 build.sh diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml new file mode 100644 index 00000000..58bc28df --- /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: ./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..e8817f85 --- /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: ./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..1e61f9c1 --- /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: ./build.sh tests diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 677dddd7..c72466d8 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -13,6 +13,13 @@ jobs: uses: actions/setup-ruby@v1 with: ruby-version: '2.6' + - name: Cache Gems + uses: actions/cache@v1 + with: + 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..037ce5b0 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -16,4 +16,4 @@ opt_in_rules: 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..187c6239 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,29 +1,28 @@ -# MessageKit, 2020 +# MessageKit, 2020 # 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..75c378ae 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ -# MessageKit, 2020 +# MessageKit, 2020 -source 'https://rubygems.org' -gem 'danger', '~> 6.2' -gem 'danger-swiftlint', '~> 0.24' +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/build.sh b/build.sh new file mode 100755 index 00000000..30354a2b --- /dev/null +++ b/build.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# MessageKit, 2020 + +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'." From 9237c50ac742f069694befa619ba466acfcfda31 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 13:13:25 +0100 Subject: [PATCH 2/8] Disable Example app cache until https://github.com/MessageKit/MessageKit/pull/1272 is merged --- .github/workflows/ci_pr_example.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index 58bc28df..190bd5ef 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -16,12 +16,12 @@ jobs: 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: 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: ./build.sh example From 8ab69e119a7a6b6f7cfc37106c74f1421a6ac5f2 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 13:18:29 +0100 Subject: [PATCH 3/8] Re-enable cache --- .github/workflows/ci_pr_example.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index 190bd5ef..58bc28df 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -16,12 +16,12 @@ jobs: 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: 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: ./build.sh example From d34226f38b6f088b3b004f77f590eef3e48f8c5b Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 19:58:13 +0100 Subject: [PATCH 4/8] Fix swiftlint --- .swiftlint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 037ce5b0..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 From 8d2001222db95c7f4b4bfdcf1022de248cd2107f Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 20:42:39 +0100 Subject: [PATCH 5/8] Switch to macOS for danger --- .github/workflows/danger.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index c72466d8..a12cdaf1 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -5,14 +5,14 @@ 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 - with: - ruby-version: '2.6' +# - name: Setup Ruby +# uses: actions/setup-ruby@v1 +# with: +# ruby-version: '2.6' - name: Cache Gems uses: actions/cache@v1 with: From cddbf106081879150352504552f9cf650510e81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ka=C5=A1par?= Date: Tue, 10 Mar 2020 20:44:17 +0100 Subject: [PATCH 6/8] Update Dangerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Martin Púčik --- Dangerfile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Dangerfile b/Dangerfile index 187c6239..3ef010fc 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,4 +1,25 @@ -# 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"] From 5af92cf40079c84c7251bf65b0eb49ad6fc0afbf Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 20:48:04 +0100 Subject: [PATCH 7/8] Move script to subfolder --- .github/workflows/ci_pr_example.yml | 2 +- .github/workflows/ci_pr_framework.yml | 2 +- .github/workflows/ci_pr_tests.yml | 2 +- Gemfile | 23 ++++++++++++++++++++++- build.sh => GitHubActions/build.sh | 23 ++++++++++++++++++++++- Sources/Models/AccessoryPosition.swift | 2 +- 6 files changed, 48 insertions(+), 6 deletions(-) rename build.sh => GitHubActions/build.sh (55%) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index 58bc28df..8ab262a5 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -24,4 +24,4 @@ jobs: restore-keys: | ${{ runner.os }}-gems- - name: Build and run example project - run: ./build.sh example + run: ./GitHubActions/build.sh example diff --git a/.github/workflows/ci_pr_framework.yml b/.github/workflows/ci_pr_framework.yml index e8817f85..3093777a 100644 --- a/.github/workflows/ci_pr_framework.yml +++ b/.github/workflows/ci_pr_framework.yml @@ -17,4 +17,4 @@ jobs: restore-keys: | ${{ runner.os }}-carthage- - name: Build framework - run: ./build.sh framework + run: ./GitHubActions/build.sh framework diff --git a/.github/workflows/ci_pr_tests.yml b/.github/workflows/ci_pr_tests.yml index 1e61f9c1..cf1a250f 100644 --- a/.github/workflows/ci_pr_tests.yml +++ b/.github/workflows/ci_pr_tests.yml @@ -17,4 +17,4 @@ jobs: restore-keys: | ${{ runner.os }}-carthage- - name: Build and run tests - run: ./build.sh tests + run: ./GitHubActions/build.sh tests diff --git a/Gemfile b/Gemfile index 75c378ae..ce1c92bd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,25 @@ -# 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. source 'https://rubygems.org' gem 'danger', '~> 6.2' diff --git a/build.sh b/GitHubActions/build.sh similarity index 55% rename from build.sh rename to GitHubActions/build.sh index 30354a2b..3f998f9a 100755 --- a/build.sh +++ b/GitHubActions/build.sh @@ -1,6 +1,27 @@ #!/bin/bash -# 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. set -e function trap_handler { 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. From 2dfbf65b3448ad30830046e390a237b430e0aa7c Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 20:53:08 +0100 Subject: [PATCH 8/8] Remove unused code --- .github/workflows/danger.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index a12cdaf1..5dbb31fc 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -9,10 +9,6 @@ jobs: steps: - name: Checkout the Git repository uses: actions/checkout@v2 -# - name: Setup Ruby -# uses: actions/setup-ruby@v1 -# with: -# ruby-version: '2.6' - name: Cache Gems uses: actions/cache@v1 with: