diff --git a/.dockerignore b/.dockerignore index 106bb099..337fd68e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,8 +2,9 @@ !**/Cargo.toml !**/Cargo.lock - -# only include runtime binary -homestar-core -homestar-guest-wasm -homestar-wasm +!**/src +!**/config +!**/migrations +!.env +!diesel.toml +!**/wits diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 066c2d4d..42e07b67 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,20 +1,12 @@ name: 🐳 Docker on: - push: - branches: [ main ] - - pull_request: - branches: [ '**' ] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + schedule: + - cron: '0 0 * * *' jobs: build-docker: runs-on: ubuntu-latest - if: ${{ github.event_name == 'pull_request' }} env: DOCKER_BUILDKIT: 1 @@ -33,21 +25,14 @@ jobs: with: buildkitd-flags: "--debug" - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker Build uses: docker/build-push-action@v4 with: - cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/homestar:latest - cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/homestar:latest,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max file: docker/Dockerfile context: . - platforms: linux/amd64, linux/arm64 + platforms: linux/amd64 push: false tags: | ${{ github.repository_owner }}/homestar:latest diff --git a/Cargo.lock b/Cargo.lock index 6ad22d99..7cf330ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -438,28 +438,6 @@ dependencies = [ "wasm-bindgen-futures", ] -[[package]] -name = "async-stream" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite 0.2.9", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.16", -] - [[package]] name = "async-task" version = "4.4.0" @@ -528,7 +506,7 @@ dependencies = [ "async-trait", "axum-core", "base64 0.21.0", - "bitflags", + "bitflags 1.3.2", "bytes", "futures-util", "headers", @@ -653,6 +631,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84" + [[package]] name = "bitvec" version = "1.0.1" @@ -864,18 +848,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -[[package]] -name = "cap-fs-ext" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc48200a1a0fa6fba138b1802ad7def18ec1cdd92f7b2a04e21f1bd887f7b9" -dependencies = [ - "cap-primitives", - "cap-std", - "io-lifetimes", - "windows-sys 0.48.0", -] - [[package]] name = "cap-primitives" version = "1.0.15" @@ -883,7 +855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4b6df5b295dca8d56f35560be8c391d59f0420f72e546997154e24e765e6451" dependencies = [ "ambient-authority", - "fs-set-times 0.19.1", + "fs-set-times", "io-extras", "io-lifetimes", "ipnet", @@ -915,18 +887,6 @@ dependencies = [ "rustix 0.37.19", ] -[[package]] -name = "cap-time-ext" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e95002993b7baee6b66c8950470e59e5226a23b3af39fc59c47fe416dd39821a" -dependencies = [ - "cap-primitives", - "once_cell", - "rustix 0.37.19", - "winx", -] - [[package]] name = "cast" version = "0.3.0" @@ -1095,7 +1055,7 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_lex 0.2.4", "indexmap", "textwrap", @@ -1120,7 +1080,7 @@ checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" dependencies = [ "anstream", "anstyle", - "bitflags", + "bitflags 1.3.2", "clap_lex 0.4.1", "strsim", ] @@ -1210,7 +1170,7 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml", + "toml 0.5.11", "yaml-rust", ] @@ -1570,16 +1530,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "ctr" version = "0.8.0" @@ -1805,38 +1755,48 @@ dependencies = [ [[package]] name = "diesel" -version = "2.0.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72eb77396836a4505da85bae0712fa324b74acfe1876d7c2f7e694ef3d0ee373" +checksum = "f7a532c1f99a0f596f6960a60d1e119e91582b24b39e2d83a190e61262c3ef0c" dependencies = [ "diesel_derives", "libsqlite3-sys", "r2d2", + "time", ] [[package]] name = "diesel_derives" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad74fdcf086be3d4fdd142f67937678fe60ed431c3b2f08599e7687269410c4" +checksum = "74398b79d81e52e130d991afeed9c86034bb1b7735f46d2f5bf7deb261d80303" dependencies = [ - "proc-macro-error", + "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] name = "diesel_migrations" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ae22beef5e9d6fab9225ddb073c1c6c1a7a6ded5019d5da11d1e5c5adc34e2" +checksum = "6036b3f0120c5961381b570ee20a02432d7e2d27ea60de9578799cf9156914ac" dependencies = [ "diesel", "migrations_internals", "migrations_macros", ] +[[package]] +name = "diesel_table_macro_syntax" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" +dependencies = [ + "syn 2.0.16", +] + [[package]] name = "digest" version = "0.9.0" @@ -2111,17 +2071,6 @@ dependencies = [ "instant", ] -[[package]] -name = "fd-lock" -version = "3.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ae6b3d9530211fb3b12a95374b8b0823be812f53d09e18c5675c0146b09642" -dependencies = [ - "cfg-if", - "rustix 0.37.19", - "windows-sys 0.48.0", -] - [[package]] name = "fdeflate" version = "0.3.0" @@ -2211,17 +2160,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs-set-times" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" -dependencies = [ - "io-lifetimes", - "rustix 0.36.13", - "windows-sys 0.45.0", -] - [[package]] name = "fs-set-times" version = "0.19.1" @@ -2540,7 +2478,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "bytes", "headers-core", "http", @@ -2643,6 +2581,7 @@ dependencies = [ "generic-array", "indexmap", "libipld", + "libsqlite3-sys", "proptest", "serde", "signature 2.1.0", @@ -2695,6 +2634,8 @@ dependencies = [ "libipld", "libp2p", "libp2p-identity", + "libsqlite3-sys", + "openssl", "proptest", "reqwest", "semver 1.0.17", @@ -2729,15 +2670,13 @@ dependencies = [ "stacker", "thiserror", "tokio", - "tokio-test", "tracing", - "wasi-cap-std-sync", "wasi-common", "wasmparser 0.104.0", "wasmtime", "wasmtime-component-util", "wat", - "wit-component 0.8.2", + "wit-component", ] [[package]] @@ -3795,6 +3734,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" dependencies = [ + "cc", "pkg-config", "vcpkg", ] @@ -3840,11 +3780,10 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" dependencies = [ - "cfg-if", "value-bag", ] @@ -3958,19 +3897,19 @@ dependencies = [ [[package]] name = "migrations_internals" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c493c09323068c01e54c685f7da41a9ccf9219735c3766fbfd6099806ea08fbc" +checksum = "0f23f71580015254b020e856feac3df5878c2c7a8812297edd6c0a485ac9dada" dependencies = [ "serde", - "toml", + "toml 0.7.4", ] [[package]] name = "migrations_macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a8ff27a350511de30cdabb77147501c36ef02e0451d957abea2f30caffb2b58" +checksum = "cce3325ac70e67bbab5bd837a31cae01f1a6db64e0e744a33cb03a543469ef08" dependencies = [ "migrations_internals", "proc-macro2", @@ -4179,7 +4118,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -4232,7 +4171,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.6.5", @@ -4370,7 +4309,7 @@ version = "0.10.52" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -4396,6 +4335,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.26.0+1.1.1u" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efc62c9f12b22b8f5208c23a7200a442b2e5999f8bdf80233852122b5a4f6f37" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.87" @@ -4404,6 +4352,7 @@ checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -4690,7 +4639,7 @@ version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aaeebc51f9e7d2c150d3f3bfeb667f2aa985db5ef1e3d212847bdedb488beeaa" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", @@ -4704,7 +4653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", @@ -4760,7 +4709,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] @@ -4770,7 +4719,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ "thiserror", - "toml", + "toml 0.5.11", ] [[package]] @@ -4836,7 +4785,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29f1b898011ce9595050a68e60f90bad083ff2987a695a42357134c8381fba70" dependencies = [ "bit-set", - "bitflags", + "bitflags 1.3.2", "byteorder", "lazy_static", "num-traits", @@ -4917,7 +4866,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "memchr", "unicase", ] @@ -5153,7 +5102,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -5162,7 +5111,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -5337,7 +5286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "serde", ] @@ -5454,7 +5403,7 @@ version = "0.36.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a38f9520be93aba504e8ca974197f46158de5dcaa9fa04b57c57cd6a679d658" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -5468,7 +5417,7 @@ version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "itoa", @@ -5629,7 +5578,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -5737,6 +5686,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -6197,7 +6155,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225e483f02d0ad107168dc57381a8a40c3aeea6abe47f37506931f861643cfa8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "thiserror", @@ -6210,7 +6168,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -6225,22 +6183,6 @@ dependencies = [ "libc", ] -[[package]] -name = "system-interface" -version = "0.25.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928ebd55ab758962e230f51ca63735c5b283f26292297c81404289cda5d78631" -dependencies = [ - "bitflags", - "cap-fs-ext", - "cap-std", - "fd-lock", - "io-lifetimes", - "rustix 0.37.19", - "windows-sys 0.48.0", - "winx", -] - [[package]] name = "tap" version = "1.0.1" @@ -6436,19 +6378,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-test" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53474327ae5e166530d17f2d956afcb4f8a004de581b3cae10f12006bc8163e3" -dependencies = [ - "async-stream", - "bytes", - "futures-core", - "tokio", - "tokio-stream", -] - [[package]] name = "tokio-tungstenite" version = "0.18.0" @@ -6485,6 +6414,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tonic" version = "0.9.2" @@ -6921,13 +6884,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.0.0-alpha.9" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" -dependencies = [ - "ctor", - "version_check", -] +checksum = "a4d330786735ea358f3bc09eea4caa098569c1c93f342d9aca0514915022fe7e" [[package]] name = "vcpkg" @@ -7003,30 +6962,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi-cap-std-sync" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "612510e6c7b6681f7d29ce70ef26e18349c26acd39b7d89f1727d90b7f58b20e" -dependencies = [ - "anyhow", - "async-trait", - "cap-fs-ext", - "cap-rand", - "cap-std", - "cap-time-ext", - "fs-set-times 0.18.1", - "io-extras", - "io-lifetimes", - "is-terminal", - "once_cell", - "rustix 0.36.13", - "system-interface", - "tracing", - "wasi-common", - "windows-sys 0.45.0", -] - [[package]] name = "wasi-common" version = "8.0.1" @@ -7034,7 +6969,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "008136464e438c5049a614b6ea1bae9f6c4d354ce9ee2b4d9a1ac6e73f31aafc" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "cap-rand", "cap-std", "io-extras", @@ -7140,19 +7075,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasm-metadata" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6956efd8a1a2c48a707e9a1b2da729834a0f8e4c58117493b0d9d089cee468" -dependencies = [ - "anyhow", - "indexmap", - "serde", - "wasm-encoder 0.25.0", - "wasmparser 0.102.0", -] - [[package]] name = "wasm-metadata" version = "0.5.0" @@ -7279,7 +7201,7 @@ dependencies = [ "rustix 0.36.13", "serde", "sha2 0.10.6", - "toml", + "toml 0.5.11", "windows-sys 0.45.0", "zstd", ] @@ -7737,7 +7659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", @@ -7771,7 +7693,7 @@ checksum = "6b16a7462893c46c6d3dd2a1f99925953bdbb921080606e1a4c9344864492fa4" dependencies = [ "anyhow", "async-trait", - "bitflags", + "bitflags 1.3.2", "thiserror", "tracing", "wasmtime", @@ -8035,6 +7957,15 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winnow" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.8.0" @@ -8059,50 +7990,50 @@ version = "0.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c52a121f0fbf9320d5f2a9a5d82f6cb7557eda5e8b47fc3e7f359ec866ae960" dependencies = [ - "bitflags", + "bitflags 1.3.2", "io-lifetimes", "windows-sys 0.48.0", ] [[package]] name = "wit-bindgen" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7cf57f8786216c5652e1228b25203af2ff523808b5e9d3671894eee2bf7264" +checksum = "ad22d93d3f55847ac4b3df31607a26f35231754ef472382319de032770d8b5bf" dependencies = [ - "bitflags", + "bitflags 2.3.1", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef177b73007d86c720931d0e2ea7e30eb8c9776e58361717743fc1e83cfacfe5" +checksum = "5bc1b5a6e87f16491f2297f75312dc0fb354f8c88c8bece53ea0d3167fc98867" dependencies = [ "anyhow", - "wit-component 0.7.4", - "wit-parser 0.6.4", + "wit-component", + "wit-parser 0.7.1", ] [[package]] name = "wit-bindgen-rust" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efdf5b00935b7b52d0e56cae1960f8ac13019a285f5aa762ff6bd7139a5c28a2" +checksum = "7946a66f1132d3322c29de9d28097bd263f67e1e0909054f91253aa103cdf8be" dependencies = [ "heck", - "wasm-metadata 0.3.1", + "wasm-metadata", "wit-bindgen-core", "wit-bindgen-rust-lib", - "wit-component 0.7.4", + "wit-component", ] [[package]] name = "wit-bindgen-rust-lib" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0a8f4b5fb1820b9d232beb122936425f72ec8fe6acb56e5d8782cfe55083da" +checksum = "0baf7325748c5d363ab6ed3ddbd155c241cfe385410c61f2505ec978a61a2d2c" dependencies = [ "heck", "wit-bindgen-core", @@ -8110,33 +8041,16 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadf1adf12ed25629b06272c16b335ef8c5a240d0ca64ab508a955ac3b46172c" +checksum = "42c131da5d2ba7746908e1401d474640371c31ad05281528c2a9e945a87d19be" dependencies = [ "anyhow", "proc-macro2", - "syn 1.0.109", + "syn 2.0.16", "wit-bindgen-core", "wit-bindgen-rust", - "wit-component 0.7.4", -] - -[[package]] -name = "wit-component" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed04310239706efc71cc8b995cb0226089c5b5fd260c3bd800a71486bd3cec97" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "url", - "wasm-encoder 0.25.0", - "wasm-metadata 0.3.1", - "wasmparser 0.102.0", - "wit-parser 0.6.4", + "wit-component", ] [[package]] @@ -8146,12 +8060,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e291ff83cb9c8e59963cc6922bdda77ed8f5517d6835f0c98070c4e7f1ae4996" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "indexmap", "log", "url", "wasm-encoder 0.26.0", - "wasm-metadata 0.5.0", + "wasm-metadata", "wasmparser 0.104.0", "wit-parser 0.7.1", ] diff --git a/Cargo.toml b/Cargo.toml index c08b520d..222c0851 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ rust-version = "1.66.0" [workspace.dependencies] anyhow = { version = "1.0", features = ["backtrace"] } +tokio = { version = "1.26", features = ["fs", "io-util", "io-std", "macros", "rt", "rt-multi-thread"] } tracing = "0.1" # Speedup build on macOS diff --git a/README.md b/README.md index 545ffc13..6d6a652a 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,6 @@ started. Run `nix develop` or `direnv allow` to load the `devShell` flake output, according to your preference. -#### External Dependencies - -- [SQLite][sqlite] - ### Formatting For formatting Rust in particular, we automatically format on `nightly`, as it diff --git a/codecov.yml b/codecov.yml index e2fc69c4..06a753ec 100644 --- a/codecov.yml +++ b/codecov.yml @@ -16,3 +16,7 @@ coverage: project: default: threshold: 5% + patch: + default: + target: 0% + if_ci_failed: ignore diff --git a/docker/Dockerfile b/docker/Dockerfile index 9b0e5574..2081e55c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,43 +11,45 @@ FROM builder-$TARGETARCH as builder RUN adduser --disabled-password --disabled-login --gecos "" --no-create-home homestar -RUN apt update && apt install -y protobuf-compiler sqlite - RUN cargo init +RUN rm -Rf src -# touch lib.rs as we combine both -RUN touch src/lib.rs +RUN cargo init --lib homestar-core && \ + cargo init --lib homestar-guest-wasm && \ + cargo init --lib homestar-wasm && \ + cargo init --lib homestar-runtime -# touch benches as it's part of Cargo.toml -RUN mkdir benches -RUN touch benches/a_benchmark.rs +RUN echo "fn main() {}" > ./homestar-runtime/src/main.rs # copy cargo.* -COPY Cargo.lock ./Cargo.lock -COPY Cargo.toml ./Cargo.toml +COPY Cargo.lock Cargo.toml .env diesel.toml ./ +COPY ../homestar-core/Cargo.toml ./homestar-core/ +COPY ../homestar-guest-wasm/Cargo.toml ./homestar-guest-wasm/ +COPY ../homestar-wasm/Cargo.toml ./homestar-wasm/ +COPY ../homestar-runtime/Cargo.toml ../homestar-runtime/migrations ./homestar-runtime/ # cache depencies RUN mkdir .cargo RUN cargo vendor > .cargo/config -RUN --mount=type=cache,target=$CARGO_HOME/registry \ - --mount=type=cache,target=$CARGO_HOME/.git \ - --mount=type=cache,target=homestar-runtime/target,sharing=locked \ - cargo build --target $CARGO_BUILD_TARGET --release +RUN cargo install diesel_cli --no-default-features --features "sqlite-bundled" +RUN diesel setup +RUN diesel migration run +RUN --mount=type=cache,id=cargo,target=$CARGO_HOME/registry \ + --mount=type=cache,id=git,target=$CARGO_HOME/.git \ + --mount=type=cache,id=target,target=./target,sharing=locked \ + cargo build --workspace --target $CARGO_BUILD_TARGET --release -# copy src -COPY src ./src -# copy benches -COPY benches ./benches +# copy workspace +COPY . ./ # final build for release -RUN rm ./target/$CARGO_BUILD_TARGET/release/deps/*homestar* -RUN --mount=type=cache,target=$CARGO_HOME/registry \ - --mount=type=cache,target=$CARGO_HOME/.git \ - --mount=type=cache,target=homestar/target,sharing=locked \ - cargo build --target $CARGO_BUILD_TARGET --bin homestar-runtime --release - +RUN cargo build --workspace --target $CARGO_BUILD_TARGET --release RUN musl-strip ./target/$CARGO_BUILD_TARGET/release/homestar-runtime -RUN mv ./target/$CARGO_BUILD_TARGET/release/homestar-runtime /usr/local/bin +RUN mv ./target/$CARGO_BUILD_TARGET/release/homestar-runtime /usr/local/bin/homestar-runtime + +RUN mv ./*.db /etc/ +RUN mv ./homestar-runtime/config /etc/config +RUN mv $CARGO_HOME/bin/diesel /usr/local/bin/diesel FROM scratch @@ -57,7 +59,11 @@ ARG log_level=info ENV RUST_BACKTRACE=${backtrace} \ RUST_LOG=${log_level} -COPY --from=builder /usr/local/bin/homestar +COPY ../homestar-runtime/migrations .env diesel.toml ./ +COPY --from=builder /usr/local/bin/homestar-runtime ./homestar +COPY --from=builder /usr/local/bin/diesel /usr/local/bin/diesel +COPY --from=builder /etc/*.db ./ +COPY --from=builder /etc/config ./config COPY --from=builder /etc/passwd /etc/passwd COPY --from=builder /etc/group /etc/group diff --git a/flake.nix b/flake.nix index a3cf75f4..52db938f 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,6 @@ pre-commit protobuf rustup - sqlite diesel-cli direnv self.packages.${system}.irust diff --git a/homestar-core/Cargo.toml b/homestar-core/Cargo.toml index f0d6e9d0..be5819be 100644 --- a/homestar-core/Cargo.toml +++ b/homestar-core/Cargo.toml @@ -17,7 +17,6 @@ authors = { workspace = true } path = "src/lib.rs" bench = false doctest = true -crate-type = ["cdylib", "rlib"] [dependencies] # return to version.workspace = true after the following issue is fixed: @@ -29,6 +28,7 @@ enum-assoc = "0.4" generic-array = "0.14" indexmap = "1.9" libipld = "0.16" +libsqlite3-sys = { version = "0.26", features = ["bundled"] } proptest = { version = "1.1", optional = true } serde = { version = "1.0", features = ["derive"] } signature = "2.0" diff --git a/homestar-core/src/workflow/instruction_result.rs b/homestar-core/src/workflow/instruction_result.rs index 0823f72e..5674bd0a 100644 --- a/homestar-core/src/workflow/instruction_result.rs +++ b/homestar-core/src/workflow/instruction_result.rs @@ -5,7 +5,7 @@ use anyhow::anyhow; use diesel::{ - backend::RawValue, + backend::Backend, deserialize::{self, FromSql}, serialize::{self, IsNull, Output, ToSql}, sql_types::Binary, @@ -122,9 +122,13 @@ where } /// Diesel, [Sqlite] [FromSql] implementation. -impl FromSql for InstructionResult { - fn from_sql(bytes: RawValue<'_, Sqlite>) -> deserialize::Result { - let raw_bytes = <*const [u8] as FromSql>::from_sql(bytes)?; +impl FromSql for InstructionResult +where + DB: Backend, + *const [u8]: FromSql, +{ + fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result { + let raw_bytes = <*const [u8] as FromSql>::from_sql(bytes)?; let raw_bytes: &[u8] = unsafe { &*raw_bytes }; let decoded: Ipld = DagCborCodec.decode(raw_bytes)?; Ok(InstructionResult::try_from(decoded)?) diff --git a/homestar-core/src/workflow/issuer.rs b/homestar-core/src/workflow/issuer.rs index c8574e24..35af0426 100644 --- a/homestar-core/src/workflow/issuer.rs +++ b/homestar-core/src/workflow/issuer.rs @@ -2,7 +2,7 @@ //! a receipt. use diesel::{ - backend::RawValue, + backend::Backend, deserialize::{self, FromSql}, serialize::{self, IsNull, Output, ToSql}, sql_types::Text, @@ -61,9 +61,13 @@ impl ToSql for Issuer { } } -impl FromSql for Issuer { - fn from_sql(bytes: RawValue<'_, Sqlite>) -> deserialize::Result { - let s = >::from_sql(bytes)?; +impl FromSql for Issuer +where + DB: Backend, + String: FromSql, +{ + fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result { + let s = String::from_sql(bytes)?; Ok(Issuer(Principle::from_str(&s)?)) } } diff --git a/homestar-core/src/workflow/pointer.rs b/homestar-core/src/workflow/pointer.rs index f6935808..2a5fbb6e 100644 --- a/homestar-core/src/workflow/pointer.rs +++ b/homestar-core/src/workflow/pointer.rs @@ -10,7 +10,7 @@ use anyhow::ensure; use diesel::{ - backend::RawValue, + backend::Backend, deserialize::{self, FromSql}, serialize::{self, IsNull, Output, ToSql}, sql_types::Text, @@ -233,9 +233,13 @@ impl ToSql for Pointer { } } -impl FromSql for Pointer { - fn from_sql(bytes: RawValue<'_, Sqlite>) -> deserialize::Result { - let s = >::from_sql(bytes)?; +impl FromSql for Pointer +where + DB: Backend, + String: FromSql, +{ + fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result { + let s = String::from_sql(bytes)?; Ok(Pointer::new(Cid::from_str(&s)?)) } } diff --git a/homestar-core/src/workflow/prf.rs b/homestar-core/src/workflow/prf.rs index 0be42167..333d30bf 100644 --- a/homestar-core/src/workflow/prf.rs +++ b/homestar-core/src/workflow/prf.rs @@ -4,7 +4,7 @@ //! [Task]: super::Task use diesel::{ - backend::RawValue, + backend::Backend, deserialize::{self, FromSql}, serialize::{self, IsNull, Output, ToSql}, sql_types::Binary, @@ -77,9 +77,13 @@ impl ToSql for UcanPrf { } } -impl FromSql for UcanPrf { - fn from_sql(bytes: RawValue<'_, Sqlite>) -> deserialize::Result { - let raw_bytes = <*const [u8] as FromSql>::from_sql(bytes)?; +impl FromSql for UcanPrf +where + DB: Backend, + *const [u8]: FromSql, +{ + fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result { + let raw_bytes = <*const [u8] as FromSql>::from_sql(bytes)?; let raw_bytes: &[u8] = unsafe { &*raw_bytes }; let decoded = DagCborCodec.decode(raw_bytes)?; Ok(UcanPrf::new(decoded)) diff --git a/homestar-guest-wasm/Cargo.toml b/homestar-guest-wasm/Cargo.toml index 5a70a01d..26060ef4 100644 --- a/homestar-guest-wasm/Cargo.toml +++ b/homestar-guest-wasm/Cargo.toml @@ -7,7 +7,7 @@ rust-version = { workspace = true } [dependencies] image = { version = "0.24", default-features = false, features = ["png"] } -wit-bindgen = "0.4" +wit-bindgen = "0.6" [dev-dependencies] image = "0.24" diff --git a/homestar-runtime/Cargo.toml b/homestar-runtime/Cargo.toml index 86d2c85d..289faece 100644 --- a/homestar-runtime/Cargo.toml +++ b/homestar-runtime/Cargo.toml @@ -39,8 +39,8 @@ config = "0.13" console-subscriber = { version = "0.1", default-features = false, features = [ "parking_lot" ], optional = true } crossbeam = "0.8" dagga = "0.2" -diesel = { version = "2.0", features = ["sqlite", "r2d2", "returning_clauses_for_sqlite_3_35"] } -diesel_migrations = "2.0" +diesel = { version = "2.1", features = ["sqlite", "r2d2", "returning_clauses_for_sqlite_3_35"] } +diesel_migrations = "2.1" dotenvy = "0.15" enum-assoc = "0.4" futures = "0.3" @@ -57,13 +57,15 @@ json = "0.12" libipld = "0.16" libp2p = { version = "0.51", features = ["kad", "request-response", "macros", "identify", "mdns", "gossipsub", "tokio", "dns", "mplex", "tcp", "noise", "yamux", "websocket"] } libp2p-identity = "0.1" +libsqlite3-sys = { version = "0.26", features = ["bundled"] } +openssl = { version = "0.10", features = ["vendored"] } proptest = { version = "1.1", optional = true } reqwest = { version = "0.11", features = ["json"] } semver = "1.0" serde = { version = "1.0", features = ["derive"] } serde_with = "2.3" thiserror = "1.0" -tokio = { version = "1.26", features = ["fs", "io-util", "io-std", "macros", "rt", "rt-multi-thread"] } +tokio = { workspace = true } tracing = { workspace = true } tracing-logfmt = { version = "0.3", optional = true } tracing-subscriber = { version = "0.3", features = ["env-filter", "parking_lot", "registry"] } diff --git a/homestar-runtime/src/receipt.rs b/homestar-runtime/src/receipt.rs index 8a1490c7..e9ed45bd 100644 --- a/homestar-runtime/src/receipt.rs +++ b/homestar-runtime/src/receipt.rs @@ -3,7 +3,7 @@ use crate::db::schema::receipts; use anyhow::anyhow; use diesel::{ - backend::RawValue, + backend::Backend, deserialize::{self, FromSql}, serialize::{self, IsNull, Output, ToSql}, sql_types::Binary, @@ -315,9 +315,13 @@ where } } -impl FromSql for LocalIpld { - fn from_sql(bytes: RawValue<'_, Sqlite>) -> deserialize::Result { - let raw_bytes = <*const [u8] as FromSql>::from_sql(bytes)?; +impl FromSql for LocalIpld +where + DB: Backend, + *const [u8]: FromSql, +{ + fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result { + let raw_bytes = <*const [u8] as FromSql>::from_sql(bytes)?; let raw_bytes: &[u8] = unsafe { &*raw_bytes }; let decoded = DagCborCodec.decode(raw_bytes)?; Ok(LocalIpld(decoded)) diff --git a/homestar-wasm/Cargo.toml b/homestar-wasm/Cargo.toml index 7c747061..b39f4535 100644 --- a/homestar-wasm/Cargo.toml +++ b/homestar-wasm/Cargo.toml @@ -17,7 +17,6 @@ authors = { workspace = true } path = "src/lib.rs" bench = false doctest = true -crate-type = ["cdylib", "rlib"] [dependencies] # return to version.workspace = true after the following issue is fixed: @@ -35,7 +34,6 @@ serde_ipld_dagcbor = "0.2" stacker = "0.1" thiserror = "1.0" tracing = { workspace = true } -wasi-cap-std-sync = "8.0" wasi-common = "8.0" wasmparser = "0.104" wasmtime = { version = "8.0", features = ["async", "component-model", "default"] } @@ -46,8 +44,7 @@ wit-component = "0.8" [dev-dependencies] criterion = "0.4" image = "0.24" -tokio = { version = "1.25", default_features = false } -tokio-test = "0.4" +tokio = { workspace = true } [features] default = [] diff --git a/homestar-wasm/fixtures/add_one.wasm b/homestar-wasm/fixtures/add_one.wasm deleted file mode 100755 index e0a25de5..00000000 Binary files a/homestar-wasm/fixtures/add_one.wasm and /dev/null differ diff --git a/homestar-wasm/fixtures/add_one.wit b/homestar-wasm/fixtures/add_one.wit deleted file mode 100644 index 61c9c00d..00000000 --- a/homestar-wasm/fixtures/add_one.wit +++ /dev/null @@ -1,3 +0,0 @@ -default world homestar { - export add-one: func(a: s32) -> s32 -} diff --git a/homestar-wasm/fixtures/add_one_arg.txt b/homestar-wasm/fixtures/add_one_arg.txt deleted file mode 100644 index bf0d87ab..00000000 --- a/homestar-wasm/fixtures/add_one_arg.txt +++ /dev/null @@ -1 +0,0 @@ -4 \ No newline at end of file diff --git a/homestar-wasm/fixtures/append_string_arg.txt b/homestar-wasm/fixtures/append_string_arg.txt deleted file mode 100644 index 5638d8ba..00000000 --- a/homestar-wasm/fixtures/append_string_arg.txt +++ /dev/null @@ -1 +0,0 @@ -"Hello" \ No newline at end of file diff --git a/homestar-wasm/fixtures/homestar-guest-wasm.wasm b/homestar-wasm/fixtures/homestar-guest-wasm.wasm new file mode 100755 index 00000000..1fa70084 Binary files /dev/null and b/homestar-wasm/fixtures/homestar-guest-wasm.wasm differ diff --git a/homestar-wasm/fixtures/homestar_guest_wasm.wasm b/homestar-wasm/fixtures/homestar_guest_wasm.wasm index b96fd619..1fa70084 100755 Binary files a/homestar-wasm/fixtures/homestar_guest_wasm.wasm and b/homestar-wasm/fixtures/homestar_guest_wasm.wasm differ diff --git a/homestar-wasm/fixtures/homestar_guest_wasm_component.wasm b/homestar-wasm/fixtures/homestar_guest_wasm_component.wasm new file mode 100644 index 00000000..2d800da0 Binary files /dev/null and b/homestar-wasm/fixtures/homestar_guest_wasm_component.wasm differ diff --git a/homestar-wasm/tests/execute_wasm.rs b/homestar-wasm/tests/execute_wasm.rs index 03c4d182..61fb749e 100644 --- a/homestar-wasm/tests/execute_wasm.rs +++ b/homestar-wasm/tests/execute_wasm.rs @@ -26,7 +26,7 @@ async fn test_execute_wat() { ("func".into(), Ipld::String("add_one".to_string())), ("args".into(), Ipld::List(vec![Ipld::Integer(1)])), ]))); - + // TODO: Replace this with updated versions and guest_wasm code. let wat = fs::read(fixtures("add_one_component.wat")).unwrap(); let mut env = World::instantiate(wat, "add-one", State::default()) .await @@ -52,7 +52,7 @@ async fn test_execute_wasm_underscore() { ("args".into(), Ipld::List(vec![Ipld::Integer(1)])), ]))); - let wasm = fs::read(fixtures("add_one.wasm")).unwrap(); + let wasm = fs::read(fixtures("homestar_guest_wasm.wasm")).unwrap(); let mut env = World::instantiate(wasm, "add_one", State::default()) .await .unwrap(); @@ -70,7 +70,7 @@ async fn test_execute_wasm_hyphen() { ("args".into(), Ipld::List(vec![Ipld::Integer(10)])), ]))); - let wasm = fs::read(fixtures("add_one.wasm")).unwrap(); + let wasm = fs::read(fixtures("homestar-guest-wasm.wasm")).unwrap(); let mut env = World::instantiate(wasm, "add-one", State::default()) .await .unwrap(); @@ -83,7 +83,7 @@ async fn test_execute_wasm_hyphen() { #[tokio::test] async fn test_wasm_wrong_fun() { - let wasm = fs::read(fixtures("add_one.wasm")).unwrap(); + let wasm = fs::read(fixtures("homestar_guest_wasm.wasm")).unwrap(); let env = World::instantiate(wasm, "add-onez", State::default()).await; assert!(env.is_err()); } @@ -172,10 +172,9 @@ async fn test_execute_wasms_in_seq() { ), ]))); - let wasm1 = fs::read(fixtures("add_one.wasm")).unwrap(); - let wasm2 = fs::read(fixtures("homestar_guest_wasm.wasm")).unwrap(); + let wasm = fs::read(fixtures("homestar_guest_wasm.wasm")).unwrap(); - let mut env = World::instantiate(wasm1, "add_one", State::default()) + let mut env = World::instantiate(wasm.clone(), "add_one", State::default()) .await .unwrap(); @@ -186,7 +185,7 @@ async fn test_execute_wasms_in_seq() { assert_eq!(res, Output::Value(wasmtime::component::Val::S32(2))); - let env2 = World::instantiate_with_current_env(wasm2, "append_string", &mut env) + let env2 = World::instantiate_with_current_env(wasm, "append_string", &mut env) .await .unwrap();