Skip to content

Commit 3760117

Browse files
authored
Add MTE-528 [v111] Include dangerfile to CI (#13018)
* Add MTE-528 [v111] Include dangerfile to CI * use pre built test without building * deploy pipeline_intermediate_files * use fennec scheme * add unit test to Fennec * Browserkit unit tests * fix spelling error
1 parent 3418f69 commit 3760117

File tree

9 files changed

+383
-234
lines changed

9 files changed

+383
-234
lines changed

BrowserKit/Package.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ let package = Package(
3535
targets: [
3636
.target(
3737
name: "SiteImageView",
38-
dependencies: ["Fuzi", "Kingfisher", "Common"]),
38+
dependencies: ["Fuzi", "Kingfisher", "Common"],
39+
swiftSettings: [.unsafeFlags(["-enable-testing"])]),
3940
.testTarget(
4041
name: "SiteImageViewTests",
4142
dependencies: ["SiteImageView"]),
4243
.target(
4344
name: "Common",
44-
dependencies: ["Dip"]),
45+
dependencies: ["Dip"],
46+
swiftSettings: [.unsafeFlags(["-enable-testing"])]),
4547
.testTarget(
4648
name: "CommonTests",
4749
dependencies: ["Common"]),

Client.xcodeproj/project.pbxproj

+22
Original file line numberDiff line numberDiff line change
@@ -3551,6 +3551,8 @@
35513551
9614BF4328AD1C6700D3F7EA /* AccountSyncHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSyncHandler.swift; sourceTree = "<group>"; };
35523552
962021E028B8078400BDF3D9 /* ContextualHintCopyProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualHintCopyProvider.swift; sourceTree = "<group>"; };
35533553
962A450E9186BF349E535413 /* sat-Olck */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "sat-Olck"; path = "sat-Olck.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
3554+
962C6C39297054A700354BE8 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
3555+
962C6C3F2971F5D400354BE8 /* Dangerfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dangerfile.swift; sourceTree = "<group>"; };
35543556
962F39492672D57A006BDA2A /* RecentItemsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentItemsHelper.swift; sourceTree = "<group>"; };
35553557
9636D92727F5D72D00771F5E /* GleanPlumbMessageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GleanPlumbMessageManager.swift; sourceTree = "<group>"; };
35563558
9636D92927F767EC00771F5E /* GleanPlumbMessageUtility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GleanPlumbMessageUtility.swift; sourceTree = "<group>"; };
@@ -4393,6 +4395,7 @@
43934395
D4BF6AB92893DDAA001B5130 /* en-US */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "en-US"; path = "en-US.lproj/Today.strings"; sourceTree = "<group>"; };
43944396
D4C35390283500A600F7DC7D /* TabsPerformanceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsPerformanceTests.swift; sourceTree = "<group>"; };
43954397
D4C4BDCD2253725E00986F04 /* LibraryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryTests.swift; sourceTree = "<group>"; };
4398+
D4F389132981634F0082E974 /* Fake.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fake.swift; sourceTree = "<group>"; };
43964399
D4F3D788232F960600FBB9AA /* WhatsNewTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatsNewTest.swift; sourceTree = "<group>"; };
43974400
D50268E825D1AE2D00026CDA /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
43984401
D50268E925D1AE2D00026CDA /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/BookmarkPanel.strings; sourceTree = "<group>"; };
@@ -6705,6 +6708,22 @@
67056708
path = ContextualHints;
67066709
sourceTree = "<group>";
67076710
};
6711+
962C6C3B297054EC00354BE8 /* Sources */ = {
6712+
isa = PBXGroup;
6713+
children = (
6714+
962C6C3E2970551000354BE8 /* DangerDependencies */,
6715+
);
6716+
path = Sources;
6717+
sourceTree = "<group>";
6718+
};
6719+
962C6C3E2970551000354BE8 /* DangerDependencies */ = {
6720+
isa = PBXGroup;
6721+
children = (
6722+
D4F389132981634F0082E974 /* Fake.swift */,
6723+
);
6724+
path = DangerDependencies;
6725+
sourceTree = "<group>";
6726+
};
67086727
9636D92627F5D71A00771F5E /* Messaging */ = {
67096728
isa = PBXGroup;
67106729
children = (
@@ -8150,6 +8169,9 @@
81508169
F84B21B51A090F8100AAB793 = {
81518170
isa = PBXGroup;
81528171
children = (
8172+
962C6C39297054A700354BE8 /* Package.swift */,
8173+
962C6C3F2971F5D400354BE8 /* Dangerfile.swift */,
8174+
962C6C3B297054EC00354BE8 /* Sources */,
81538175
5A65BE172928619E00E841A7 /* BrowserKit */,
81548176
45D5EDC1292D636000311934 /* nimbus.fml.yaml */,
81558177
C8E2E80623D20FB3005AACE6 /* RustFxA */,

Client.xcodeproj/xcshareddata/xcschemes/Fennec.xcscheme

+18
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,24 @@
221221
ReferencedContainer = "container:Client.xcodeproj">
222222
</BuildableReference>
223223
</CodeCoverageTargets>
224+
<TestPlans>
225+
<TestPlanReference
226+
reference = "container:Tests/UnitTest.xctestplan"
227+
default = "YES">
228+
</TestPlanReference>
229+
<TestPlanReference
230+
reference = "container:Tests/SmokeXCUITests.xctestplan">
231+
</TestPlanReference>
232+
<TestPlanReference
233+
reference = "container:Tests/Smoketest4.xctestplan">
234+
</TestPlanReference>
235+
<TestPlanReference
236+
reference = "container:Tests/Smoketest2.xctestplan">
237+
</TestPlanReference>
238+
<TestPlanReference
239+
reference = "container:Tests/Smoketest3.xctestplan">
240+
</TestPlanReference>
241+
</TestPlans>
224242
<Testables>
225243
<TestableReference
226244
skipped = "YES">

Dangerfile.swift

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Danger
2+
import DangerSwiftCoverage
3+
import Foundation
4+
5+
let danger = Danger()
6+
7+
coverage()
8+
changedFiles()
9+
10+
func changedFiles() {
11+
message("Edited \(danger.git.modifiedFiles.count) files")
12+
message("Created \(danger.git.createdFiles.count) files")
13+
}
14+
15+
func coverage() {
16+
guard let xcresult = ProcessInfo.processInfo.environment["BITRISE_XCRESULT_PATH"]?.escapeString() else {
17+
fail("Could not get the BITRISE_XCRESULT_PATH to generate code coverage")
18+
return
19+
}
20+
21+
Coverage.xcodeBuildCoverage(
22+
.xcresultBundle(xcresult),
23+
minimumCoverage: 50
24+
)
25+
}
26+
27+
extension String {
28+
// Helper function to escape (iOS) in our file name for xcov.
29+
func escapeString() -> String {
30+
var newString = self.replacingOccurrences(of: "(", with: "\\(")
31+
newString = newString.replacingOccurrences(of: ")", with: "\\)")
32+
newString = newString.replacingOccurrences(of: " ", with: "\\ ")
33+
return newString
34+
}
35+
}

Package.resolved

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"pins" : [
3+
{
4+
"identity" : "danger-swift-coverage",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/f-meloni/danger-swift-coverage",
7+
"state" : {
8+
"revision" : "6a21a6e595e2b13443428942ce128b3ba6b827ee",
9+
"version" : "1.2.1"
10+
}
11+
},
12+
{
13+
"identity" : "logger",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/shibapm/Logger",
16+
"state" : {
17+
"revision" : "53c3ecca5abe8cf46697e33901ee774236d94cce",
18+
"version" : "0.2.3"
19+
}
20+
},
21+
{
22+
"identity" : "octokit.swift",
23+
"kind" : "remoteSourceControl",
24+
"location" : "https://github.com/nerdishbynature/octokit.swift",
25+
"state" : {
26+
"revision" : "f762f1566f7cd0e683b9329f169c28ab6ef993cc",
27+
"version" : "0.12.0"
28+
}
29+
},
30+
{
31+
"identity" : "requestkit",
32+
"kind" : "remoteSourceControl",
33+
"location" : "https://github.com/nerdishbynature/RequestKit.git",
34+
"state" : {
35+
"revision" : "8b0258ea2a4345cbcac90509b764faacea12efb0",
36+
"version" : "3.2.1"
37+
}
38+
},
39+
{
40+
"identity" : "swift",
41+
"kind" : "remoteSourceControl",
42+
"location" : "https://github.com/danger/swift.git",
43+
"state" : {
44+
"revision" : "0a4b52f4518974cbd2cc45c29d33cb54a303f81d",
45+
"version" : "3.15.0"
46+
}
47+
},
48+
{
49+
"identity" : "version",
50+
"kind" : "remoteSourceControl",
51+
"location" : "https://github.com/mxcl/Version",
52+
"state" : {
53+
"revision" : "1fe824b80d89201652e7eca7c9252269a1d85e25",
54+
"version" : "2.0.1"
55+
}
56+
}
57+
],
58+
"version" : 2
59+
}

Package.swift

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version:5.7
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "Danger",
7+
platforms: [.iOS("15"), .macOS("11")],
8+
products: [
9+
.library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]), // dev
10+
],
11+
dependencies: [
12+
.package(url: "https://github.com/danger/swift.git", exact: "3.15.0"), // dev
13+
.package(url: "https://github.com/f-meloni/danger-swift-coverage", exact: "1.2.1") // dev
14+
],
15+
targets: [
16+
.target(
17+
name: "DangerDependencies",
18+
dependencies: [
19+
.product(name: "Danger", package: "swift"),
20+
.product(name: "DangerSwiftCoverage", package: "danger-swift-coverage")
21+
]
22+
) // dev
23+
]
24+
)

Sources/DangerDependencies/Fake.swift

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/
4+
5+
import Foundation

Tests/UnitTest.xctestplan

+63-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,55 @@
99
}
1010
],
1111
"defaultOptions" : {
12-
"codeCoverage" : false
12+
"codeCoverage" : {
13+
"targets" : [
14+
{
15+
"containerPath" : "container:Client.xcodeproj",
16+
"identifier" : "F84B21BD1A090F8100AAB793",
17+
"name" : "Client"
18+
},
19+
{
20+
"containerPath" : "container:Client.xcodeproj",
21+
"identifier" : "2FA435FA1ABB83B4008031D1",
22+
"name" : "Account"
23+
},
24+
{
25+
"containerPath" : "container:Client.xcodeproj",
26+
"identifier" : "2FCAE2191ABB51F800877008",
27+
"name" : "Storage"
28+
},
29+
{
30+
"containerPath" : "container:Client.xcodeproj",
31+
"identifier" : "E69DB0741E97DEA9008A67E6",
32+
"name" : "SyncTelemetry"
33+
},
34+
{
35+
"containerPath" : "container:Client.xcodeproj",
36+
"identifier" : "397848DA1ED86605004C0C0B",
37+
"name" : "NotificationService"
38+
},
39+
{
40+
"containerPath" : "container:Client.xcodeproj",
41+
"identifier" : "F84B22481A0920C600AAB793",
42+
"name" : "ShareTo"
43+
},
44+
{
45+
"containerPath" : "container:Client.xcodeproj",
46+
"identifier" : "390527491C874D35007E0BB7",
47+
"name" : "Today"
48+
},
49+
{
50+
"containerPath" : "container:Client.xcodeproj",
51+
"identifier" : "047F9B2624E1FE1C00CD7DF7",
52+
"name" : "WidgetKitExtension"
53+
},
54+
{
55+
"containerPath" : "container:Client.xcodeproj",
56+
"identifier" : "F8324A042649A188007E4BFA",
57+
"name" : "CredentialProvider"
58+
}
59+
]
60+
}
1361
},
1462
"testTargets" : [
1563
{
@@ -71,6 +119,20 @@
71119
"identifier" : "282731671ABC9BE700AA1954",
72120
"name" : "SyncTests"
73121
}
122+
},
123+
{
124+
"target" : {
125+
"containerPath" : "container:BrowserKit",
126+
"identifier" : "CommonTests",
127+
"name" : "CommonTests"
128+
}
129+
},
130+
{
131+
"target" : {
132+
"containerPath" : "container:BrowserKit",
133+
"identifier" : "SiteImageViewTests",
134+
"name" : "SiteImageViewTests"
135+
}
74136
}
75137
],
76138
"version" : 1

0 commit comments

Comments
 (0)