Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/scripts/format.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env swift

// Workflow commands for GitHub Actions
// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions

let regex = #/(?<file>.+\.swift):(?<line>\d+):(?<column>\d+): (?<severity>.+): \[(?<title>.+)\] (?<message>.+)/#
while let line = readLine() {
if let match = try? regex.firstMatch(in: line) {
let (_, file, line, column, severity, title, message) = match.output
print("::\(severity) file=\(file),line=\(line),col=\(column),title=\(title)::\(message)")
} else {
print(line)
}
}
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v7
- name: Build and test
shell: bash
env:
Expand All @@ -29,5 +29,13 @@ jobs:
container:
image: swift:6.3.3
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- run: swift test
Lint:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: swift-format lint
run: make lint 2>&1 | .github/scripts/format.swift
shell: bash
79 changes: 79 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentBlankLines" : false,
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"indentation" : {
"spaces" : 4
},
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : false,
"lineBreakBeforeEachGenericRequirement" : false,
"lineBreakBetweenDeclarationAttributes" : false,
"lineLength" : 120,
"maximumBlankLines" : 1,
"multiElementCollectionTrailingCommas" : true,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow"
]
},
"orderedImports" : {
"includeConditionalImports" : false
},
"prioritizeKeepingFunctionOutputTogether" : false,
"reflowMultilineStringLiterals" : "never",
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : true,
"AmbiguousTrailingClosureOverload" : true,
"AvoidRetroactiveConformances" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyLinesOpeningClosingBraces" : false,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoPlaygroundLiterals" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : false,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"TypeNamesShouldBeCapitalized" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : true,
"UseLetInEveryBoundCaseVariable" : true,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : true,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
},
"spacesAroundRangeFormationOperators" : false,
"spacesBeforeEndOfLineComments" : 1,
"tabWidth" : 8,
"version" : 1
}
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
.PHONY: clean test lint format

test:
swift test --enable-code-coverage
./.github/scripts/codecov.sh $(shell swift test --show-codecov-path)

clean:
swift package clean

# MARK: - format

lint:
xcrun swift-format lint --recursive --strict ./

format:
xcrun swift-format --recursive --in-place ./
7 changes: 3 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import PackageDescription
let package = Package(
name: "XSTooling",
platforms: [
.macOS(.v10_15),
.macOS(.v10_15)
],
products: [
.library(
name: "XSTooling",
targets: ["XSTooling"]),
],
dependencies: [
targets: ["XSTooling"])
],
dependencies: [],
targets: [
.target(
name: "XSTooling",
Expand Down
2 changes: 1 addition & 1 deletion Sources/XSTooling/ProcessCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct ProcessCommand: Hashable, Sendable {

/// The receiver’s executable.
public var executableURL: URL

/// The command arguments that the system uses to launch the executable.
public var arguments: [String]

Expand Down
18 changes: 10 additions & 8 deletions Tests/XSToolingTests/GHTest/GHTestCase.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// GHTestCase.swift
//
//
//
// Created by Alexander Ignatiev on 12.12.2022.
//
Expand All @@ -11,23 +11,25 @@ class GHTestCase: XCTestCase {
var github: GHActions { .shared }

var isLinux: Bool {
#if os(Linux)
#if os(Linux)
return true
#else
#else
return false
#endif
#endif
}

#if os(Linux)
#if os(Linux)

override func recordFailure(withDescription description: String, inFile filePath: String, atLine lineNumber: Int, expected: Bool) {
override func recordFailure(
withDescription description: String, inFile filePath: String, atLine lineNumber: Int, expected: Bool
) {
if github.isEnabled {
github.error(file: filePath, line: lineNumber, message: description)
}
super.recordFailure(withDescription: description, inFile: filePath, atLine: lineNumber, expected: expected)
}

#else // os(Darwin)
#else // os(Darwin)

override func record(_ issue: XCTIssue) {
if github.isEnabled {
Expand All @@ -41,5 +43,5 @@ class GHTestCase: XCTestCase {
super.record(issue)
}

#endif
#endif
}
2 changes: 1 addition & 1 deletion Tests/XSToolingTests/ShellTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class ShellTests: GHTestCase {

func testZsh() async throws {
try XCTSkipIf(isLinux)

shell = Shell.zsh
XCTAssertEqual(shell.path, "/bin/zsh")

Expand Down