Skip to content

Commit

Permalink
Add code coverage reporting to tests (#1412)
Browse files Browse the repository at this point in the history
Adds code coverage reports to pull requests. Enabling code coverage gathering appears to be about a 25% increase in build time, unfortunately, so just enabling it for the App/Shared targets and doing it in a separate scheme so it doesn't impact local build times.
  • Loading branch information
zacwest committed Jan 24, 2021
1 parent 5def7ad commit b80c874
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
- name: Run tests
run: bundle exec fastlane ios test

- uses: codecov/codecov-action@v1
name: "Upload Code Coverage"

- uses: actions/upload-artifact@v2
name: "Upload Test Logs"
if: ${{ always() }}
Expand Down
6 changes: 3 additions & 3 deletions HomeAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@
path = AppleWatch;
sourceTree = "<group>";
};
1141182824AFA0F000E6525C /* Request&Response */ = {
1141182824AFA0F000E6525C /* Networking */ = {
isa = PBXGroup;
children = (
1141182524AF9A0500E6525C /* WebhookManager.swift */,
Expand All @@ -1938,7 +1938,7 @@
117675EE252D5CA80047B1D3 /* WebhookResponseUpdateComplications.swift */,
11C4629524B19FC700031902 /* URLSessionTask+WebhookPersisted.swift */,
);
path = "Request&Response";
path = Networking;
sourceTree = "<group>";
};
1155DD07250F4100003405C0 /* Share */ = {
Expand Down Expand Up @@ -2924,7 +2924,7 @@
children = (
11AF4D0F249C7DD8006C74C0 /* Sensors */,
B6A258442232485300ADD202 /* Alamofire+EncryptedResponses.swift */,
1141182824AFA0F000E6525C /* Request&Response */,
1141182824AFA0F000E6525C /* Networking */,
);
path = Webhook;
sourceTree = "<group>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,24 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D03D891620E0A85200D4F28D"
BuildableName = "Shared.framework"
BlueprintName = "Shared-iOS"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B657A8E51CA646EB00121384"
BuildableName = "Home Assistant.app"
BlueprintName = "App"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
Expand Down
117 changes: 117 additions & 0 deletions HomeAssistant.xcodeproj/xcshareddata/xcschemes/Tests-Unit.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1220"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B657A8E51CA646EB00121384"
BuildableName = "Home Assistant.app"
BlueprintName = "App"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D03D891620E0A85200D4F28D"
BuildableName = "Shared.framework"
BlueprintName = "Shared-iOS"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B657A8E51CA646EB00121384"
BuildableName = "Home Assistant.app"
BlueprintName = "App"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B657A8FB1CA646EB00121384"
BuildableName = "Tests-App.xctest"
BlueprintName = "Tests-App"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D03D894120E0BC1800D4F28D"
BuildableName = "Tests-Shared.xctest"
BlueprintName = "Tests-Shared"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
migratedStopOnEveryIssue = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B657A8E51CA646EB00121384"
BuildableName = "Home Assistant.app"
BlueprintName = "App"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B657A8E51CA646EB00121384"
BuildableName = "Home Assistant.app"
BlueprintName = "App"
ReferencedContainer = "container:HomeAssistant.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
14 changes: 14 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
coverage:
status:
project:
shared:
paths:
- Sources/Shared
app:
paths:
- Sources/App
ignore:
- Sources/Shared/Resources
- Sources/App/Resources
- Tests
- Pods
3 changes: 1 addition & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ platform :ios do
lane :test do
run_tests(
workspace: 'HomeAssistant.xcworkspace',
scheme: 'App-Debug',
prelaunch_simulator: true,
scheme: 'Tests-Unit',
result_bundle: true
)
end
Expand Down

0 comments on commit b80c874

Please sign in to comment.