From edb596fc72e642c0e4f0d39766ee11534eb19a55 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 16:43:50 +0000 Subject: [PATCH 1/9] Run Danger with GitHub Actions --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..12e8b265 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,26 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Danger Swift + uses: danger/swift@2.0.3 From 702404a15cc34d24f11236fc418ecca47b0eda26 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 16:56:41 +0000 Subject: [PATCH 2/9] Add Dangerfile.swift, GitHub token to main.yml --- .github/workflows/main.yml | 2 ++ Dangerfile.swift | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 Dangerfile.swift diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 12e8b265..bd2e60b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,3 +24,5 @@ jobs: - name: Danger Swift uses: danger/swift@2.0.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dangerfile.swift b/Dangerfile.swift new file mode 100644 index 00000000..3e65a76a --- /dev/null +++ b/Dangerfile.swift @@ -0,0 +1,8 @@ +import Danger + +SwiftLint.lint( + inline: true, + configFile: ".swiftlint.yml", + strict: true, + lintAllFiles: true +) \ No newline at end of file From a3cf08df9210de8f68ecf4ff366e3e5f99e37cdb Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 16:57:41 +0000 Subject: [PATCH 3/9] Add newline to Dangerfile.swift --- Dangerfile.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dangerfile.swift b/Dangerfile.swift index 3e65a76a..401ccbc5 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -5,4 +5,4 @@ SwiftLint.lint( configFile: ".swiftlint.yml", strict: true, lintAllFiles: true -) \ No newline at end of file +) From 6e329bdcbee9ebb9d092b74c9619cfbde39bb502 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 17:05:27 +0000 Subject: [PATCH 4/9] Set latest version of Danger in main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd2e60b2..ad6527f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,6 @@ jobs: - uses: actions/checkout@v2 - name: Danger Swift - uses: danger/swift@2.0.3 + uses: danger/swift@3.1.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a15760816a1fab552d5431c3a2e275ca9ff9102f Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 17:30:11 +0000 Subject: [PATCH 5/9] Attempt to use forked danger-swift with Swiftlint --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ad6527f6..253a65d1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,6 @@ jobs: - uses: actions/checkout@v2 - name: Danger Swift - uses: danger/swift@3.1.0 + uses: maxdesiatov/danger-swift@swiftlint-docker env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7f863be336a2f4bdaecb35e5299499fb743794b9 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 17:42:16 +0000 Subject: [PATCH 6/9] Test inline linter warnings --- Dangerfile.swift | 3 +-- Sources/XMLCoder/Encoder/EncodingErrorExtension.swift | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Dangerfile.swift b/Dangerfile.swift index 401ccbc5..b98272a9 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -3,6 +3,5 @@ import Danger SwiftLint.lint( inline: true, configFile: ".swiftlint.yml", - strict: true, - lintAllFiles: true + strict: true ) diff --git a/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift b/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift index fcda79c0..e22cae3f 100644 --- a/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift +++ b/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift @@ -26,11 +26,7 @@ extension EncodingError { valueDescription = "\(T.self).nan" } - let debugDescription = """ - Unable to encode \(valueDescription) directly in XML. \ - Use XMLEncoder.NonConformingFloatEncodingStrategy.convertToString \ - to specify how the value should be encoded. - """ + let debugDescription = "Unable to encode \(valueDescription) directly in XML. Use XMLEncoder.NonConformingFloatEncodingStrategy.convertToString to specify how the value should be encoded." return .invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: debugDescription)) } } From 5dd01a20d605cb5a893efd07451b45e2fe403de3 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 18:24:13 +0000 Subject: [PATCH 7/9] Revert "Test inline linter warnings" This reverts commit 7f863be336a2f4bdaecb35e5299499fb743794b9. --- Sources/XMLCoder/Encoder/EncodingErrorExtension.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift b/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift index e22cae3f..fcda79c0 100644 --- a/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift +++ b/Sources/XMLCoder/Encoder/EncodingErrorExtension.swift @@ -26,7 +26,11 @@ extension EncodingError { valueDescription = "\(T.self).nan" } - let debugDescription = "Unable to encode \(valueDescription) directly in XML. Use XMLEncoder.NonConformingFloatEncodingStrategy.convertToString to specify how the value should be encoded." + let debugDescription = """ + Unable to encode \(valueDescription) directly in XML. \ + Use XMLEncoder.NonConformingFloatEncodingStrategy.convertToString \ + to specify how the value should be encoded. + """ return .invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: debugDescription)) } } From 2bffb8f3f9adcc2220fcb7fef40de07acc9f98e7 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 18:25:15 +0000 Subject: [PATCH 8/9] Avoid installing and running SwiftLint on Azure --- lint.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lint.sh b/lint.sh index 08e52b35..8681785b 100755 --- a/lint.sh +++ b/lint.sh @@ -4,7 +4,6 @@ set -e set -o pipefail brew update -brew install swiftformat swiftlint +brew install swiftformat swiftformat --lint --verbose . -swiftlint From e4ac62ce6031ac77752aba746fa96f6dedd3e2ba Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sun, 22 Mar 2020 18:35:50 +0000 Subject: [PATCH 9/9] Fix formatter issues --- Dangerfile.swift | 6 +----- Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift | 2 +- Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift | 2 +- .../XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift | 8 ++++---- Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift | 2 +- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Dangerfile.swift b/Dangerfile.swift index b98272a9..8fbce09b 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -1,7 +1,3 @@ import Danger -SwiftLint.lint( - inline: true, - configFile: ".swiftlint.yml", - strict: true -) +SwiftLint.lint(inline: true, configFile: ".swiftlint.yml", strict: true) diff --git a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift index b6756dfa..6eec8951 100644 --- a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift +++ b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift @@ -71,7 +71,7 @@ class XMLDecoderImplementation: Decoder { } public func container(keyedBy keyType: Key.Type) throws -> KeyedDecodingContainer { - if let keyed = try self.topContainer() as? SharedBox { + if let keyed = try topContainer() as? SharedBox { return KeyedDecodingContainer(XMLKeyedDecodingContainer( referencing: self, wrapping: keyed diff --git a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift index 7aea290d..3fbcac10 100644 --- a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift +++ b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift @@ -227,7 +227,7 @@ extension XMLKeyedDecodingContainer { _ type: T.Type, forKey key: Key ) throws -> T { - guard let strategy = self.decoder.nodeDecodings.last else { + guard let strategy = decoder.nodeDecodings.last else { preconditionFailure( """ Attempt to access node decoding strategy from empty stack. diff --git a/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift b/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift index 71300449..09e37da3 100644 --- a/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift +++ b/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift @@ -48,7 +48,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { public mutating func decodeNil() throws -> Bool { guard !isAtEnd else { throw DecodingError.valueNotFound(Any?.self, DecodingError.Context( - codingPath: decoder.codingPath + [XMLKey(index: self.currentIndex)], + codingPath: decoder.codingPath + [XMLKey(index: currentIndex)], debugDescription: "Unkeyed container is at end." )) } @@ -75,7 +75,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { _ type: T.Type, decode: (XMLDecoderImplementation, Box) throws -> T? ) throws -> T { - guard let strategy = self.decoder.nodeDecodings.last else { + guard let strategy = decoder.nodeDecodings.last else { preconditionFailure("Attempt to access node decoding strategy from empty stack.") } decoder.codingPath.append(XMLKey(index: currentIndex)) @@ -90,7 +90,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { } guard !isAtEnd else { throw DecodingError.valueNotFound(type, DecodingError.Context( - codingPath: decoder.codingPath + [XMLKey(index: self.currentIndex)], + codingPath: decoder.codingPath + [XMLKey(index: currentIndex)], debugDescription: "Unkeyed container is at end." )) } @@ -128,7 +128,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { guard let decoded: T = value else { throw DecodingError.valueNotFound(type, DecodingError.Context( - codingPath: decoder.codingPath + [XMLKey(index: self.currentIndex)], + codingPath: decoder.codingPath + [XMLKey(index: currentIndex)], debugDescription: "Expected \(type) but found null instead." )) } diff --git a/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift b/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift index de04a225..e1378cb5 100644 --- a/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift +++ b/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift @@ -91,7 +91,7 @@ struct XMLKeyedEncodingContainer: KeyedEncodingContainerProtocol { _ = self.encoder.nodeEncodings.removeLast() self.encoder.codingPath.removeLast() } - guard let strategy = self.encoder.nodeEncodings.last else { + guard let strategy = encoder.nodeEncodings.last else { preconditionFailure( "Attempt to access node encoding strategy from empty stack." )