diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8de42a6..bd2bd068 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - name: Test run: | rustup component add clippy - cargo install cargo-machete + cargo install cargo-machete -f cargo machete cargo clippy cargo test diff --git a/.github/workflows/release-crate.yml b/.github/workflows/release-crate.yml new file mode 100644 index 00000000..ba5c2221 --- /dev/null +++ b/.github/workflows/release-crate.yml @@ -0,0 +1,15 @@ +name: "Release Crate" +on: + workflow_dispatch: +jobs: + publish_crate: + name: Publish Crate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/cargo@v1 + if: startsWith(github.ref, 'refs/tags/v') + name: Release Crate + with: + command: publish + args: --manifest-path autocorrect/Cargo.toml --token ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/release-crate-gem.yml b/.github/workflows/release-rubygem.yml similarity index 72% rename from .github/workflows/release-crate-gem.yml rename to .github/workflows/release-rubygem.yml index f25d6ac5..98c5fee0 100644 --- a/.github/workflows/release-crate-gem.yml +++ b/.github/workflows/release-rubygem.yml @@ -1,22 +1,11 @@ -name: "Release Crate & RubyGem" +name: "Release RubyGem" on: workflow_dispatch: + push: + branches: + - support-ruby-4.0 jobs: - publish_crate: - name: Publish Crate - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/cargo@v1 - if: startsWith(github.ref, 'refs/tags/v') - name: Release Crate - with: - command: publish - args: --manifest-path autocorrect/Cargo.toml --token ${{ secrets.CARGO_REGISTRY_TOKEN }} - build: - needs: - - publish_crate name: Build compile gems runs-on: ubuntu-latest strategy: @@ -30,9 +19,9 @@ jobs: - x86_64-linux-musl steps: - uses: actions/checkout@v4 - - uses: oxidize-rb/actions/setup-ruby-and-rust@v1.3.0 + - uses: oxidize-rb/actions/setup-ruby-and-rust@v1.4.4 with: - ruby-version: "3.4" + ruby-version: "4.0" bundler-cache: true cargo-cache: true cargo-vendor: false @@ -41,11 +30,11 @@ jobs: run: | touch Rakefile - - uses: oxidize-rb/actions/cross-gem@v1.3.0 + - uses: oxidize-rb/actions/cross-gem@v1.4.4 with: platform: ${{ matrix.ruby-platform }} working-directory: autocorrect-rb/ - ruby-versions: "3.4, 3.3, 3.2" # optional + ruby-versions: "4.0, 3.4, 3.3" - name: Upload Gem uses: actions/upload-artifact@v4 @@ -55,14 +44,12 @@ jobs: build_source: name: Build source gem - needs: - - publish_crate runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: oxidize-rb/actions/setup-ruby-and-rust@v1.3.0 + - uses: oxidize-rb/actions/setup-ruby-and-rust@v1.4.4 with: - ruby-version: "3.4" + ruby-version: "4.0" bundler-cache: false cargo-cache: true cargo-vendor: true @@ -89,7 +76,7 @@ jobs: steps: - uses: ruby/setup-ruby@v1 with: - ruby-version: "3.4" + ruby-version: "4.0" bundler-cache: true - uses: actions/download-artifact@v4 with: @@ -97,8 +84,9 @@ jobs: - name: Display structure of built gems run: | - mv -f **/autocorrect-*.gem ./ - ls -lha autocorrect-*.gem + mkdir -p dist/ + cp -n cross-gem-*/*.gem dist/ + tree working-directory: pkg/ - name: Publish to RubyGem @@ -110,7 +98,7 @@ jobs: touch $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials printf -- "---\n:rubygems_api_key: ${RUBYGEM_TOKEN}\n" > $HOME/.gem/credentials - for filename in autocorrect-*.gem; do + for filename in dist/autocorrect-*.gem; do echo $filename gem push $filename done diff --git a/Cargo.lock b/Cargo.lock index f90f8602..d8faea9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -493,7 +493,7 @@ dependencies = [ "bitflags 2.9.1", "cexpr", "clang-sys", - "itertools 0.12.1", + "itertools 0.10.5", "lazy_static", "lazycell", "proc-macro2", @@ -1937,15 +1937,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.14.0" @@ -2046,7 +2037,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.53.2", + "windows-targets 0.48.5", ] [[package]] @@ -2121,9 +2112,8 @@ dependencies = [ [[package]] name = "magnus" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d87ae53030f3a22e83879e666cb94e58a7bdf31706878a0ba48752994146dab" +version = "0.9.0" +source = "git+https://github.com/matsadler/magnus.git?rev=c7e33c181c44860a33e7d8cd8f39090145f061d0#c7e33c181c44860a33e7d8cd8f39090145f061d0" dependencies = [ "magnus-macros", "rb-sys", @@ -2133,9 +2123,8 @@ dependencies = [ [[package]] name = "magnus-macros" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3" +version = "0.9.0" +source = "git+https://github.com/matsadler/magnus.git?rev=c7e33c181c44860a33e7d8cd8f39090145f061d0#c7e33c181c44860a33e7d8cd8f39090145f061d0" dependencies = [ "proc-macro2", "quote", @@ -2883,18 +2872,18 @@ dependencies = [ [[package]] name = "rb-sys" -version = "0.9.116" +version = "0.9.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059846f68396df83155779c75336ca24567741cb95256e6308c9fcc370e8dad" +checksum = "c85c4188462601e2aa1469def389c17228566f82ea72f137ed096f21591bc489" dependencies = [ "rb-sys-build", ] [[package]] name = "rb-sys-build" -version = "0.9.116" +version = "0.9.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac217510df41b9ffc041573e68d7a02aaff770c49943c7494441c4b224b0ecd0" +checksum = "568068db4102230882e6d4ae8de6632e224ca75fe5970f6e026a04e91ed635d3" dependencies = [ "bindgen", "lazy_static", @@ -2907,9 +2896,9 @@ dependencies = [ [[package]] name = "rb-sys-env" -version = "0.1.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb" +checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a" [[package]] name = "redox_syscall" diff --git a/Makefile b/Makefile index 71546f87..75954dc9 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ test\:node\:cli: test\:python: cd autocorrect-py && python3 -m pip install . && python3 -m pytest test\:ruby: - cd autocorrect-rb && bundle && rake compile && rake test + cd autocorrect-rb && bundle && bundle exec rake compile && bundle exec rake test test\:java: cd autocorrect-java && make test install: diff --git a/autocorrect-rb/Gemfile.lock b/autocorrect-rb/Gemfile.lock index df1bab23..1a73d29d 100644 --- a/autocorrect-rb/Gemfile.lock +++ b/autocorrect-rb/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - autocorrect-rb (2.13.0) + autocorrect-rb (2.16.3) rb_sys (>= 0.9.105) GEM @@ -31,7 +31,9 @@ GEM concurrent-ruby (~> 1.0) logger (1.6.4) memory_profiler (1.1.0) - minitest (5.25.4) + minitest (6.0.1) + prism (~> 1.5) + prism (1.9.0) rake (13.2.1) rake-compiler (1.2.8) rake @@ -47,6 +49,7 @@ PLATFORMS arm64-darwin-22 arm64-darwin-23 arm64-darwin-24 + arm64-darwin-25 x86_64-linux DEPENDENCIES diff --git a/autocorrect-rb/ext/autocorrect/Cargo.toml b/autocorrect-rb/ext/autocorrect/Cargo.toml index 9657ceee..0f7795a5 100644 --- a/autocorrect-rb/ext/autocorrect/Cargo.toml +++ b/autocorrect-rb/ext/autocorrect/Cargo.toml @@ -10,4 +10,5 @@ name = "autocorrect" [dependencies] autocorrect = "2" -magnus = "0.7" +# Wait 0.9.0 +magnus = { git = "https://github.com/matsadler/magnus.git", rev = "c7e33c181c44860a33e7d8cd8f39090145f061d0" } diff --git a/autocorrect-rb/ext/autocorrect/src/lib.rs b/autocorrect-rb/ext/autocorrect/src/lib.rs index fc78a839..4c1d41c7 100644 --- a/autocorrect-rb/ext/autocorrect/src/lib.rs +++ b/autocorrect-rb/ext/autocorrect/src/lib.rs @@ -1,4 +1,4 @@ -use magnus::{define_class, function, method, Error, IntoValue, Module, Object}; +use magnus::{Error, IntoValue, Module, Object, Ruby, function, method}; #[derive(Debug, Clone)] pub struct LineResult { @@ -137,14 +137,14 @@ pub fn load_config(config_str: String) { } #[magnus::init(name = "autocorrect")] -fn init() -> Result<(), Error> { - let class = define_class("AutoCorrect", magnus::class::object())?; +fn init(ruby: &Ruby) -> Result<(), Error> { + let class = ruby.define_class("AutoCorrect", ruby.class_object())?; class.define_singleton_method("format", function!(format, 1))?; class.define_singleton_method("format_for", function!(format_for, 2))?; class.define_singleton_method("lint_for", function!(lint_for, 2))?; class.define_singleton_method("load_config", function!(load_config, 1))?; - let ignorer_class = class.define_class("Ignorer", magnus::class::object())?; + let ignorer_class = class.define_class("Ignorer", ruby.class_object())?; ignorer_class.define_singleton_method("new", function!(Ignorer::new, 1))?; ignorer_class.define_method("ignored?", method!(Ignorer::is_ignored, 1))?;