Commit Graph

104 Commits

Author SHA1 Message Date
Bryan Oltman d321ad02de feat: add client_id to UpdaterState (#70)
* feat: add client_id to UpdaterState

* Ensure we save UpdaterState after it's created

* Save state if we assign it a client id on load

* Rename
2023-08-11 11:23:13 -04:00
Bryan Oltman ffabae1ae6 chore: sort deps in Cargo.toml (#69)
* chore: sort deps in Cargo.toml

* more sorting

* even more sorting

* remove unused lib
2023-08-10 09:50:44 -04:00
Eric Seidel 1841f59b94 refactor: Use Result to indicate failure in mark_patch_bad (#66)
I'm not sure if this is better or worse, but it does make testing
a bit more clear.
2023-08-04 16:55:35 +00:00
Eric Seidel 15ab0f2295 feat: add support for parsing auto_update from shorebird.yaml (#65)
* feat: add support for parsing auto_update from shorebird.yaml

The actual support will be in the C++ engine, but this keeps
all yaml parsing in the Rust code for simplicity.

---------

Co-authored-by: Felix Angelov <felix@shorebird.dev>
2023-08-03 18:37:09 +00:00
Eric Seidel 5fcf97e3e0 test: improve rust coverage (#64)
Refactored our android code slightly so we could test all the
branches of our "find the right split apk" function.
2023-08-03 11:25:08 -05:00
Eric Seidel ae85cf5125 fix: Improve rust logging and error clarity (#63)
* Improve logging from our rust code.

Fixes https://github.com/shorebirdtech/updater/issues/56
and https://github.com/shorebirdtech/shorebird/issues/779
and https://github.com/shorebirdtech/updater/issues/61

I did not add a test for the log handling when starting a thread
(didn't see an easy way to do so, without mocking the update
call itself?)

I also did not add a test for changing the log verbosity.

Verified both by hand.

* Reduce logging.

Also removed unused assets.rs file.
Also silenced "file not found" error case on first boot.

* Improve coverage
2023-07-31 21:51:08 +00:00
Felix Angelov abe4126da5 chore(shorebird_code_push): v1.1.0 (#60) 2023-07-14 16:08:24 -05:00
Felix Angelov 2e851aa913 docs: add coverage badge (#59) 2023-07-14 16:03:22 -05:00
Felix Angelov bccee99656 ci: exclude generated code (#58) 2023-07-14 15:57:47 -05:00
Felix Angelov 4ceb37dc1e refactor(shorebird_code_push): ffi + noop implementation and web compat (#55) 2023-07-14 15:30:35 -05:00
Erikas Taroza d3ec0a3aaf fix: glibc error when patching on Linux (#52) 2023-07-08 09:30:42 -04:00
Bryan Oltman 0be41d9d85 chore(shorebird_code_push): Release 1.0.0, change downloadUpdate to downloadUpdateIfAvailable (#46)
* Release 1.0.0, change downloadUpdate to downloadUpdateIfAvailable

* update readme and contributing

* add dart doc

* add discord badge

* remove doc checkin

* formatting
2023-06-29 16:42:56 -04:00
Bryan Oltman b0734d9275 docs: move BUILDING_ENGINE.md to wiki (#20)
* docs: move BUILDING_ENGINE.md to wiki

* Resolve merge issue
2023-06-29 14:33:00 -04:00
Bryan Oltman 9f638cd250 update example to latest released version 2023-06-23 18:11:58 -04:00
Bryan Oltman 9336cb3add Release shorebird_code_push 0.1.3 2023-06-23 18:07:14 -04:00
Bryan Oltman ec7b55aecb add ignore_for_file header to generated files 2023-06-23 18:06:00 -04:00
Bryan Oltman d162c724ec Update example after running in xcode 2023-06-23 15:19:08 -04:00
Bryan Oltman aa60264e15 release shorebird_code_push 0.1.2 2023-06-23 14:12:42 -04:00
Bryan Oltman ef13b122f1 doc(shorebird_code_push): lengthen pubspec.yaml description 2023-06-23 14:04:19 -04:00
Eric Seidel 3af4081f55 fix: Only allow one update attempt at a time (#44)
This is all for shorebirdtech/shorebird#695

I ended up fixing a lot of things in our Rust code while I was in there, including:

* Using PathBuf instead of Sting wherever we are holding onto Path objects (this removed a bunch of code which was converting in and out of these).
* Made a variety of functions private (the default) that were previously mistakenly pub.
* Moved the android hacks around libapp_paths closer to the C++ code. Previously we were storing all of the libapp_paths on ResolvedConfig and handling the android hacks during patch install. Now we're doing the android path hacks on init, eventually we'll remove them entirely by making the C++ code pass us in the android app_dir or even the resolved .apk we need instead of the libapp_paths.
* Fixed several tests to use /dir/lib/arch/libapp.so paths instead of 'libapp.so' now that the init code applies the android hacks an expects the deeper paths. Again, this will go away when we move the android hacks into c++.
* Added a test which confirms that if we init twice we log instead of trying to init again (this was one behavior which FCM was triggering as part of fix: ANR when using Firebase Cloud Messaging with Shorebird shorebird#695
* Add a test which confirms that further calls to update while an update is ongoing just fail out quickly instead of hanging.
* Moved to serial_test instead of a separate per-thread config system for testing. This makes our tests operate more like the code does in the wild, at the cost of needing to annotate a test as #[serial] any time it needs to use shorebird_init.
* Removed ResolvedConfig and now call it UpdateConfig. ResolvedConfig previously had a bool on it to tell if it was initialized, that's now represented as Option instead which is more rusty.
* Changed how we handle NetworkHooks from being compile-time test switched to using function pointers held off of UpdateConfig.network_hooks. I think this makes more sense? I did this to remove the special ThreadConfig object which was used during unit tests, but didn't exist in production. I think the way we mock networking could still be improved.
2023-06-22 12:45:55 -07:00
Bryan Oltman 7fc761d71f feat: add restart button to example (#43) 2023-06-22 12:11:57 -04:00
Eric Seidel c627ad79a1 chore: Remove dead UpdateStatus code (#42)
We never used UpdateDownloaded (and I'm not sure we need this enum at all), so at least removing the dead one.
2023-06-21 18:18:03 +00:00
Bryan Oltman fb89fdd412 Update to version 0.1.1, readme updates 2023-06-21 11:02:30 -04:00
Bryan Oltman 4b3ffca8d7 chore: add LICENSE file (#39)
* chore: add license file

* rename license
2023-06-20 19:55:08 -04:00
Bryan Oltman 1776b058b4 chore(shorebird_code_push): add CHANGELOG.md (#41)
* chore(shorebird_code_push): add CHANGELOG.md

* remove build number from version

* correct version number
2023-06-20 17:52:12 -04:00
Bryan Oltman 75d10b2585 chore: add homepage to pubspec.yaml (#40)
* chore: add homepage to pubspec.yaml

* update pubspec
2023-06-20 17:45:00 -04:00
Bryan Oltman 62ed676140 feat(shorebird_code_push): add download update functionality (#37)
* feat: add shorebird_current_boot_patch_number function

* Continue support for next_patch_version

* rename, return null in case of 0

* feat(shorebird_code_push): add download update functionality

* rename defaultValue to fallbackValue

* add forTest constructor to ShorebirdCodePush
2023-06-20 17:11:30 -04:00
Bryan Oltman 318d86e13f feat: add shorebird_current_boot_patch_number function (#36)
* feat: add shorebird_current_boot_patch_number function

* Continue support for next_patch_version

* rename, return null in case of 0
2023-06-20 16:45:43 -04:00
Bryan Oltman 0057c7ea8d chore: delete old counter example, dart_bindings, and dart_cli (#35)
* chore: delete old counter example

* delete dart_bindings and dart_cli
2023-06-20 10:38:09 -04:00
Bryan Oltman f85eda8173 feat(shorebird_code_push): update example to use code push bindings (#33)
* feat(shorebird_code_push): add updater bindings and dart support

* newlines

* docs

* feat(shorebird_code_push): update example to use code push bindings

* Move checkForUpdate into setState

* Update to reflect patch number being sent as int

* polish

* updater test coverage

* Update shorebird_code_push/example/lib/main.dart

Co-authored-by: Felix Angelov <felix@shorebird.dev>

* Analysis

---------

Co-authored-by: Felix Angelov <felix@shorebird.dev>
2023-06-20 10:15:56 -04:00
Bryan Oltman 0222f526a6 chore: use a number instead of a string for next boot patch number (#34) 2023-06-19 22:49:59 -04:00
Bryan Oltman ea48f6cb4f feat(shorebird_code_push): add updater bindings and dart support (#32)
* feat(shorebird_code_push): add updater bindings and dart support

* newlines

* docs

* Remove unused support for dart cli

* clarify Android-specific setup in readme
2023-06-19 20:53:51 -04:00
Bryan Oltman a593540f96 chore(shorebird_code_push): add example project (#31)
* chore(shorebird_code_push): add example project

* use flutter instead of dart in gha
2023-06-19 18:02:43 -04:00
Bryan Oltman 27e7984179 feat: add shorebird_code_push package (#30)
* feat: add shorebird_code_push package

* remove example and extra code

* update github workflow

* fix gha
2023-06-17 14:17:03 -04:00
Bryan Oltman 02c84f6e1d docs: delete UPDATING_ENGINE.md (#21)
Co-authored-by: Eric Seidel <eric@shorebird.dev>
2023-06-12 18:19:36 +00:00
Felix Angelov 21bda06fdf chore: add licenses badges to README (#28) 2023-06-09 15:56:28 -05:00
Felix Angelov d9361f0475 chore: add MIT and Apache licenses (#27) 2023-06-09 15:53:42 -05:00
Felix Angelov dc919cad5a chore: add coverage badge to README (#26) 2023-06-09 15:52:18 -05:00
Felix Angelov 8eb3a46446 ci: upload coverage to codecov (#25) 2023-06-09 20:36:35 +00:00
Eric Seidel bce1508787 fix: remove more unwrap calls. (#24)
Each unwrap() is a potential crash.  Shorebird's updater code
should never crash.

There still are a couple, but I think we should set up coverage
first so we can track that we're testing all these changes.
2023-06-08 15:14:09 -07:00
Eric Seidel 50f0b022df feat: Support iOS (#23)
Adds support for iOS to the updater library.

Refactored the android-specific code into an android module.

The tests still mostly use the android code, rather than testing iOS paths too, but that can be fixed in a follow-up.

I had to change how "latest patch number" works to understand when patch files disappear from disk (which I thought was happening on iOS initially).

I also had to make status.json not store absolute paths to patch files (since the absolute path changes per-xcode run on iOS).
2023-06-08 17:34:10 -04:00
Eric Seidel 4d2ec2e148 feat: Make updater build on iOS (#22)
Doesn't work yet, but does at least build (and log).
2023-05-31 14:44:35 -05:00
Bryan Oltman 11d8c22805 fix: don't panic on missing shorebird.yaml (#18)
* fix: don't panic on missing shorebird.yaml

* fix next_boot_patch C api

* don't log error in updater

* Cleanup

* Remove anyhow::bail import
2023-05-16 16:21:43 -04:00
Eric Seidel 7809b5f6fe Remove mention of cbindgen manual step 2023-05-16 11:42:25 -07:00
Bryan Oltman 7768cfd461 docs: update building instructions to reflect current branching strategy (#17) 2023-05-15 15:53:09 -04:00
Bryan Oltman f8c17c1ffe docs: clarify where gclient sync should be run 2023-05-15 10:42:15 -04:00
Bryan Oltman ffb0640739 docs: update building_engine.md (#15)
* doc: update building_engine.md

* cleanup

* update

* cleanup

* Remove {% note %} tags that don't work
2023-05-09 15:57:11 -07:00
Eric Seidel 594ffe5872 docs: Update BUILDING_ENGINE.md
Fixes https://github.com/shorebirdtech/updater/issues/13
2023-04-26 16:34:15 -07:00
Eric Seidel 226df7d08d test: Make our rust tests use per-thread config rather than global static (#14)
* Make our rust tests use per-thread config rather than global static

This lets our unit tests run in parallel.  I also moved our "integration"
tests back to be unit tests for now.

This also exposes a network mocking abstraction.

I've added an incomplete test of applying a full patch.  Still
needs some work to complete.

* Finish making the patch success test work

* Changed our test config to use println instead of info/error, etc. so that tests show output on failure (there might be a better way?)
Unfortunately macro_use (which is the way we were causing error!, info! etc to appear everywhere with only one global import before, only works on crates not on std, so I had to be explicit with my imports per-file.
* Add a function to build a fake zip file, because that's what the updater currently expects.  Better would be for us to move to a AssetManager system I suspect, then the updater would ask the asset manager for the libapp.so and we'd return it instead of having to go through writing out a zip file.
* Added a string_patch.rs tool and shared code between that and the patch tool.  This made it possible/easy for me to generate the necessary binary patches as well as needed hashes to pretend to be the patch server.
* Added one simple test of the patch tool core logic.

In total we're now above 80% coverage of our rust code after this.

* remove stray comment
2023-04-26 13:07:19 -05:00
Eric Seidel e4a883c8a7 Refactor C API to avoid using unwrap. (#12)
This removes another source of possible crashes from the rust code.

I also took this opportunity to try and test the C-api. I also
discovered rust "integration tests" as part of this and chose
to move some of the (new) c_api tests to an integration test
as well as the existing rust api (updater.rs) tests.
2023-04-25 15:39:33 -05:00