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

Drop database #510

Merged
merged 60 commits into from
Apr 26, 2022
Merged

Drop database #510

merged 60 commits into from
Apr 26, 2022

Conversation

mplorentz
Copy link
Member

@mplorentz mplorentz commented Apr 21, 2022

Warning: if you run this branch it will drop your database!

This is a big chunk of #421, which adds migration logic to delete the user's database and resync it from the network so that the latest version of go-ssb can start a fresh db.

What's done:

  • Detect need for upgrade & drop database
  • Present placeholder migration UI
  • Integration tests for the migration (this required me to add basically our whole view layer to the unit test target so I could use LaunchViewController in the tests)

What's left for future PRs:

  • Styling the migration UI
  • Analytics

Sorry for the large PR. Each part kind of needed the others so it ended up being large. But don't let the 2000+ lines added stat scare you too much. A lot of the changed lines were caused by adding files and Pods to the test target.

mplorentz and others added 30 commits April 4, 2022 16:49
@@ -235,7 +235,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cp -r ${BUILD_DIR}/Products/GoSSB.xcframework/ ${PROJECT_DIR}/../Frameworks/GoSSB.xcframework\n\n";
shellScript = "rsync -t ${BUILD_DIR}/Products/GoSSB.xcframework/ ${PROJECT_DIR}/../Frameworks/GoSSB.xcframework\n\n";
Copy link
Member Author

Choose a reason for hiding this comment

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

I learned recently that you shouldn't use cp in a build phase because it changes the file's last modified time and can cause unnecessary rebuilds. rsync -t preserves the last modified time.

@@ -8,25 +8,6 @@

import Foundation

extension AppConfiguration {
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this out of an extension so I could mock it in the unit tests.

AppController.shared.showMainViewController(animated: true)
appController.showMainViewController(animated: true)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

The diff for this file got messy. The next two functions: handleLoginFailure and trackLogin don't have a lot of changes, I just factored them out of launch.

@@ -247,10 +247,6 @@ private class MenuView: UIView {
let maxHeightConstraint = connectedPeersView.heightAnchor.constraint(equalToConstant: 310)
maxHeightConstraint.priority = UILayoutPriority(501)
maxHeightConstraint.isActive = true

if Date.todayIsAHoliday() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This was a cool Easter egg, but it has the old Planetary branding and only works with US holidays, so this Easter seemed like a good time to retire it.

static let unselectedTab = UIColor(named: "unselectedTab")!
static let textInputBorder = UIColor(named: "textInputBorder")!
static let textInputBackground = UIColor(named: "textInputBackground")!
static let appBackground = UIColor(named: "appBackground", in: Bundle.current, compatibleWith: nil) ?? UIColor.white
Copy link
Member Author

Choose a reason for hiding this comment

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

This gets these working in the test target. In the future I would like to generate this file from an .xcassets directory with SwiftGen so I didn't worry about finding a cleaner solution.

@rabble
Copy link
Contributor

rabble commented Apr 21, 2022

I tried to run this on a simulator that had an active db, it worked on building, threw up the loading screen, but is not migrating.

level=warn ts="2022-04-21 01:27:07.2899950 (UTC)" RepoStats="RepoStats: could not get the last message hash: error read offset of seq(-1): seek failed:seek /Users/rabble/Library/Developer/CoreSimulator/Devices/541B498A-08E5-4764-A65F-3ABAB8622449/data/Containers/Data/Application/EACEF622-7A6F-4191-A028-AD3CA2F9AF69/Library/Application Support/FBTT/d4a1cb88a66f02f8db635ce26441cc5dac1b08420ceaac230839b755845a9ffb/GoSbot/log/ofst: invalid argument"
2022-04-21 13:27:07.293862+1200 Planetary[48169:3307288] LOG:INFO: Resync progress: 0.0
level=warn ts="2022-04-21 01:27:08.2894230 (UTC)" RepoStats="RepoStats: could not get the last message hash: error read offset of seq(-1): seek failed:seek /Users/rabble/Library/Developer/CoreSimulator/Devices/541B498A-08E5-4764-A65F-3ABAB8622449/data/Containers/Data/Application/EACEF622-7A6F-4191-A028-AD3CA2F9AF69/Library/Application Support/FBTT/d4a1cb88a66f02f8db635ce26441cc5dac1b08420ceaac230839b755845a9ffb/GoSbot/log/ofst: invalid argument"
2022-04-21 13:27:08.294693+1200 Planetary[48169:3307288] LOG:INFO: Resync progress: 0.0

@mplorentz
Copy link
Member Author

I tried to run this on a simulator that had an active db, it worked on building, threw up the loading screen, but is not migrating.

@rabble thanks for catching this! I tested on the test network and it worked, but when I tested on the main SSB net it failed for me too. The culprit was a bad regex I had written to parse multiserver addresses. It's fixed now!

@mplorentz
Copy link
Member Author

The unit tests pass for me locally but are failing on CI. I'll take a look this afternoon.

mplorentz and others added 17 commits April 21, 2022 16:26
* remove xcpretty

* bring xcpretty back

* turn on sync logging

* add beautify

* introduce error

* bring xcpretty back

* remove introduced error

* mock Logger in Support

* fix Codacy issues
* Update CONTRIBUTING.md

* add CONTRIBUTING.md to Planetary project

* add cocoapods to Gemfile

* update CONTRIBUTNG.md

* remove unnecesary step

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

* add swiftlint_diff back to the project

* add missing files back to xcodeproj
@mplorentz mplorentz merged commit e6b089c into bump-version Apr 26, 2022
@mplorentz mplorentz deleted the migration_tests branch April 26, 2022 18:13
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.

3 participants