Skip to content

Commit

Permalink
Merge pull request #7 from AppDifferentia/configure-release
Browse files Browse the repository at this point in the history
Configure release
  • Loading branch information
weisunOW authored Sep 6, 2021
2 parents 44bd54f + ba607ec commit a8e4f06
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 60 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/gha_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: npm install -g danger
- run: swift build --product Danger --disable-sandbox -c release
- run: swift run danger-swift ci -c release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -24,7 +23,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: npm install -g danger
- run: swift build --product Danger
- run: swift test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -35,7 +33,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: npm install -g danger
- run: swift build --product Danger
- run: swift test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 12 additions & 10 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ let filesToLint = (danger.git.modifiedFiles + danger.git.createdFiles)

SwiftLint.lint(.files(filesToLint), inline: true)

// Support running via `danger local`
// Only run GitHub related checks when GitHub dsl is available. This allows `danger-swift local` to work.
guard let github = danger.github else {
warn("Unable to parse GitHub DSL response, the GitHub related checks will be skipped. (i.e. running `danger-swift local`).")
exit(0)
}

if let github = danger.github {
// These checks only happen on a PR
let foundWIPMessageInTitle = github.pullRequest.title.contains("Work In Progress")
// These checks only happen on a PR
let foundWIPMessageInTitle = github.pullRequest.title.contains("Work In Progress")
|| github.pullRequest.title.contains("WIP")
let foundWIPLabel = github.issue.labels.contains {
$0.name.contains("Work In Progress")
}
let foundWIPLabel = github.issue.labels.contains {
$0.name.contains("Work In Progress")
}

if foundWIPMessageInTitle || foundWIPLabel {
warn("PR is classed as Work in Progress")
}
if foundWIPMessageInTitle || foundWIPLabel {
warn("PR is classed as Work in Progress")
}
63 changes: 54 additions & 9 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"object": {
"pins": [
{
"package": "Komondor",
"repositoryURL": "https://github.com/shibapm/Komondor",
"state": {
"branch": null,
"revision": "1bb467ad7ad57e94af82d73fa0fe063cb0b8ddd5",
"version": "1.1.0"
}
},
{
"package": "Logger",
"repositoryURL": "https://github.com/shibapm/Logger",
Expand All @@ -19,6 +28,15 @@
"version": "0.11.0"
}
},
{
"package": "PackageConfig",
"repositoryURL": "https://github.com/shibapm/PackageConfig.git",
"state": {
"branch": null,
"revision": "bf90dc69fa0792894b08a0b74cf34029694ae486",
"version": "0.13.0"
}
},
{
"package": "RequestKit",
"repositoryURL": "https://github.com/nerdishbynature/RequestKit.git",
Expand All @@ -28,6 +46,24 @@
"version": "2.4.0"
}
},
{
"package": "Rocket",
"repositoryURL": "https://github.com/shibapm/Rocket",
"state": {
"branch": null,
"revision": "51a77ce5fa66c42715c14dcc542c01cd7a60fb27",
"version": "1.2.0"
}
},
{
"package": "ShellOut",
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
"state": {
"branch": null,
"revision": "e1577acf2b6e90086d01a6d5e2b8efdaae033568",
"version": "2.3.0"
}
},
{
"package": "SourceKitten",
"repositoryURL": "https://github.com/jpsim/SourceKitten.git",
Expand Down Expand Up @@ -55,6 +91,15 @@
"version": "0.3.2"
}
},
{
"package": "SwiftFormat",
"repositoryURL": "https://github.com/nicklockwood/SwiftFormat",
"state": {
"branch": null,
"revision": "a9bdfd2548ebe518a693a5c6341d27c42b7e7a0a",
"version": "0.48.11"
}
},
{
"package": "SwiftLint",
"repositoryURL": "https://github.com/realm/SwiftLint",
Expand All @@ -64,6 +109,15 @@
"version": "0.43.1"
}
},
{
"package": "SwiftShell",
"repositoryURL": "https://github.com/kareman/SwiftShell",
"state": {
"branch": null,
"revision": "a6014fe94c3dbff0ad500e8da4f251a5d336530b",
"version": "5.1.0-beta.1"
}
},
{
"package": "SwiftyTextTable",
"repositoryURL": "https://github.com/scottrhoyt/SwiftyTextTable.git",
Expand All @@ -90,15 +144,6 @@
"revision": "200046c93f6d5d78a6d72bfd9c0b27a95e9c0a2b",
"version": "1.2.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version": "4.0.6"
}
}
]
},
Expand Down
40 changes: 29 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ import PackageDescription
let package = Package(
name: "DangerSwiftJira",
products: [
.library(
name: "DangerSwiftJira",
targets: ["DangerSwiftJira"]
),
.library(name: "DangerDependencies", type: .dynamic, targets: ["DangerDependencies"]),
.library(name: "DangerSwiftJira", targets: ["DangerSwiftJira"]),
.library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]), // dev
],
dependencies: [
.package(name: "danger-swift", url: "https://github.com/danger/swift", from: "3.0.0"),
.package(url: "https://github.com/realm/SwiftLint", .upToNextMajor(from: "0.43.0")),
// Dev dependencies.
.package(url: "https://github.com/shibapm/Komondor", from: "1.0.0"), // dev
.package(url: "https://github.com/shibapm/Rocket", from: "1.2.0"), // dev
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.48.0"), // dev
.package(url: "https://github.com/realm/SwiftLint", from: "0.43.0"), // dev
],
targets: [
.target(name: "DangerDependencies", dependencies: ["danger-swift"]),
.target(
name: "DangerSwiftJira",
dependencies: ["danger-swift"]
),
.target(name: "DangerDependencies", dependencies: [.product(name: "Danger", package: "danger-swift")]), // dev
.target(name: "DangerSwiftJira", dependencies: [.product(name: "Danger", package: "danger-swift")]),
.testTarget(
name: "DangerSwiftJiraTests",
dependencies: [
Expand All @@ -30,3 +28,23 @@ let package = Package(
),
]
)

#if canImport(PackageConfig)
import PackageConfig

let config = PackageConfiguration([
"komondor": [
"pre-commit": [
"swift test --generate-linuxmain",
"swift run swiftformat .",
"swift run swiftlint autocorrect --path Sources/",
"git add .",
],
],
"rocket": [
"after": [
"push",
],
],
]).write()
#endif
4 changes: 1 addition & 3 deletions Sources/DangerSwiftJira/DangerSwiftJira.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Danger
import Foundation

public final class DangerSwiftJira {

private let danger: DangerDSL

private lazy var prTitle: String = {
Expand Down Expand Up @@ -80,7 +79,7 @@ public final class DangerSwiftJira {

if shouldSearchCommit {
danger.git.commits
.map { $0.message }
.map(\.message)
.forEach(findJiraIssue(in:))
}

Expand Down Expand Up @@ -115,5 +114,4 @@ public final class DangerSwiftJira {
let href = url.appendingPathComponent(issue)
return "<a href=\(href.absoluteString)>\(issue)</a>"
}

}
6 changes: 2 additions & 4 deletions Tests/DangerSwiftJiraTests/DangerSwiftJiraGitHubTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import XCTest
@testable import DangerSwiftJira
@testable import Danger
import DangerFixtures
@testable import DangerSwiftJira
import XCTest

final class DangerSwiftJiraGitHubTests: XCTestCase {

private var dangerDSL: DangerDSL!

override func setUpWithError() throws {
Expand Down Expand Up @@ -65,5 +64,4 @@ final class DangerSwiftJiraGitHubTests: XCTestCase {
let jiraHtmlLink = dangerJira.htmlLink(url: URL(string: "https://fakejira.mock")!, issue: "TEST-123")
XCTAssertEqual(jiraHtmlLink, "<a href=https://fakejira.mock/TEST-123>TEST-123</a>")
}

}
40 changes: 20 additions & 20 deletions Tests/DangerSwiftJiraTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#if !canImport(ObjectiveC)
import XCTest
import XCTest

extension DangerSwiftJiraGitHubTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DangerSwiftJiraGitHubTests = [
("testDoNotSkipJiraInPullRequest", testDoNotSkipJiraInPullRequest),
("testFindJiraIssueInPullRequestBody", testFindJiraIssueInPullRequestBody),
("testFindJiraIssueInPullRequestCommits", testFindJiraIssueInPullRequestCommits),
("testFindJiraIssueInPullRequestTitle", testFindJiraIssueInPullRequestTitle),
("testGenerateJiraLink", testGenerateJiraLink),
("testOnlyFindUniqueIssues", testOnlyFindUniqueIssues),
("testSkipJiraInPullRequest", testSkipJiraInPullRequest),
]
}
extension DangerSwiftJiraGitHubTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DangerSwiftJiraGitHubTests = [
("testDoNotSkipJiraInPullRequest", testDoNotSkipJiraInPullRequest),
("testFindJiraIssueInPullRequestBody", testFindJiraIssueInPullRequestBody),
("testFindJiraIssueInPullRequestCommits", testFindJiraIssueInPullRequestCommits),
("testFindJiraIssueInPullRequestTitle", testFindJiraIssueInPullRequestTitle),
("testGenerateJiraLink", testGenerateJiraLink),
("testOnlyFindUniqueIssues", testOnlyFindUniqueIssues),
("testSkipJiraInPullRequest", testSkipJiraInPullRequest),
]
}

public func __allTests() -> [XCTestCaseEntry] {
return [
testCase(DangerSwiftJiraGitHubTests.__allTests__DangerSwiftJiraGitHubTests),
]
}
public func __allTests() -> [XCTestCaseEntry] {
[
testCase(DangerSwiftJiraGitHubTests.__allTests__DangerSwiftJiraGitHubTests),
]
}
#endif

0 comments on commit a8e4f06

Please sign in to comment.