Skip to content

Commit

Permalink
Initial version.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobergj committed Jan 9, 2023
1 parent 6fd632a commit cf7b65f
Show file tree
Hide file tree
Showing 1,579 changed files with 1,404 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode
.netrc
1 change: 1 addition & 0 deletions .swiftlint-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.53.1
57 changes: 57 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
excluded:
- .build

opt_in_rules:
- discouraged_optional_collection
- discouraged_optional_boolean

disabled_rules:
- function_body_length
- type_body_length
- unused_optional_binding
- cyclomatic_complexity
- function_parameter_count
- force_cast
- force_try
- force_unwrapping
- trailing_comma
- large_tuple

line_length:
warning: 120

file_length:
warning: 800
error: 1200

type_name:
min_length: 2
max_length:
warning: 45
error: 60

identifier_name:
max_length: 45
allowed_symbols:
- _
excluded:
- id
- vc
- x
- y
- ok
- on
- os
- by
- qr
- x1
- x2
- y1
- y2
- to
- dp
- up
- pi
- ps
- i
- j
1 change: 1 addition & 0 deletions .xcode-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.2.0
23 changes: 23 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "fddd1c00396eed152c45a46bea9f47b98e59301d",
"version" : "1.2.0"
}
},
{
"identity" : "xcresultkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/davidahouse/XCResultKit",
"state" : {
"revision" : "3c8206371aa630248afddd085cce036b625c1455",
"version" : "1.0.1"
}
}
],
"version" : 2
}
41 changes: 41 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// swift-tools-version: 5.7
import PackageDescription

let package = Package(
name: "xcresult-to-json",
platforms: [
.macOS(.v12),
],
products: [
.executable(name: "xcresult-to-json", targets: ["XCResultToJson"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/davidahouse/XCResultKit", exact: "1.0.1"),
],
targets: [
.executableTarget(
name: "XCResultToJson",
dependencies: [
.target(name: "XCResultToJsonLib"),
]
),
.target(
name: "XCResultToJsonLib",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "XCResultKit", package: "XCResultKit"),
]
),
.testTarget(
name: "XCResultToJsonTests",
dependencies: [
"XCResultToJson",
"XCResultToJsonLib"
],
resources: [
.copy("Resources/xcresult"),
]
)
]
)
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# xcresult-to-json

A macOS command line tool that parses an Xcode-generated xcresult bundle and outputs a summarizing json for CI.

## Example usage

```
xcodebuild build -resultBundlePath "build.xcresult"
xcresult-to-json build.xcresult --path-root $PWD
```

For more options see:
```
xcresult-to-json --help
```

## Runtime dependencies

* Requires Xcode to be installed
- [XCResultKit](https://github.com/davidahouse/XCResultKit), that is used to
parse the xcresult bundle, internally runs `xcrun xcresulttool`.

## Output format

The json that is written to `stdout` is described by [a Json Schema file](Schema/output.json)

109 changes: 109 additions & 0 deletions Schema/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "xcresult-to-json output",
"type": "object",
"properties": {
"metrics": {
"$ref": "#/$defs/metrics"
},
"annotations": {
"type": "array",
"items": {
"$ref": "#/$defs/annotation"
}
}
},
"required": [
"annotations",
"errors"
],
"$defs": {
"metrics": {
"type": "object",
"properties": {
"analyzerWarningCount": {
"type": "integer"
},
"errorCount": {
"type": "integer"
},
"testCount": {
"type": "integer"
},
"testFailedCount": {
"type": "integer"
},
"testSkippedCount": {
"type": "integer"
},
"warningCount": {
"type": "integer"
}
},
"required": [
"analyzerWarningCount",
"errorCount",
"testCount",
"testFailedCount",
"testSkippedCount",
"warningCount"
]
},
"annotation": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "The file path"
},
"location": {
"$ref": "#/$defs/sourceLocation"
},
"annotationLevel": {
"type": "string",
"description": "The level of the annotation.",
"enum": [
"notice",
"warning",
"failure"
]
},
"message": {
"type": "string",
"description": "A short description"
},
"title": {
"type": "string",
"description": "Title",
"maxLength": 255
}
},
"required": [
"annotationLevel",
"message",
"title"
]
},
"sourceLocation": {
"type": "object",
"properties": {
"startLine": {
"type": "integer"
},
"endLine": {
"type": "integer"
},
"startColumn": {
"type": "integer"
},
"endColumn": {
"type": "integer"
}
},
"required": [
"startLine",
"endLine"
]
}
}
}
3 changes: 3 additions & 0 deletions Sources/XCResultToJson/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import XCResultToJsonLib

XCResultToJsonLib.main()
9 changes: 9 additions & 0 deletions Sources/XCResultToJsonLib/Output+Json.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

extension Output {
var json: Data {
let encoder = JSONEncoder()
encoder.outputFormatting = [.sortedKeys, .prettyPrinted]
return try! encoder.encode(self)
}
}
Loading

0 comments on commit cf7b65f

Please sign in to comment.