Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand AdHoc build workflow, add debug bookmarks screen #3086

Merged
merged 13 commits into from
Jul 17, 2024
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
17 changes: 15 additions & 2 deletions .github/workflows/adhoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ on:
description: "Asana task URL"
required: false
type: string
build-type:
description: "Build Configuration"
type: choice
required: true
default: 'Alpha'
options:
- Alpha
- Release

jobs:
make-adhoc:
Expand Down Expand Up @@ -41,10 +49,15 @@ jobs:
APPLE_API_KEY_ISSUER: ${{ secrets.APPLE_API_KEY_ISSUER }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
run: |
lane_to_use="adhoc"
if [[ "${{ github.event.inputs.build-type }}" == "Release" ]]; then
lane_to_use = "release_adhoc"
fi

if [[ -n "${{ github.event.inputs.suffix }}" ]]; then
bundle exec fastlane adhoc suffix:${{ github.event.inputs.suffix }}
bundle exec fastlane ${lane_to_use} suffix:${{ github.event.inputs.suffix }}
else
bundle exec fastlane adhoc
bundle exec fastlane ${lane_to_use}
fi

- name: Set filenames
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@
98A16C2D28A11D6200A6C003 /* BrowserServicesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 98A16C2C28A11D6200A6C003 /* BrowserServicesKit */; };
98A50962294B48A400D10880 /* Bookmarks in Frameworks */ = {isa = PBXBuildFile; productRef = 98A50961294B48A400D10880 /* Bookmarks */; };
98A54A8422AFCB2D00E541F4 /* Instruments.instrpkg in Sources */ = {isa = PBXBuildFile; fileRef = 98A54A8322AFCB2D00E541F4 /* Instruments.instrpkg */; };
98A860EF2C4682E00077FE4D /* BookmarksDebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A860EE2C4682E00077FE4D /* BookmarksDebugViewController.swift */; };
98AA92B32456FBE100ED4B9E /* SearchFieldContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AA92B22456FBE100ED4B9E /* SearchFieldContainerView.swift */; };
98AAF8E4292EB46000DBDF06 /* BookmarksMigrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AAF8E3292EB46000DBDF06 /* BookmarksMigrationTests.swift */; };
98B000532915C46E0034BCA0 /* LegacyBookmarksStoreMigration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B000522915C46E0034BCA0 /* LegacyBookmarksStoreMigration.swift */; };
Expand Down Expand Up @@ -2199,6 +2200,7 @@
989B337422D7EF2100437824 /* EmptyCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyCollectionReusableView.swift; sourceTree = "<group>"; };
98A54A8122AFCB2C00E541F4 /* Instruments.instrdst */ = {isa = PBXFileReference; explicitFileType = com.apple.instruments.instrdst; includeInIndex = 0; path = Instruments.instrdst; sourceTree = BUILT_PRODUCTS_DIR; };
98A54A8322AFCB2D00E541F4 /* Instruments.instrpkg */ = {isa = PBXFileReference; lastKnownFileType = "com.apple.instruments.package-definition"; path = Instruments.instrpkg; sourceTree = "<group>"; };
98A860EE2C4682E00077FE4D /* BookmarksDebugViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksDebugViewController.swift; sourceTree = "<group>"; };
98AA92B22456FBE100ED4B9E /* SearchFieldContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchFieldContainerView.swift; sourceTree = "<group>"; };
98AAF8E3292EB46000DBDF06 /* BookmarksMigrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksMigrationTests.swift; sourceTree = "<group>"; };
98AC5D8B251EAC07009B7979 /* hu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3936,6 +3938,7 @@
EE72CA842A862D000043B5B3 /* NetworkProtectionDebugViewController.swift */,
CBFCB30D2B2CD47800253E9E /* ConfigurationURLDebugViewController.swift */,
851624C62B96389D002D5CD7 /* HistoryDebugViewController.swift */,
98A860EE2C4682E00077FE4D /* BookmarksDebugViewController.swift */,
);
name = Debug;
sourceTree = "<group>";
Expand Down Expand Up @@ -6963,6 +6966,7 @@
31C70B5B2804C61000FB6AD1 /* SaveAutofillLoginManager.swift in Sources */,
982123502B6D233E00F08C57 /* UserSession.swift in Sources */,
85449EFD23FDA71F00512AAF /* KeyboardSettings.swift in Sources */,
98A860EF2C4682E00077FE4D /* BookmarksDebugViewController.swift in Sources */,
980891A222369ADB00313A70 /* FeedbackUserText.swift in Sources */,
1DEAADFF2BA7832F00E25A97 /* EmailProtectionView.swift in Sources */,
988F3DD3237DE8D900AEE34C /* ForgetDataAlert.swift in Sources */,
Expand Down
96 changes: 96 additions & 0 deletions DuckDuckGo/BookmarksDebugViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// BookmarksDebugViewController.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit
import SwiftUI
import Core
import Combine
import Persistence
import Bookmarks
import CoreData

class BookmarksDebugViewController: UIHostingController<BookmarksDebugRootView> {

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder, rootView: BookmarksDebugRootView())
}

}

struct BookmarksDebugRootView: View {

@ObservedObject var model = BookmarksDebugViewModel()

var body: some View {
List(model.bookmarks, id: \.id) { entry in
VStack(alignment: .leading) {
Text(entry.title ?? "empty!")
.font(.system(size: 16))
Text("Is unified fav: " + (entry.isFavorite(on: .unified) ? "true" : "false") )
.font(.system(size: 12))
Text("Is mobile fav: " + (entry.isFavorite(on: .mobile) ? "true" : "false") )
.font(.system(size: 12))
Text("Is desktop fav: " + (entry.isFavorite(on: .desktop) ? "true" : "false") )
.font(.system(size: 12))
ForEach(model.bookmarkAttributes, id: \.self) { attr in
Text(entry.formattedValue(for: attr))
.font(.system(size: 12))
}

}
}
.navigationTitle("\(model.bookmarks.count) Bookmarks")
}

}

extension BookmarkEntity {

func formattedValue(for key: String) -> String {
key + ": \'" + String(describing: value(forKey: key)) + "'"
}
}

class BookmarksDebugViewModel: ObservableObject {

@Published var bookmarks = [BookmarkEntity]()
let bookmarkAttributes: [String]

let database: CoreDataDatabase
let context: NSManagedObjectContext

init() {
database = BookmarksDatabase.make()
database.loadStore()

context = database.makeContext(concurrencyType: .mainQueueConcurrencyType)
bookmarkAttributes = Array(BookmarkEntity.entity(in: context).attributesByName.keys)

fetch()
}

func fetch() {

let fetchRequest = BookmarkEntity.fetchRequest()
fetchRequest.sortDescriptors = [NSSortDescriptor(key: #keyPath(BookmarkEntity.title),
ascending: false)]
fetchRequest.returnsObjectsAsFaults = false
bookmarks = (try? context.fetch(fetchRequest)) ?? []
}
}
Loading
Loading