Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/cargo/patch/patch-deps-925dfa8b70
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman authored Nov 25, 2024
2 parents b8cb997 + 6298d37 commit 2188f8a
Show file tree
Hide file tree
Showing 22 changed files with 164 additions and 120 deletions.
11 changes: 8 additions & 3 deletions .github/actions/flutter_package/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ inputs:
required: false
default: "lib"
description: Directories to report on when collecting coverage
platform:
example_platform:
required: false
default: "vm"
description: Platform to use when running tests
default: "web"
description: Platform to use when building example

runs:
using: "composite"
Expand All @@ -54,6 +54,11 @@ runs:
shell: ${{ inputs.shell }}
run: dart analyze --fatal-warnings ${{inputs.analyze_directories}}

- name: Build Example
working-directory: ${{ inputs.working_directory }}/example
shell: ${{ inputs.shell }}
run: flutter build ${{ inputs.example_platform }}

- name: Test
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
name: ✅ Semantic Pull Request
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1

cspell:
name: 🔤 Check Spelling
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/spell_check.yml@v1
with:
config: cspell.config.yaml

changes:
runs-on: ubuntu-latest

Expand Down
70 changes: 70 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json
version: '0.2'
ignorePaths:
- target
- build
- '**/*.g.dart'
# Flutter platform directories with per-platform build files
- windows
- macos
- linux
- ios
- android
words:
- aarch
- androideabi
- apks
- armeabi
- armv7
- autogen
- bidiff
- bipatch
- bootable
- buildroot
- bundletool
- carryforward
- cbindgen
- cdylib
- classpath
- comde
- compatch
- Condvar
- datadir
- declspec
- Decompressor
- dllexport
- dlopen
- endtemplate
- eseidel
- ffigen
- gclient
- hdpi
- ifdef
- libapp
- libc
- libflutter
- libupdater
- logcat
- mockall
- mocktail
- oslog
- pubspec
- repr
- reqwest
- rollouts
- rustls
- rustup
- serde
- shorebirdtech
- sigstore
- staticlib
- subosito
- unbootable
- Verdana
- vmcode
- withf
- xlink
- zstandard
- zstd
- xcodeproj
- pbxproj
2 changes: 1 addition & 1 deletion library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ This state machine tracks the process of checking for new patches. It is managed
by the code in `updater.rs` and does not have any on-disk state. It has the
following states:

1. Ready - Ready to check for udpates.
1. Ready - Ready to check for updates.
2. Send queued events (e.g., report that a patch succeeded or failed to boot)
a. Move to checking once events, if any, have been reported.
3. Checking for new patches - A PatchCheckRequest is issued but not completed.
Expand Down
1 change: 1 addition & 0 deletions library/src/android.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// cspell:ignore rpkDZSLBRv2jWcc1gQpwdg
use anyhow::Context;
use std::fs;
use std::io::{Cursor, Read};
Expand Down
14 changes: 7 additions & 7 deletions library/src/c_api/c_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ struct CFile {
}

#[derive(Clone, Debug)]
pub struct CFileProvder {
pub struct CFileProvider {
pub file_callbacks: FileCallbacks,
}

impl ExternalFileProvider for CFileProvder {
impl ExternalFileProvider for CFileProvider {
fn open(&self) -> anyhow::Result<Box<dyn ReadSeek>> {
let handle = (self.file_callbacks.open)();
if handle.is_null() {
Expand Down Expand Up @@ -139,7 +139,7 @@ mod test {
fn test_open() {
reset_tests();

let file_provider = CFileProvder {
let file_provider = CFileProvider {
file_callbacks: FileCallbacks::new(),
};
let handle = file_provider.open().unwrap();
Expand All @@ -158,7 +158,7 @@ mod test {
OPEN_RET = std::ptr::null_mut();
}

let file_provider = CFileProvder {
let file_provider = CFileProvider {
file_callbacks: FileCallbacks::new(),
};
let result = file_provider.open();
Expand All @@ -170,7 +170,7 @@ mod test {
fn test_read() {
reset_tests();

let file_provider = CFileProvder {
let file_provider = CFileProvider {
file_callbacks: FileCallbacks::new(),
};
let mut handle = file_provider.open().unwrap();
Expand All @@ -187,7 +187,7 @@ mod test {
fn test_seek() {
reset_tests();

let file_provider = CFileProvder {
let file_provider = CFileProvider {
file_callbacks: FileCallbacks::new(),
};
let mut handle = file_provider.open().unwrap();
Expand Down Expand Up @@ -233,7 +233,7 @@ mod test {
fn test_seek_err() {
reset_tests();

let file_provider = CFileProvder {
let file_provider = CFileProvider {
file_callbacks: FileCallbacks::new(),
};
let mut handle = file_provider.open().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions library/src/c_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::path::PathBuf;

use crate::{updater, UpdateStatus};

use self::c_file::CFileProvder;
use self::c_file::CFileProvider;

mod c_file;

Expand Down Expand Up @@ -162,7 +162,7 @@ pub extern "C" fn shorebird_init(
log_on_error(
|| {
let config = app_config_from_c(c_params)?;
let file_provider = Box::new(CFileProvder {
let file_provider = Box::new(CFileProvider {
file_callbacks: c_file_callbacks,
});
let yaml_string = to_rust(c_yaml)?;
Expand Down
2 changes: 1 addition & 1 deletion library/src/cache/disk_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod test {
}

#[test]
fn read_errs_if_file_doesnt_exist() {
fn read_errs_if_file_does_not_exist() {
assert!(super::read::<TestStruct, _>(&Path::new("nonexistent.json")).is_err());
}

Expand Down
13 changes: 7 additions & 6 deletions library/src/cache/patch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ struct PatchesState {

/// Abstracts the storage of patches on disk.
///
/// The impementation of this (PatchManager) should only be responsible for translating what is on
/// disk into a form that is useful for the updater and vice versa. Some business logic has crept in
/// in the form of validation, and we should consider moving that into a separate module.
/// The implementation of this (PatchManager) should only be responsible for
/// translating what is on disk into a form that is useful for the updater and
/// vice versa. Some business logic has crept in in the form of validation, and
/// we should consider moving that into a separate module.
#[cfg_attr(test, automock)]
pub trait ManagePatches {
/// Copies the patch file at file_path to the manager's directory structure sets
/// this patch as the next patch to boot.
/// Copies the patch file at file_path to the manager's directory structure
/// sets this patch as the next patch to boot.
///
/// The explicit lifetime is required for automock to work with Options.
/// See https://github.com/asomers/mockall/issues/61.
Expand Down Expand Up @@ -952,7 +953,7 @@ mod fall_back_tests {
manager.record_boot_start_for_patch(1)?;
manager.record_boot_success()?;
let patch_1_path = manager.patch_artifact_path(1);
std::fs::write(patch_1_path, "junkjunkjunk")?;
std::fs::write(patch_1_path, "junk junk junk")?;

// Download and fall back from patch 2
manager.add_patch_for_test(&temp_dir, 2)?;
Expand Down
1 change: 1 addition & 0 deletions library/src/cache/signing.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// cspell:ignore pubin PKCS outform
use anyhow::{bail, Context, Result};
use base64::Engine;
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion library/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ mod tests {
let result = super::report_event_default(
// Make the request to an incorrectly formatted URL, which will
// trigger the same error as a lack of internet connection.
&patches_events_url("asdfasdf"),
&patches_events_url("does_not_exist"),
super::CreatePatchEventRequest {
event: PatchEvent {
app_id: "app_id".to_string(),
Expand Down
11 changes: 5 additions & 6 deletions library/src/updater_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ fn updater_lock() -> &'static std::sync::Mutex<UpdaterLockState> {

// Note: it is not OK to ever ask for the Updater lock *while* holding the
// UpdateConfig lock because the updater thread *will* block on getting the
// UpdateConfig lock while holding the Updater lock. Allowing the inverse
// could cause a deadlock. We could add a check for that here by doing a
// tryLock on the UpdateConfig lock and erroring out if we can't get it, but
// that would probably have false postives since it is OK for some other call to
// be holding the UpdateConfig lock while another thread asks for the Updater
// lock.
// UpdateConfig lock while holding the Updater lock. Allowing the inverse could
// cause a deadlock. We could add a check for that here by doing a tryLock on
// the UpdateConfig lock and erroring out if we can't get it, but that would
// probably have false positives since it is OK for some other call to be
// holding the UpdateConfig lock while another thread asks for the Updater lock.
pub fn with_updater_thread_lock<F, R>(f: F) -> anyhow::Result<R>
where
F: FnOnce(&UpdaterLockState) -> anyhow::Result<R>,
Expand Down
10 changes: 10 additions & 0 deletions shorebird_code_push/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 2.0.2

- fix: un-break web platform
- chore: minor improvements to example

# 2.0.1

- Update the minimum Flutter version from 3.24.4 to 3.24.5 (3.24.4 does not
include the updater changes required to support the new API).

# 2.0.0

- **BREAKING**: more updates to the Updater API. We now support Stable, Beta,
Expand Down
29 changes: 7 additions & 22 deletions shorebird_code_push/example/.metadata
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 796c8ef79279f9c774545b3771238c3098dbefab
channel: stable
revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
- platform: android
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
- platform: ios
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
- platform: linux
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
- platform: macos
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: web
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
- platform: windows
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668

# User provided section

Expand Down
5 changes: 3 additions & 2 deletions shorebird_code_push/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: shorebird_code_push_example
description: An example demonstrating how to use the shorebird_code_push package
publish_to: "none"

version: 1.0.0+21
version: 1.0.0+1

environment:
sdk: ">=3.0.5 <4.0.0"
sdk: ">=3.5.4 <4.0.0"
flutter: ">=3.24.5"

dependencies:
flutter:
Expand Down
23 changes: 1 addition & 22 deletions shorebird_code_push/example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,8 @@

<title>example</title>
<link rel="manifest" href="manifest.json">

<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
appRunner.runApp();
});
}
});
});
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
3 changes: 1 addition & 2 deletions shorebird_code_push/lib/src/shorebird_updater.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:shorebird_code_push/src/shorebird_updater_io.dart'
if (dart.library.js_interop) './shorebird_updater_web.dart';
import 'package:shorebird_code_push/src/updater.dart';

/// The reason a call to [ShorebirdUpdater.update] failed.
enum UpdateFailureReason {
Expand Down Expand Up @@ -95,7 +94,7 @@ enum UpdateStatus {
/// {@endtemplate}
abstract class ShorebirdUpdater {
/// {@macro shorebird_updater}
factory ShorebirdUpdater() => ShorebirdUpdaterImpl(const Updater());
factory ShorebirdUpdater() => ShorebirdUpdaterImpl();

/// Whether the updater is available on the current platform.
/// The most common reasons for this returning false are:
Expand Down
Loading

0 comments on commit 2188f8a

Please sign in to comment.