318 Commits

Author SHA1 Message Date
Bryan Oltman 6a65a46027 add trailing comma 2023-09-20 10:52:29 -04:00
Bryan Oltman b4024cf499 fix: add separate storage dir for state (#84) 2023-09-12 16:13:19 -04:00
Eric Seidel 84cfcf5c58 chore: add missing codecov.yml file and comments 2023-09-08 11:19:00 -07:00
Eric Seidel edc3130400 chore: attempt to turn on codecov flags 2023-09-08 11:07:22 -07:00
Eric Seidel e4b182d75d chore: fix 30 of the 54 warnings from clippy pedantic. (#81)
I just ran `cargo clippy -- -W clippy::pedantic` and fixed things.

These are more invasive that the default set and the remaining
warnings are mostly about our (abysmal) public docs missing
Error and Panic sections to explain errors and panicks.
2023-09-08 17:51:07 +00:00
Eric Seidel 20b65f14c2 chore: run cargo clippy over our rust codebase (#80)
* chore: apply fixes from clippy

* Add a Safety section to appease clippy
2023-09-08 17:30:19 +00:00
Eric Seidel 15b2f6bfaa feat: report patch install failure events (#78)
* feat: report failure events to our servers

This doesn't tell us anything about the failure, just that it
happened.  Which at least will let us communicate that to customers.

This currently has no tests and will need some before landing.

* Address review comments

* Use use statements for config and events

* Add partial test

* Add comment about when save happens
2023-09-08 09:48:04 -07:00
Eric Seidel 9d4ce55c2b refactor: Prepare to have more than one event type (#77)
Refactored our PatchInstallEvent to be just PatchEvent
and allow us to have more than one event type.

I moved it into its own events.rs file and added privacy
warnings to both this and the network code (eventually
we may move all this into a separate privacy.rs file).

I also fixed our build.rs file to not panic when our build
is otherwise broken. For whatever reason that seems to
cause the rust-analyzer to stop and not show any future
warnings (thus it's hard to fix things).

I moved away from having a "new" method for PatchEvent
with a series of Strings (which could be confused in order)
and instead am now using just the normal default struct
construction which effectively has named args.

Since EventType is now an enum, it's easy to use the
right enum not have to call PatchInstallEvent::new to
get the right magic string for "identifier".

Also added a bit more documentation to c_api.rs
2023-09-07 12:31:32 -07:00
Bryan Oltman 292f978950 fix: don't regenerate client id if UpdaterState successfully loaded (#76)
* fix: don't regenerate client id if UpdaterState successfully loaded

* tests, cleanup

* comments
2023-09-07 10:48:43 -04:00
Eric Seidel e14f630f91 refactor: move shorebird_code_push_io and _web into src/ (#75)
* break: move shorebird_code_push_io and _web into src/

Users were sometimes importing the _web version thinking it
was the "web safe" import, rather than shorebird_code_push.dart
and then being surprised when ShorebirdCodePush did nothing.

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

* Update formating for Dart 3.1
2023-09-07 07:38:15 -07:00
Eric Seidel ef268acaf6 fix: show patch check info in logs (#73) 2023-09-01 08:17:02 -07:00
Bryan Oltman 53072a9128 fix: put call to report launch success on bg thread. (#72)
* fix: use non-blocking http client when reporting launch success

* Make patch install report request on bg thread

* Pass client_id instead of state

* Convert client_id from &str to String
2023-08-17 14:55:26 -04:00
Bryan Oltman 7417429d91 fix: log more friendly error message in case of no internet connection (#67)
* fix: log more friendly error message in case of no internet connection

* fix typo

* coverage
2023-08-17 08:36:10 -04:00
Bryan Oltman 99f3005ff4 feat: add support for reporting patch install events (#71)
* feat: add client_id to UpdaterState

* feat: add support for reporting patch install events

* Ensure we save UpdaterState after it's created

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

* Don't error in report_launch_success if no patch exists

* coverage

* Rename

* Minor refactor

* coverage

* coverage

* Update library/src/updater.rs

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

* restore debug logs

* make test serial

---------

Co-authored-by: Felix Angelov <felix@shorebird.dev>
2023-08-11 13:56:46 -04:00
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