Skip to content

CI: also run tests on watchOS#2340

Merged
NachoSoto merged 6 commits intomainfrom
watchos-tests
Mar 16, 2023
Merged

CI: also run tests on watchOS#2340
NachoSoto merged 6 commits intomainfrom
watchos-tests

Conversation

@NachoSoto
Copy link
Copy Markdown
Contributor

@NachoSoto NachoSoto commented Mar 16, 2023

This is a follow up to #717.
In order to be able to reproduce #2338, which seems to be an issue only on watchOS, it's important that we now run tests on watchOS as well.
We probably won't be able to fully replicate that issue since we don't run tests on actual devices, so they'll still run on 64 bits. But this way we might be able to prevent issues that are only reproducible on watchOS in the future.

Changes:

  • Added CircleCI job
  • Added lane
  • Simplified UnitTestsHostApp definition using SwiftUI
  • Increased test only watchOS deployment target to 7.0 (this was necessary to be able to have a common @main for the host app)
  • Increased test only tvOS deployment target to 14.0 (same as above, plus we only run tvOS tests on the latest version anyway. We test backwards compatibility through iOS already)
  • Fixed test compilation on watchOS
  • Disabled HTTPClient tests on watchOS (see OHHTTPStubs not working with watchOS AliSoftware/OHHTTPStubs#287)
  • StoreKitConfigTestCase is only available from watchOS 7.0 since that's when SKTestSession was introduced
  • Added watchOS support to UnitTests target
  • Added watchOS support to ReceiptParserTests target
  • Fixed isFamilySharable watchOS version checks for version 8.0
  • Created new CI-RevenueCat Test Plan to only run unit tests and not StoreKit tests on watchOS

This is a follow up to #717.
In order to be able to reproduce #2338, which seems to be an issue only on `watchOS`, it's important that we now run tests on `watchOS` as well.

## Changes:
- Added CircleCI job
- Added lane
- Simplified `UnitTestsHostApp` definition using `SwiftUI`
- Increased _test only_ watchOS deployment target to 7.0 (this was necessary to be able to have a comm 	on `@main` for the host app
- Fixed test compilation on `watchOS`
- Disabled `HTTPClient` tests on `watchOS` (see AliSoftware/OHHTTPStubs#287)
- `StoreKitConfigTestCase` is only available from `watchOS 7.0` since that's when `SKTestSession` was introduced
- Added `watchOS` support to `UnitTests` target
- Added `watchOS` support to `ReceiptParserTests` target
- Fixed `isFamilySharable` `watchOS` version checks for version 8.0
- Created new `CI-RevenueCat` Test Plan to only run unit tests and not StoreKit tests on `watchOS`
@NachoSoto NachoSoto added the ci label Mar 16, 2023
@NachoSoto NachoSoto requested a review from a team March 16, 2023 18:16
@NachoSoto NachoSoto changed the title CI: also run tests watchOS tests CI: also run tests on watchOS Mar 16, 2023
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2023

Codecov Report

Merging #2340 (191c44e) into main (3e221e8) will increase coverage by 0.07%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #2340      +/-   ##
==========================================
+ Coverage   86.45%   86.52%   +0.07%     
==========================================
  Files         189      189              
  Lines       12793    12793              
==========================================
+ Hits        11060    11069       +9     
+ Misses       1733     1724       -9     

see 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, SKTestSession is watchOS 7+, I'm surprised this even worked before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never compiled this on watchOS.

Comment on lines +30 to +33
#if os(watchOS)
// See https://github.com/AliSoftware/OHHTTPStubs/issues/287
try XCTSkipIf(true, "OHHTTPStubs does not currently support watchOS")
#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would love to replace OHHTTPStubs altogether some day

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup..

@NachoSoto NachoSoto changed the title CI: also run tests on watchOS CI: also run tests on watchOS Mar 16, 2023
@NachoSoto NachoSoto enabled auto-merge (squash) March 16, 2023 20:04
@NachoSoto NachoSoto merged commit 2fff5b0 into main Mar 16, 2023
@NachoSoto NachoSoto deleted the watchos-tests branch March 16, 2023 20:11
NachoSoto added a commit that referenced this pull request Mar 16, 2023
…` crashes (#2342)

Fixes #2338, [SDKONCALL-237], [SDK-2974].

`Int` is actually 32 bits in 32-bit platforms, like `watchOS` still is
(sort of).
This fixes 2 potential `Int` overflows: `Date.millisecondsSince1970` and
`DispatchTimeInterval` arithmetic using `nanoseconds`.

See also #2340.

[SDKONCALL-237]:
https://revenuecats.atlassian.net/browse/SDKONCALL-237?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
NachoSoto added a commit that referenced this pull request Mar 16, 2023
This is a follow up to #717.
In order to be able to reproduce #2338, which seems to be an issue only
on `watchOS`, it's important that we now run tests on `watchOS` as well.
We probably won't be able to fully replicate that issue since we don't
run tests on actual devices, so they'll still run on 64 bits. But this
way we might be able to prevent issues that are only reproducible on
`watchOS` in the future.

- Added CircleCI job
- Added lane
- Simplified `UnitTestsHostApp` definition using `SwiftUI`
- Increased _test only_ `watchOS` deployment target to 7.0 (this was
necessary to be able to have a common `@main` for the host app)
- Increased _test only_ `tvOS` deployment target to `14.0` (same as
above, plus we only run tvOS tests on the latest version anyway. We test
backwards compatibility through iOS already)
- Fixed test compilation on `watchOS`
- Disabled `HTTPClient` tests on `watchOS` (see
AliSoftware/OHHTTPStubs#287)
- `StoreKitConfigTestCase` is only available from `watchOS 7.0` since
that's when `SKTestSession` was introduced
- Added `watchOS` support to `UnitTests` target
- Added `watchOS` support to `ReceiptParserTests` target
- Fixed `isFamilySharable` `watchOS` version checks for version 8.0
- Created new `CI-RevenueCat` Test Plan to only run unit tests and not
StoreKit tests on `watchOS`
NachoSoto added a commit that referenced this pull request Mar 16, 2023
…` crashes (#2342)

Fixes #2338, [SDKONCALL-237], [SDK-2974].

`Int` is actually 32 bits in 32-bit platforms, like `watchOS` still is
(sort of).
This fixes 2 potential `Int` overflows: `Date.millisecondsSince1970` and
`DispatchTimeInterval` arithmetic using `nanoseconds`.

See also #2340.

[SDKONCALL-237]:
https://revenuecats.atlassian.net/browse/SDKONCALL-237?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants