Skip to content

Commit

Permalink
Run Danger with GitHub Actions (CoreOffice#163)
Browse files Browse the repository at this point in the history
* Run Danger with GitHub Actions

* Add Dangerfile.swift, GitHub token to main.yml

* Add newline to Dangerfile.swift

* Set latest version of Danger in main.yml

* Attempt to use forked danger-swift with Swiftlint

* Test inline linter warnings

* Revert "Test inline linter warnings"

This reverts commit 7f863be.

* Avoid installing and running SwiftLint on Azure

* Fix formatter issues
  • Loading branch information
MaxDesiatov authored and Arjun Gupta committed Jun 26, 2020
1 parent 17e1ccf commit 2607788
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 9 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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: maxdesiatov/danger-swift@swiftlint-docker
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Danger

SwiftLint.lint(inline: true, configFile: ".swiftlint.yml", strict: true)
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class XMLDecoderImplementation: Decoder {
}

public func container<Key>(keyedBy keyType: Key.Type) throws -> KeyedDecodingContainer<Key> {
if let keyed = try self.topContainer() as? SharedBox<KeyedBox> {
if let keyed = try topContainer() as? SharedBox<KeyedBox> {
return KeyedDecodingContainer(XMLKeyedDecodingContainer<Key>(
referencing: self,
wrapping: keyed
Expand Down
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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."
))
}
Expand All @@ -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))
Expand All @@ -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."
))
}
Expand Down Expand Up @@ -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."
))
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct XMLKeyedEncodingContainer<K: CodingKey>: 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."
)
Expand Down
3 changes: 1 addition & 2 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -e
set -o pipefail

brew update
brew install swiftformat swiftlint
brew install swiftformat

swiftformat --lint --verbose .
swiftlint

0 comments on commit 2607788

Please sign in to comment.