fastlane-plugin-xcodetestcoverage 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f505a1904cbee1d299c96a6546ccba7b5fb0ca24793c743d91513ee31979d34
|
4
|
+
data.tar.gz: 91a090e60bb6510e6af7ed52850ea30177faa3b87b58c46842a3193e04af3387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d5f90ab84f727386d65764df76464a9ac0a5d3e6647ee5ecc358a87050fc7e84a7280bc741fc74a54fc4f72172ce706d506717b97a0509b452cc08b9f0cbe9
|
7
|
+
data.tar.gz: 50d6728b59803e3cbeb9783b64483fd9fcf80b2d86f7952a1ffd4d2ce23f17ee39cffbf6c5e197cb397f6199e2cffa1fb763d8c0b728d16323a6c24c46384fd1
|
data/README.md
CHANGED
@@ -14,23 +14,56 @@ fastlane add_plugin xcodetestcoverage
|
|
14
14
|
|
15
15
|
Plugin for getting test data from Xcode
|
16
16
|
|
17
|
-
|
17
|
+
It has to be run after tests.
|
18
|
+
Returns hash contains keys: coverage, coveredLines, executableLines:
|
18
19
|
|
19
|
-
|
20
|
+
```bash
|
21
|
+
run_tests()
|
22
|
+
result = xcodetestcoverage()
|
23
|
+
puts(result["coverage"])
|
24
|
+
puts(result["coveredLines"])
|
25
|
+
puts(result["executableLines"])
|
26
|
+
```
|
20
27
|
|
21
|
-
|
28
|
+
parameters:
|
22
29
|
|
23
|
-
|
30
|
+
minimumCoveragePercentage - Minimum acceptable coverage percentage. Call coverageExceptionCallback. Then raise error if overall coverage percentage is under this value and the option enableDefaultCoverageException is enabled", type: Float, optional: true.
|
24
31
|
|
25
|
-
|
26
|
-
rake
|
27
|
-
```
|
32
|
+
enableDefaultCoverageException - Raise error if overall coverage percentage is under this minimumCoveragePercentage and this option is enabled, optional: true, default_value: true
|
28
33
|
|
29
|
-
|
34
|
+
enableDataFailedException - Raise error if can not read the test data and this option is enabled optional: true, default_value: false
|
35
|
+
|
36
|
+
dataFailedExceptionCallback - Optional data failed exception callback argument, optional: true,
|
37
|
+
type: Proc
|
38
|
+
|
39
|
+
coverageExceptionCallback - Optional coverage exception callback argument" optional: true, type: Proc
|
40
|
+
|
41
|
+
## Example
|
42
|
+
|
43
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane tests`.
|
44
|
+
|
45
|
+
If you need to throw an exception on coverage percantage, set the parameter minimumCoveragePercentage. If you want to call your code in this case set coverageExceptionCallback.
|
46
|
+
You can disable defaultException if you set enableDefaultCoverageException = false.
|
47
|
+
|
48
|
+
```bash
|
49
|
+
xcodetestcoverage(minimumCoveragePercentage: 40.0,
|
50
|
+
coverageExceptionCallback: ->(value) {
|
51
|
+
UI.message("Test coverage failed #{value}")
|
52
|
+
})
|
30
53
|
```
|
31
|
-
|
54
|
+
|
55
|
+
If you need to throw an exception on test data read error, set the parameter enableDataFailedException = true. If you want to call your code in this case set dataFailedExceptionCallback.
|
56
|
+
|
57
|
+
```bash
|
58
|
+
xcodetestcoverage(minimumCoveragePercentage: 45.0,
|
59
|
+
enableDataFailedException: true,
|
60
|
+
dataFailedExceptionCallback: ->() {
|
61
|
+
UI.message("Data reading error")
|
62
|
+
}
|
63
|
+
)
|
32
64
|
```
|
33
65
|
|
66
|
+
|
34
67
|
## Issues and Feedback
|
35
68
|
|
36
69
|
For any other issues and feedback about this plugin, please submit it to this repository.
|
@@ -5,42 +5,108 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class XcodetestcoverageAction < Action
|
7
7
|
def self.run(params)
|
8
|
-
|
8
|
+
enableDataFailedException = params[:enableDataFailedException]
|
9
|
+
minimumCoveragePercentage = params[:minimumCoveragePercentage]
|
10
|
+
enableDefaultCoverageException = params[:enableDefaultCoverageException]
|
11
|
+
lineCoverage = nil
|
12
|
+
coveredLines = nil
|
13
|
+
executableLines = nil
|
14
|
+
|
15
|
+
filePath = lane_context[SharedValues::SCAN_DERIVED_DATA_PATH]
|
16
|
+
|
17
|
+
if filePath && File.exists?(filePath)
|
18
|
+
jsonResult = sh "xcrun xccov view --only-targets --report #{filePath} --json"
|
19
|
+
if lineCoverageMatch = jsonResult.match('.*lineCoverage":(\d+.\d+).*')
|
20
|
+
lineCoverage = lineCoverageMatch.captures[0].to_f * 100
|
21
|
+
UI.message("Xcodetestcoverage: coverage: #{lineCoverage}")
|
22
|
+
end
|
23
|
+
|
24
|
+
if coveredLinesMatch = jsonResult.match('.*coveredLines":(\d+).*')
|
25
|
+
coveredLines = coveredLinesMatch.captures[0].to_i
|
26
|
+
UI.message("Xcodetestcoverage: coveredLines: #{coveredLines}")
|
27
|
+
end
|
28
|
+
|
29
|
+
if executableLineMatch = jsonResult.match('.*executableLines":(\d+).*')
|
30
|
+
executableLines = executableLineMatch.captures[0].to_i
|
31
|
+
UI.message("Xcodetestcoverage: executableLines: #{executableLines}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if !lineCoverage
|
36
|
+
params[:dataFailedExceptionCallback].call() if params[:dataFailedExceptionCallback]
|
37
|
+
UI.user_error!("Xcodetestcoverage: Test data reading error!") if enableDataFailedException
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
if minimumCoveragePercentage && lineCoverage < minimumCoveragePercentage
|
42
|
+
params[:coverageExceptionCallback].call(minimumCoveragePercentage) if params[:coverageExceptionCallback]
|
43
|
+
UI.user_error!("Xcodetestcoverage: Coverage percentage is less than #{minimumCoveragePercentage} (minimumCoveragePercentage)") if enableDefaultCoverageException
|
44
|
+
end
|
45
|
+
|
46
|
+
return {
|
47
|
+
"coverage" => lineCoverage,
|
48
|
+
"coveredLines" => coveredLines,
|
49
|
+
"executableLines" => executableLines,
|
50
|
+
}
|
9
51
|
end
|
10
52
|
|
11
53
|
def self.description
|
12
|
-
"plugin for getting test data from Xcode"
|
54
|
+
"plugin for getting coverage test data from Xcode"
|
13
55
|
end
|
14
56
|
|
15
57
|
def self.authors
|
16
58
|
["Yury Savitsky"]
|
17
59
|
end
|
18
60
|
|
19
|
-
def self.return_value
|
20
|
-
|
61
|
+
def self.return_value
|
62
|
+
"returns hash contains keys: coverage, coveredLines, executableLines"
|
21
63
|
end
|
22
64
|
|
23
65
|
def self.details
|
24
|
-
# Optional:
|
25
66
|
"plugin for getting test data from Xcode"
|
26
67
|
end
|
27
68
|
|
28
69
|
def self.available_options
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
70
|
+
[
|
71
|
+
FastlaneCore::ConfigItem.new(
|
72
|
+
key: :minimumCoveragePercentage,
|
73
|
+
env_name: "XCODETESTCOVERAGE_MINIMUM_COVERAGE_PERCENTAGE",
|
74
|
+
description: "Minimum acceptable coverage percentage. Call coverageExceptionCallback. Then raise error if overall coverage percentage is under this value and the option enableDefaultCoverageException is enabled",
|
75
|
+
type: Float,
|
76
|
+
optional: true),
|
77
|
+
|
78
|
+
FastlaneCore::ConfigItem.new(
|
79
|
+
key: :enableDefaultCoverageException,
|
80
|
+
env_name: "XCODETESTCOVERAGE_ENABLE_DEFAULT_COVERAGE_EXCEPTION",
|
81
|
+
description: "Raise error if overall coverage percentage is under this minimumCoveragePercentage and this option is enabled",
|
82
|
+
optional: true,
|
83
|
+
default_value: true,
|
84
|
+
is_string: false),
|
85
|
+
|
86
|
+
FastlaneCore::ConfigItem.new(
|
87
|
+
key: :enableDataFailedException,
|
88
|
+
env_name: "XCODETESTCOVERAGE_ENABLE_DATA_FAILED_EXCEPTION",
|
89
|
+
description: "Raise error if can not read the test data and this option is enabled",
|
90
|
+
optional: true,
|
91
|
+
default_value: false,
|
92
|
+
is_string: false),
|
93
|
+
|
94
|
+
FastlaneCore::ConfigItem.new(
|
95
|
+
key: :dataFailedExceptionCallback,
|
96
|
+
description: "Optional data failed exception callback argument",
|
97
|
+
optional: true,
|
98
|
+
type: Proc),
|
99
|
+
|
100
|
+
FastlaneCore::ConfigItem.new(
|
101
|
+
key: :coverageExceptionCallback,
|
102
|
+
description: "Optional coverage exception callback argument",
|
103
|
+
optional: true,
|
104
|
+
type: Proc)
|
35
105
|
]
|
36
106
|
end
|
37
107
|
|
38
108
|
def self.is_supported?(platform)
|
39
|
-
|
40
|
-
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
41
|
-
#
|
42
|
-
# [:ios, :mac, :android].include?(platform)
|
43
|
-
true
|
109
|
+
[:ios, :mac].include?(platform)
|
44
110
|
end
|
45
111
|
end
|
46
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-xcodetestcoverage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Savitsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|