Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fllesser
Copy link
Contributor

@fllesser fllesser commented Oct 22, 2025

Description

Support Lua hooks #41 , but not yet manage the Lua toolchain(lua,luarocks), consistent with pre-commit

Note

Run cargo test with the PowerShell (pwsh) shell on Windows to prevent symbolic link conflicts related to Lua dependencies. Failed Tests

  - uses: ilammy/msvc-dev-cmd@v1 # windows only
  - name: "Install Lua"
    uses: luarocks/gh-actions-lua@v11 # windows only
    with:
      luaVersion: ${{ env.LUA_VERSION }}

  - name: "Install LuaRocks"
    uses: luarocks/gh-actions-luarocks@v6 # windows only
    with:
      luaRocksVersion: ${{ env.LUAROCKS_VERSION }}

  - name: "Cargo test"
    run: |
      cargo llvm-cov nextest `
        --no-report `
        --workspace `
        --status-level skip `
        --failure-output immediate `
        --no-fail-fast `
        -j 8 `
        --final-status-level slow

      cargo llvm-cov report --lcov --output-path lcov.info
    shell: pwsh

Performance

This is the .pre-commit-config.yaml used for testing

repos:
  - repo: local
    hooks:
      - id: hello-world
        name: hello-world
        entry: lua -e "print('Hello, World!')"
        language: lua
        pass_filenames: false

  - repo: local
    hooks:
      - id: test-lua-deps
        name: test-lua-deps
        entry: lua -e "require('lfs');require('luacheck');print('Hello, World!')"
        language: lua
        pass_filenames: false
        additional_dependencies:
          - "luacheck"

  - repo: https://github.com/fllesser/lua-hooks
    rev: v1.0.0
    hooks:
      - id: lua-hooks

Test results

❯ pre-commit run -v
hello-world..............................................................Passed
- hook id: hello-world
- duration: 0.09s

Hello, World!

test-lua-deps............................................................Passed
- hook id: test-lua-deps
- duration: 0.09s

Hello, World!

lua-hooks................................................................Passed
- hook id: lua-hooks
- duration: 0.1s

this is a lua remote hook

❯ prek run -v
hello-world..............................................................Passed
- hook id: hello-world
- duration: 0.00s
  Hello, World!
test-lua-deps............................................................Passed
- hook id: test-lua-deps
- duration: 0.01s
  Hello, World!
lua-hooks................................................................Passed
- hook id: lua-hooks
- duration: 0.00s
  this is a lua remote hook

Based on the test results, prek demonstrates significantly faster performance than pre-commit when executing Lua scripts. However, this performance gap narrows considerably for remote repository hooks, as they compile Lua scripts into executable binaries during the download phase.

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 93.12169% with 13 lines in your changes missing coverage. Please review.
βœ… Project coverage is 90.16%. Comparing base (697b101) to head (82043d4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/languages/lua.rs 94.04% 10 Missing ⚠️
src/hook.rs 83.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #954      +/-   ##
==========================================
+ Coverage   90.06%   90.16%   +0.09%     
==========================================
  Files          65       66       +1     
  Lines       12077    12250     +173     
==========================================
+ Hits        10877    11045     +168     
- Misses       1200     1205       +5     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Oct 22, 2025

πŸ“¦ Cargo Bloat Comparison

Binary size change: +0.00% (16.1 MiB β†’ 16.1 MiB)

Expand for cargo-bloat output

PR Branch Results

 File  .text     Size          Crate Name
 0.6%   1.3% 101.1KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.5%   1.2%  88.0KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}
 0.5%   1.1%  85.8KiB           prek prek::builtin::pre_commit_hooks::Implemented::run::{{closure}}
 0.4%   0.9%  70.0KiB           prek prek::run::{{closure}}
 0.4%   0.9%  63.8KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.6%  42.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  40.9KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.5%  40.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  38.5KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.4%  32.9KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  32.8KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  32.7KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  31.8KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  31.7KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.3%  26.2KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.2%   0.3%  25.8KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.2%   0.3%  25.2KiB        globset globset::GlobSetBuilder::build
 0.2%   0.3%  24.9KiB           prek prek::main
 0.1%   0.3%  24.6KiB           prek prek::languages::golang::installer::GoInstaller::install::{{closure}}
 0.1%   0.3%  23.7KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
39.7%  87.3%   6.4MiB                And 10135 smaller methods. Use -n N to show more.
45.5% 100.0%   7.3MiB                .text section size, the file size is 16.1MiB

Base Branch Results

 File  .text     Size          Crate Name
 0.6%   1.4% 101.1KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.5%   1.1%  85.8KiB           prek prek::builtin::pre_commit_hooks::Implemented::run::{{closure}}
 0.5%   1.0%  76.8KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}
 0.4%   0.9%  70.0KiB           prek prek::run::{{closure}}
 0.4%   0.9%  63.8KiB           prek prek::archive::unpack::{{closure}}
 0.2%   0.5%  40.9KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.5%  40.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  38.5KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.5%  35.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4%  32.9KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  32.8KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  32.7KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  31.8KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  31.7KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.4%  26.2KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.2%   0.3%  25.8KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.2%   0.3%  25.2KiB        globset globset::GlobSetBuilder::build
 0.2%   0.3%  24.9KiB           prek prek::main
 0.1%   0.3%  24.6KiB           prek prek::languages::golang::installer::GoInstaller::install::{{closure}}
 0.1%   0.3%  23.7KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
39.7%  87.4%   6.4MiB                And 10107 smaller methods. Use -n N to show more.
45.4% 100.0%   7.3MiB                .text section size, the file size is 16.1MiB

@j178
Copy link
Owner

j178 commented Oct 22, 2025

One quick question, what is sum lua mutual code contact collision? πŸ€”

@fllesser
Copy link
Contributor Author

One quick question, what is sum lua mutual code contact collision? πŸ€”

Sorry, this is a translation error, I have corrected it

@fllesser fllesser changed the title Support lua hooks Support lua hooks Oct 22, 2025
Refactor Lua integration: streamline async functions and improve rockspec file handling

Add Lua and LuaRocks installation steps to CI workflow

Add MSVC development command to CI workflow

Update CI workflow to specify Windows-only dependencies for MSVC and Lua installations

Update CI workflow to use official Lua and LuaRocks GitHub actions

Update CI workflow to specify Windows-only dependencies for Lua and LuaRocks installations

Update CI workflow to use PowerShell for Cargo test execution and improve command formatting

Add platform-specific command snapshots for Lua tests

Enhance the Lua test environment by adding separate command snapshots for Windows and non-Windows platforms. This ensures accurate output handling based on the operating system, improving test reliability and clarity.

Update CI workflow to use specific versions of Lua and LuaRocks actions

Refactor Lua dependency installation and update test cases

Refactor Lua command execution to streamline environment path handling

Fix dependencies installing

Fix remote repo hook
@fllesser
Copy link
Contributor Author

fllesser commented Oct 23, 2025

@j178 This PR is ready for review, however, it cannot achieve 100% code coverage due to the lack of implementation for Lua and LuaRocks management.

@j178 j178 changed the title Support lua hooks Support language: lua hooks Oct 24, 2025
@j178 j178 added the enhancement New feature or request label Oct 24, 2025
@j178 j178 merged commit ed3f357 into j178:master Oct 24, 2025
21 checks passed
@j178
Copy link
Owner

j178 commented Oct 24, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants