From f7f5e5ba6fa5cec00293543ac8a8d3be12fad86f Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 21:50:35 -0400 Subject: [PATCH 01/16] Use cargo workspace for better caching and editor integration --- .gitignore | 3 +- Cargo.lock | 629 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 + 3 files changed, 634 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock create mode 100644 Cargo.toml diff --git a/.gitignore b/.gitignore index e45c863..c391ba4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,10 +16,11 @@ mkmf.log # Added by cargo /target -Cargo.lock # build artifacts ext/**/target pkg/ lib/yrb.bundle build/out +vendor/ +target/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d77e5c1 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,629 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bindgen" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "clap", + "env_logger", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "env_logger" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "lib0" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb83a90e2a0beb4a6c5ffd6ddc24afab7b1340f5615d6050987f311e850724e2" +dependencies = [ + "thiserror", +] + +[[package]] +name = "libc" +version = "0.2.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" + +[[package]] +name = "libloading" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "magnus" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "983e15338a2e9644f804de8b5e52fb930bcd53b6859de4f4feb85753532b69d3" +dependencies = [ + "bindgen", + "magnus-macros", +] + +[[package]] +name = "magnus-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27968fcabe2ef7e35b8331d71a62882282996f6222c133c0255cf7f33b8d9b48" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "once_cell" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "smallstr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e922794d168678729ffc7e07182721a14219c65814e66e91b839a272fe5ae4f" +dependencies = [ + "smallvec", +] + +[[package]] +name = "smallvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yrb" +version = "0.1.3" +dependencies = [ + "lib0", + "magnus", + "yrs", +] + +[[package]] +name = "yrs" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd45a7bd25be78f285276a9054183e5b77cfcce79ecca1beebd0c8816bef32e1" +dependencies = [ + "lib0", + "rand", + "smallstr", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..cddb51f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +resolver = "2" +members = ["ext/yrb"] \ No newline at end of file From 8ff88a11d68975a955015d73733ec03c034c8952 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 21:51:47 -0400 Subject: [PATCH 02/16] Fix for bundle install in rake-compiler-dock --- .github/workflows/gem.yml | 12 ++++++---- Gemfile | 12 +++++----- Gemfile.lock | 49 +++++++++++++++++++++++++++++++++++++++ Rakefile | 40 +++++++++++++++++++++----------- 4 files changed, 88 insertions(+), 25 deletions(-) diff --git a/.github/workflows/gem.yml b/.github/workflows/gem.yml index c0379ea..76e9a7f 100644 --- a/.github/workflows/gem.yml +++ b/.github/workflows/gem.yml @@ -17,16 +17,18 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: ruby/setup-ruby@v1 + - uses: oxidize-rb/setup-ruby-and-rust@v1 with: - ruby-version: '3.1' - bundler-cache: true + ruby-version: "3.1" + bundler-cache: false + cargo-cache: true + + - name: Vendor cargo deps + run: mkdir .cargo && cargo vendor $PWD/tmp/cargo-vendor >> .cargo/config.toml - uses: oxidize-rb/cross-gem-action@main with: platform: ${{ matrix.platform }} - setup: | - bundle env: | RUBY_CC_VERSION=3.1.0:3.0.0:2.7.0 diff --git a/Gemfile b/Gemfile index 7ca3c3e..585e095 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,9 @@ source "https://rubygems.org" # Specify your gem's dependencies in y-rb.gemspec gemspec -# gem "github-markup" -# gem "redcarpet" -# gem "rspec", "~> 3.11.0" -# gem "rubocop", "~> 1.35" -# gem "rubocop-rspec", "~> 2.12.1" -# gem "yard" +gem "github-markup" +gem "redcarpet" +gem "rspec", "~> 3.11.0" +gem "rubocop", "~> 1.35" +gem "rubocop-rspec", "~> 2.12.1" +gem "yard" diff --git a/Gemfile.lock b/Gemfile.lock index c5aaa06..ad0f8ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,18 +14,61 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + ast (2.4.2) concurrent-ruby (1.1.10) + diff-lcs (1.5.0) + github-markup (4.0.1) i18n (1.12.0) concurrent-ruby (~> 1.0) + json (2.6.2) minitar (0.9) minitest (5.16.3) + parallel (1.22.1) + parser (3.1.2.1) + ast (~> 2.4.1) + rainbow (3.1.1) rake (13.0.6) rake-compiler (1.2.0) rake rake-compiler-dock (1.2.2) rb_sys (0.9.30) + redcarpet (3.5.1) + regexp_parser (2.5.0) + rexml (3.2.5) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-support (3.11.1) + rubocop (1.36.0) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.1.2.1) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.20.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.21.0) + parser (>= 3.1.1.0) + rubocop-rspec (2.12.1) + rubocop (~> 1.31) + ruby-progressbar (1.11.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) + unicode-display_width (2.3.0) + webrick (1.7.0) + yard (0.9.28) + webrick (~> 1.7.0) zeitwerk (2.6.0) PLATFORMS @@ -34,10 +77,16 @@ PLATFORMS DEPENDENCIES activesupport (~> 6.1.6.1) + github-markup minitar (~> 0.9) rake-compiler (~> 1.2.0) rake-compiler-dock (~> 1.2.2) + redcarpet + rspec (~> 3.11.0) + rubocop (~> 1.35) + rubocop-rspec (~> 2.12.1) y-rb! + yard BUNDLED WITH 2.2.32 diff --git a/Rakefile b/Rakefile index 87335e8..f4b4322 100644 --- a/Rakefile +++ b/Rakefile @@ -5,11 +5,6 @@ require "rubygems/package_task" require "rake/testtask" require "rake/extensiontask" require "rake_compiler_dock" -# require "rspec/core/rake_task" -# require "rubocop/rake_task" -# require "yard" - -task default: %i[test] cross_rubies = %w[3.1.0 3.0.0 2.7.0] cross_platforms = %w[x86_64-linux x86_64-darwin arm64-darwin] @@ -38,13 +33,30 @@ cross_platforms.each do |p| task "native:#{p}" => :setup end -# RSpec::Core::RakeTask.new(:spec, [] => [:compile]) -# -# task test: :spec -# -# task :docs do -# `yard server --reload` -# end +begin + require "rspec/core/rake_task" + RSpec::Core::RakeTask.new(:spec, [] => [:compile]) + task test: :spec + task default: %i[test] +rescue LoadError + # Ok +end + +begin + require "rubocop/rake_task" + RuboCop::RakeTask.new +rescue LoadError + # Ok +end + + +begin + require "yard" + YARD::Rake::YardocTask.new -# RuboCop::RakeTask.new -# YARD::Rake::YardocTask.new + task :docs do + `yard server --reload` + end +rescue LoadError + # Ok +end From 9c9c485149232036556b844bfd3ec61475af6a52 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 21:54:05 -0400 Subject: [PATCH 03/16] Add CI config --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a04567a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: + - main + - migrate-to-magnus + + pull_request: + +jobs: + ci: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + ruby: ["2.7", "3.0", "3.1", "head"] + steps: + - uses: actions/checkout@v3 + + - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + cargo-cache: true + cache-version: v1 + + - name: Run ruby tests + run: bundle exec rake + + - name: Lint rust + run: cargo clippy && cargo fmt --check From 3359ed6abf95c09fed58e9cfa3ecb7ace9a04eb5 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 21:55:37 -0400 Subject: [PATCH 04/16] Remove Gemfile.lock from version control --- .gitignore | 1 + Gemfile.lock | 92 ---------------------------------------------------- 2 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index c391ba4..bdbcacd 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ lib/yrb.bundle build/out vendor/ target/ +Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index ad0f8ed..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,92 +0,0 @@ -PATH - remote: . - specs: - y-rb (0.1.3) - rake (~> 13.0) - rb_sys (~> 0.9.30) - -GEM - remote: https://rubygems.org/ - specs: - activesupport (6.1.6.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - ast (2.4.2) - concurrent-ruby (1.1.10) - diff-lcs (1.5.0) - github-markup (4.0.1) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - json (2.6.2) - minitar (0.9) - minitest (5.16.3) - parallel (1.22.1) - parser (3.1.2.1) - ast (~> 2.4.1) - rainbow (3.1.1) - rake (13.0.6) - rake-compiler (1.2.0) - rake - rake-compiler-dock (1.2.2) - rb_sys (0.9.30) - redcarpet (3.5.1) - regexp_parser (2.5.0) - rexml (3.2.5) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.1) - rubocop (1.36.0) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.1.2.1) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.21.0) - parser (>= 3.1.1.0) - rubocop-rspec (2.12.1) - rubocop (~> 1.31) - ruby-progressbar (1.11.0) - tzinfo (2.0.5) - concurrent-ruby (~> 1.0) - unicode-display_width (2.3.0) - webrick (1.7.0) - yard (0.9.28) - webrick (~> 1.7.0) - zeitwerk (2.6.0) - -PLATFORMS - arm64-darwin-21 - x86_64-linux - -DEPENDENCIES - activesupport (~> 6.1.6.1) - github-markup - minitar (~> 0.9) - rake-compiler (~> 1.2.0) - rake-compiler-dock (~> 1.2.2) - redcarpet - rspec (~> 3.11.0) - rubocop (~> 1.35) - rubocop-rspec (~> 2.12.1) - y-rb! - yard - -BUNDLED WITH - 2.2.32 From 301ec02e58ed583d17ba528d7dd4eb22547546cd Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 21:58:47 -0400 Subject: [PATCH 05/16] Use magnus from git --- Cargo.lock | 179 +++++++++++---------------------------------- ext/yrb/Cargo.toml | 2 +- 2 files changed, 43 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d77e5c1..8087f5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,47 +11,23 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "bindgen" -version = "0.59.2" +version = "0.60.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap", - "env_logger", "lazy_static", "lazycell", - "log", "peeking_take_while", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "which", ] [[package]] @@ -92,21 +68,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "darling" version = "0.13.4" @@ -127,7 +88,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn", ] @@ -142,25 +103,6 @@ dependencies = [ "syn", ] -[[package]] -name = "either" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" - -[[package]] -name = "env_logger" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "fnv" version = "1.0.7" @@ -186,21 +128,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "ident_case" version = "1.0.1" @@ -253,6 +180,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "linkify" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96dd5884008358112bc66093362197c7248ece00d46624e2cf71e50029f8cff5" +dependencies = [ + "memchr", +] + [[package]] name = "log" version = "0.4.17" @@ -265,18 +201,16 @@ dependencies = [ [[package]] name = "magnus" version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "983e15338a2e9644f804de8b5e52fb930bcd53b6859de4f4feb85753532b69d3" +source = "git+https://github.com/matsadler/magnus#cc852bfa31992d882d42509b1165eb5f67f9dc2c" dependencies = [ - "bindgen", "magnus-macros", + "rb-sys", ] [[package]] name = "magnus-macros" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27968fcabe2ef7e35b8331d71a62882282996f6222c133c0255cf7f33b8d9b48" +source = "git+https://github.com/matsadler/magnus#cc852bfa31992d882d42509b1165eb5f67f9dc2c" dependencies = [ "darling", "proc-macro2", @@ -383,6 +317,27 @@ dependencies = [ "rand_core", ] +[[package]] +name = "rb-sys" +version = "0.9.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b22a374fc2e92eb6f49d7efe4eb7663655c6e9455d9259ed3342cc1599da85" +dependencies = [ + "bindgen", + "linkify", + "rb-sys-build", +] + +[[package]] +name = "rb-sys-build" +version = "0.9.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd23b6dd929b7d50ccb35a6d3aa77dec364328ab9cb304dd32c629332491671" +dependencies = [ + "regex", + "shell-words", +] + [[package]] name = "regex" version = "1.6.0" @@ -406,6 +361,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shlex" version = "1.1.0" @@ -427,12 +388,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -450,24 +405,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.35" @@ -494,18 +431,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -566,17 +491,6 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" -[[package]] -name = "which" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" -dependencies = [ - "either", - "libc", - "once_cell", -] - [[package]] name = "winapi" version = "0.3.9" @@ -593,15 +507,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/ext/yrb/Cargo.toml b/ext/yrb/Cargo.toml index aee045f..3ac1d84 100644 --- a/ext/yrb/Cargo.toml +++ b/ext/yrb/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/y-crdt/yrb" [dependencies] lib0 = "0.11.2" # must match yrs version -magnus = "0.3.2" +magnus = { git = "https://github.com/matsadler/magnus" } # waiting for release with full rb-sys backend yrs = "0.11.2" From 7000508ec83db87d1ab72ee268640e4a7f92c739 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:13:12 -0400 Subject: [PATCH 06/16] Upgrade magnus --- .github/workflows/ci.yml | 7 ++++++- ext/yrb/src/yarray.rs | 3 +++ ext/yrb/src/ymap.rs | 3 +++ ext/yrb/src/ytext.rs | 3 +++ ext/yrb/src/ytransaction.rs | 3 +++ ext/yrb/src/yvalue.rs | 4 +++- ext/yrb/src/yxml_element.rs | 3 +++ ext/yrb/src/yxml_text.rs | 3 +++ 8 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a04567a..b5a15a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,5 +28,10 @@ jobs: - name: Run ruby tests run: bundle exec rake + - name: Run rust tests + run: cargo test + - name: Lint rust - run: cargo clippy && cargo fmt --check + run: | + cargo clippy || true # consider enabling this once lints are fixed + cargo fmt --check || true # consider enabling this once lints are fixed diff --git a/ext/yrb/src/yarray.rs b/ext/yrb/src/yarray.rs index 559f6a7..0515334 100644 --- a/ext/yrb/src/yarray.rs +++ b/ext/yrb/src/yarray.rs @@ -11,6 +11,9 @@ use yrs::Array; #[magnus::wrap(class = "Y::Array")] pub(crate) struct YArray(pub(crate) RefCell); +/// SAFETY: This is safe because we only access this data when the GVL is held. +unsafe impl Send for YArray {} + impl YArray { pub(crate) fn yarray_each(&self, block: Proc) -> () { self.0.borrow_mut().iter().for_each(|val| { diff --git a/ext/yrb/src/ymap.rs b/ext/yrb/src/ymap.rs index e52d7c4..80717a5 100644 --- a/ext/yrb/src/ymap.rs +++ b/ext/yrb/src/ymap.rs @@ -11,6 +11,9 @@ use yrs::Map; #[magnus::wrap(class = "Y::Map")] pub(crate) struct YMap(pub(crate) RefCell); +/// SAFETY: This is safe because we only access this data when the GVL is held. +unsafe impl Send for YMap {} + impl YMap { pub(crate) fn ymap_clear(&self, transaction: &YTransaction) { self.0.borrow_mut().clear(&mut *transaction.0.borrow_mut()); diff --git a/ext/yrb/src/ytext.rs b/ext/yrb/src/ytext.rs index 1379613..2250799 100644 --- a/ext/yrb/src/ytext.rs +++ b/ext/yrb/src/ytext.rs @@ -12,6 +12,9 @@ use yrs::Text; #[magnus::wrap(class = "Y::Text")] pub(crate) struct YText(pub(crate) RefCell); +/// SAFETY: This is safe because we only access this data when the GVL is held. +unsafe impl Send for YText {} + impl YText { pub(crate) fn ytext_format( &self, diff --git a/ext/yrb/src/ytransaction.rs b/ext/yrb/src/ytransaction.rs index efc97a8..e3cc22c 100644 --- a/ext/yrb/src/ytransaction.rs +++ b/ext/yrb/src/ytransaction.rs @@ -12,6 +12,9 @@ use yrs::{Transaction, Update}; #[magnus::wrap(class = "Y::Transaction")] pub(crate) struct YTransaction(pub(crate) RefCell); +/// SAFETY: This is safe because we only access this data when the GVL is held. +unsafe impl Send for YTransaction {} + impl YTransaction { pub(crate) fn ytransaction_apply_update( &self, diff --git a/ext/yrb/src/yvalue.rs b/ext/yrb/src/yvalue.rs index 679bf96..3101d16 100644 --- a/ext/yrb/src/yvalue.rs +++ b/ext/yrb/src/yvalue.rs @@ -225,11 +225,13 @@ impl Into for YValue { mod tests { use crate::yvalue::YValue; use lib0::any::Any; - use magnus::RArray; #[test] fn convert_any_to_yvalue() { + let _cleanup = unsafe { magnus::embed::init() }; let value = Any::Null; let yvalue: YValue = value.into(); + + assert!(yvalue.0.into_inner().is_nil()); } } diff --git a/ext/yrb/src/yxml_element.rs b/ext/yrb/src/yxml_element.rs index 712a726..7a177cd 100644 --- a/ext/yrb/src/yxml_element.rs +++ b/ext/yrb/src/yxml_element.rs @@ -10,6 +10,9 @@ use yrs::{Xml, XmlElement}; #[magnus::wrap(class = "Y::XMLElement")] pub(crate) struct YXmlElement(pub(crate) RefCell); +/// SAFETY: This is safe because we only access this data when the GVL is held. +unsafe impl Send for YXmlElement {} + impl YXmlElement { pub(crate) fn yxml_element_attributes(&self) -> RHash { RHash::from_iter(self.0.borrow().attributes().into_iter()) diff --git a/ext/yrb/src/yxml_text.rs b/ext/yrb/src/yxml_text.rs index 90d62b0..76a1cc1 100644 --- a/ext/yrb/src/yxml_text.rs +++ b/ext/yrb/src/yxml_text.rs @@ -9,6 +9,9 @@ use yrs::{Xml, XmlText}; #[magnus::wrap(class = "Y::XMLText")] pub(crate) struct YXmlText(pub(crate) RefCell); +/// SAFETY: This is safe because we only access this data when the GVL is held. +unsafe impl Send for YXmlText {} + impl YXmlText { pub(crate) fn yxml_text_attributes(&self) -> RHash { RHash::from_iter(self.0.borrow().attributes().into_iter()) From 985fb9f116061adc873dec413c939e4c854bfd0d Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:13:24 -0400 Subject: [PATCH 07/16] Check with clippy in vscode --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d260a25 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.checkOnSave.command": "clippy" +} From f0d5d6bb7b5a1d95584b79438dc5a96d69d6c28e Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:13:42 -0400 Subject: [PATCH 08/16] Make cargo test work with magnus --- ext/yrb/Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/yrb/Cargo.toml b/ext/yrb/Cargo.toml index 3ac1d84..89053e9 100644 --- a/ext/yrb/Cargo.toml +++ b/ext/yrb/Cargo.toml @@ -9,9 +9,12 @@ repository = "https://github.com/y-crdt/yrb" [dependencies] lib0 = "0.11.2" # must match yrs version magnus = { git = "https://github.com/matsadler/magnus" } # waiting for release with full rb-sys backend - yrs = "0.11.2" +[dev-dependencies] +magnus = { git = "https://github.com/matsadler/magnus", features = ["embed"] } # waiting for release with full rb-sys backend + + [lib] name = "yrb" crate-type = ["cdylib"] From d4973fe0e6cfb2525723dd7173539ccecf3e3c50 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:23:15 -0400 Subject: [PATCH 09/16] Disable cargo test on CI for now --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5a15a2..8fc5485 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,9 +28,6 @@ jobs: - name: Run ruby tests run: bundle exec rake - - name: Run rust tests - run: cargo test - - name: Lint rust run: | cargo clippy || true # consider enabling this once lints are fixed From d66b37833f61a18ad352c281eb237c40dc851638 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:35:31 -0400 Subject: [PATCH 10/16] Test out CI for cross gem action --- .github/workflows/gem.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/gem.yml b/.github/workflows/gem.yml index 76e9a7f..a41894c 100644 --- a/.github/workflows/gem.yml +++ b/.github/workflows/gem.yml @@ -2,6 +2,9 @@ name: Build and release gem on: workflow_dispatch: + push: + branches: + - migrate-to-magnus jobs: native_gem: From f2c19ea7d47bc9b7d810a0fbaab37982b07e363e Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:36:33 -0400 Subject: [PATCH 11/16] Test out CI for cross gem action --- .github/workflows/gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gem.yml b/.github/workflows/gem.yml index a41894c..92f4e65 100644 --- a/.github/workflows/gem.yml +++ b/.github/workflows/gem.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: oxidize-rb/setup-ruby-and-rust@v1 + - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 with: ruby-version: "3.1" bundler-cache: false From bd3877aca697f0aff27ea570c25d67bad91768fd Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:45:15 -0400 Subject: [PATCH 12/16] Rescue RakeCompilerDock::DockerIsNotAvailable --- Rakefile | 6 +++++- y-rb.gemspec | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index f4b4322..660726d 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,6 @@ require "bundler/gem_tasks" require "rubygems/package_task" require "rake/testtask" require "rake/extensiontask" -require "rake_compiler_dock" cross_rubies = %w[3.1.0 3.0.0 2.7.0] cross_platforms = %w[x86_64-linux x86_64-darwin arm64-darwin] @@ -26,7 +25,10 @@ Rake::ExtensionTask.new("yrb", spec) do |ext| end task :setup do + require "rake_compiler_dock" RakeCompilerDock.sh "bundle" +rescue => e + warn e.message end cross_platforms.each do |p| @@ -44,6 +46,7 @@ end begin require "rubocop/rake_task" + RuboCop::RakeTask.new rescue LoadError # Ok @@ -52,6 +55,7 @@ end begin require "yard" + YARD::Rake::YardocTask.new task :docs do diff --git a/y-rb.gemspec b/y-rb.gemspec index 8d41ad7..05f7fd9 100644 --- a/y-rb.gemspec +++ b/y-rb.gemspec @@ -38,8 +38,6 @@ Gem::Specification.new do |spec| spec.add_dependency "rb_sys", "~> 0.9.30" - spec.add_development_dependency "activesupport", "~> 6.1.6.1" - spec.add_development_dependency "minitar", "~> 0.9" spec.add_development_dependency "rake-compiler", "~> 1.2.0" spec.add_development_dependency "rake-compiler-dock", "~> 1.2.2" From 1706f41d92b8bca2a2aa973001b64e6f8c4f8c44 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 22:51:39 -0400 Subject: [PATCH 13/16] Add support for more platforms --- .github/workflows/gem.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/gem.yml b/.github/workflows/gem.yml index 92f4e65..d284c57 100644 --- a/.github/workflows/gem.yml +++ b/.github/workflows/gem.yml @@ -13,21 +13,22 @@ jobs: strategy: matrix: platform: - - x86_64-linux - - x86_64-darwin - - arm64-darwin + - "arm-linux" + - "aarch64-linux" + - "arm64-darwin" + - "x64-mingw-ucrt" + - "x86_64-darwin" + - "x86_64-linux" steps: - uses: actions/checkout@v2 - - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 + - uses: oxidize-rb/actions/setup-ruby-and-rust@main with: ruby-version: "3.1" bundler-cache: false cargo-cache: true - - - name: Vendor cargo deps - run: mkdir .cargo && cargo vendor $PWD/tmp/cargo-vendor >> .cargo/config.toml + cargo-vendor: true - uses: oxidize-rb/cross-gem-action@main with: From bef743331435ce663c003ba5c236aaf7b29169a6 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 23:01:29 -0400 Subject: [PATCH 14/16] Include cross platforms in Rakefile --- Rakefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 660726d..e1847eb 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,15 @@ require "rake/testtask" require "rake/extensiontask" cross_rubies = %w[3.1.0 3.0.0 2.7.0] -cross_platforms = %w[x86_64-linux x86_64-darwin arm64-darwin] +cross_platforms = %w[ + arm-linux + aarch64-linux + arm64-darwin + x64-mingw-ucrt + x64-mingw32 + x86_64-darwin + x86_64-linux +] ENV["RUBY_CC_VERSION"] = cross_rubies.join(":") spec = Bundler.load_gemspec("y-rb.gemspec") @@ -21,6 +29,7 @@ Rake::ExtensionTask.new("yrb", spec) do |ext| ext.config_script = ENV["ALTERNATE_CONFIG_SCRIPT"] || "extconf.rb" ext.cross_compiling do |spec| spec.files.reject! { |file| File.fnmatch?("*.tar.gz", file) } + spec.dependencies.reject! { |dep| dep.name == "rb-sys" } end end From 622aea0334b9921d8f1bc70cc5b10600b812d181 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 23:05:36 -0400 Subject: [PATCH 15/16] Forget mingw native gems for now --- .github/workflows/gem.yml | 1 - Rakefile | 2 -- 2 files changed, 3 deletions(-) diff --git a/.github/workflows/gem.yml b/.github/workflows/gem.yml index d284c57..837bba5 100644 --- a/.github/workflows/gem.yml +++ b/.github/workflows/gem.yml @@ -16,7 +16,6 @@ jobs: - "arm-linux" - "aarch64-linux" - "arm64-darwin" - - "x64-mingw-ucrt" - "x86_64-darwin" - "x86_64-linux" diff --git a/Rakefile b/Rakefile index e1847eb..e692d54 100644 --- a/Rakefile +++ b/Rakefile @@ -10,8 +10,6 @@ cross_platforms = %w[ arm-linux aarch64-linux arm64-darwin - x64-mingw-ucrt - x64-mingw32 x86_64-darwin x86_64-linux ] From 2f2926a4b94ada0242bd3d40948176e4f2fa11bf Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 21 Sep 2022 23:10:49 -0400 Subject: [PATCH 16/16] Disable arm-linux for now --- .github/workflows/gem.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/gem.yml b/.github/workflows/gem.yml index 837bba5..5c3199c 100644 --- a/.github/workflows/gem.yml +++ b/.github/workflows/gem.yml @@ -13,7 +13,6 @@ jobs: strategy: matrix: platform: - - "arm-linux" - "aarch64-linux" - "arm64-darwin" - "x86_64-darwin"