Skip to content

Commit

Permalink
Merge branch 'main' into sam/vpn-snooze-initial-support
Browse files Browse the repository at this point in the history
* main:
  Update Xcode version to 15.4 (#912)
  Keep Remote Messages in database if they were shown (#911)
  • Loading branch information
samsymons committed Jul 28, 2024
2 parents 0da5e9f + 5c7a0b4 commit 2cfc890
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 114 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: SwiftLint
uses: docker://norionomura/swiftlint:0.54.0_swift-5.9.0
with:
Expand All @@ -22,7 +22,7 @@ jobs:

name: Run unit tests (macOS)

runs-on: macos-13-xlarge
runs-on: macos-14-xlarge
timeout-minutes: 30

outputs:
Expand All @@ -31,7 +31,7 @@ jobs:
steps:

- name: Check out the code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -46,7 +46,7 @@ jobs:
- name: Cache SPM
if: env.cache_key_hash
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
.build/artifacts
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
| xargs -L 1 ./scripts/report-failed-unit-test.sh -s ${{ vars.APPLE_CI_FAILING_TESTS_FAILED_TESTS_SECTION_ID }}
- name: Upload logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: build-log.txt
Expand All @@ -109,13 +109,13 @@ jobs:

name: Run unit tests (iOS)

runs-on: macos-13-xlarge
runs-on: macos-14-xlarge
timeout-minutes: 30

steps:

- name: Check out the code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -130,7 +130,7 @@ jobs:
- name: Cache SPM
if: env.cache_key_hash
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: DerivedData/SourcePackages
key: ${{ runner.os }}-spm-ios-${{ env.cache_key_hash }}
Expand All @@ -144,7 +144,7 @@ jobs:
run: |
while xcodebuild -resolvePackageDependencies \
-scheme BrowserServicesKit-Package \
-destination 'platform=iOS Simulator,name=iPhone 15' \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17' \
-derivedDataPath DerivedData \
2>&1 | grep Error; do :; done
Expand All @@ -157,7 +157,7 @@ jobs:
run: |
set -o pipefail && xcodebuild test \
-scheme BrowserServicesKit \
-destination 'platform=iOS Simulator,name=iPhone 15' \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17' \
-derivedDataPath DerivedData \
-skipPackagePluginValidation \
-skipMacroValidation \
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
| xargs -L 1 ./scripts/report-failed-unit-test.sh -s ${{ vars.APPLE_CI_FAILING_TESTS_FAILED_TESTS_SECTION_ID }}
- name: Upload logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: ios-build-log.txt
Expand All @@ -203,7 +203,7 @@ jobs:

steps:
- name: Check out the code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create Asana Task
uses: ./.github/actions/asana-failed-pr-checks
with:
Expand All @@ -222,7 +222,7 @@ jobs:

steps:
- name: Check out the code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Close Asana Task
uses: ./.github/actions/asana-failed-pr-checks
with:
Expand Down
2 changes: 1 addition & 1 deletion .xcode-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.2
15.4
46 changes: 46 additions & 0 deletions Sources/RemoteMessaging/CoreData/RemoteMessageUtils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// RemoteMessageUtils.swift
//
// 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 CoreData

struct RemoteMessageUtils {
static func fetchRemoteMessage(with id: String, in context: NSManagedObjectContext) -> RemoteMessageManagedObject? {
let fetchRequest: NSFetchRequest<RemoteMessageManagedObject> = RemoteMessageManagedObject.fetchRequest()
fetchRequest.predicate = NSPredicate(format: "%K == %@", #keyPath(RemoteMessageManagedObject.id), id)
fetchRequest.fetchLimit = 1

return try? context.fetch(fetchRequest).first
}

static func fetchScheduledRemoteMessage(in context: NSManagedObjectContext) -> RemoteMessageManagedObject? {
let fetchRequest: NSFetchRequest<RemoteMessageManagedObject> = RemoteMessageManagedObject.fetchRequest()
fetchRequest.predicate = NSPredicate(
format: "%K == %i",
#keyPath(RemoteMessageManagedObject.status),
RemoteMessagingStore.RemoteMessageStatus.scheduled.rawValue
)
fetchRequest.fetchLimit = 1

return try? context.fetch(fetchRequest).first
}

static func fetchAllRemoteMessages(in context: NSManagedObjectContext) -> [RemoteMessageManagedObject] {
let fetchRequest = RemoteMessageManagedObject.fetchRequest()
return (try? context.fetch(fetchRequest)) ?? []
}
}
Loading

0 comments on commit 2cfc890

Please sign in to comment.