Commit Graph

90 Commits

Author SHA1 Message Date
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
Eric Seidel 4ab78869b8 feat: Add start_updater_thread to update off the main thread (#11)
* feat: Add start_updater_thread to update off the main thread

This makes it so that clients can easily not block when wanting to
queue an update.

I have a separate patch which updates the Engine to use this new
API.

I also needed to split the concept of the "next_boot" patch
from the "current_boot" patch, previously refered to as
"current" or "active" patch.  This required adding a
report_launch_start api to let the updater library know
when to set current_boot patch from next_boot.

I also removed the rust updater/cli in this as well as the
vmpath argument to init.

I also exposed the report_launch_success api, but its not yet
used by the Engine.

I renamed report_failed_launch to report_launch_failure to match
report_launch_start which I introduced.

* Update naming per comments from Felix.

Also added a helper for char* allocation (not sure if it's better).

* Update library/src/updater.rs

---------

Co-authored-by: Felix Angelov <felix@shorebird.dev>
2023-04-25 09:06:40 -07:00
Felix Angelov 182ce073e2 feat(updater): include version_code as part of release_version (#9) 2023-04-19 16:07:09 -05:00
Eric Seidel 1281624ccf Rename release_version to version_name, add version_code, remove vm_path (#8) 2023-04-19 19:46:41 +00:00
Eric Seidel bc19f5df79 fix: Teach update about split apks (#7)
* Teach update about split apks

Fixes https://github.com/shorebirdtech/shorebird/issues/292.

The previous code only worked with universal apks, not split apks (which is what the play store produces).

We now look for APKs in the same directory as base.apk (through the same path hacks as before) and look for one matching the arch/abi name first.  If we don't find one we also check base.apk.

This works in my testing with bundletool locally.

I also removed support for hashes being optional and removed a few unwraps (which will crash on failure).

I also fixed our use of imports/use statements to be a bit more consistent, including using "std::fs" rather than "std::fs::File" in one place but not another.

* Fix failing unit tests
2023-04-17 13:17:08 -07:00
Eric Seidel b19eb16654 fix: Rewrite updater to read libapp.so from apk rather than expecting it on disk (#5)
Fixes shorebirdtech/shorebird#235 🤞

This moves us away from depending on libapp.so having been extracted from the APK and instead we always extract it ourselves.
2023-04-12 14:49:00 -07:00
Eric Seidel c0e22f7e54 Update README.md 2023-04-12 09:04:13 -07:00
Eric Seidel 5c98d17bfb Update README.md 2023-04-12 09:01:56 -07:00
Eric Seidel d6eb5f7f09 Update README.md
Lets see if I wrote this down correctly.
2023-04-12 08:57:19 -07:00
Eric Seidel 4f4081c177 Update README.md 2023-04-12 08:48:19 -07:00
Eric Seidel ed5665cf78 Update README.md
Write down my dev workflow.
2023-04-11 12:07:39 -07:00
Felix Angelov 5f42886163 chore: add example from shorebird/shorebird (#4) 2023-04-07 10:03:54 -05:00
Eric Seidel 241a1dfabf Autogenerate include/updater.h every time we build. (#3)
Turns out this was way easier than I thought.
https://github.com/shorebirdtech/shorebird/issues/121
Docs:
https://github.com/eqrion/cbindgen/blob/master/docs.md#buildrs
2023-04-06 17:14:49 +00:00
Felix Angelov 8232ee34be ci: remove release creation step and adjust trigger 2023-04-06 12:02:01 -05:00
Felix Angelov da86c12fca ci: add build_patch_artifacts workflow (#2) 2023-04-06 11:57:33 -05:00