WIP: Rust implementation of packs for ruby

Related tags

Command-line packs
Overview

packs

CI Audit

WIP: Rust implementation of packs and packwerk for ruby

Features

  • It's entirely built in Rust, so it's really fast, and doesn't require any external dependencies since the binary contains everything that needed to run packs!
  • Currently all packs can do is generate a cache to be used by the ruby implementation.

Usage

One simple way to try out packs to generate your cache would be to create a bash function which wraps the call to bin/packwerk, like so:

# In your ~/.bash_profile or analogous file
packwerk() {
    if [ "$1" = "check" ] || [ "$1" = "update" ]; then
        echo "Calling packs generate_cache with args: ${@:2}"
        packs generate_cache "${@:2}"
    fi

    echo "Now calling packwerk with args: $@"
    bin/packwerk "$@"
}

You can also modify the bin/packwerk executable to call packs conditionally, e.g.

# In bin/packwerk
packs_executable = `which packs`.chomp
if !packs_executable.empty?
  if ARGV.first == 'check' || ARGV.first == 'update'
    puts "Calling packs generate_cache with args: #{ARGV[1..-1]}"
    system('packs', 'generate_cache', *ARGV[1..-1])
  end
end

Verification

As packs is still a work-in-progress, it's possible it will not produce the same results as the ruby implementation (see below). If not, please file an issue!

To verify:

  1. Run rm -rf tmp/cache/packwerk to delete the existing cache.
  2. Run packs generate_cache (see directions below to get binary)
  3. Run bin/packwerk update to see how violations change using packs.

Downloading the Binary

Deployment ergonomics are still a WIP.

If you want to try it out:

  • Go to https://github.com/alexevanczuk/packs/releases
  • Download the packs asset and run chmod +x path/to/packs
  • Open the containing directory, right click on the binary, click open, and then accept the warning message that says its from an unknown developer (it's me!)
  • Execute path/to/packs to see the CLI help message.

You can add path/to/packs to your PATH so it's available in every terminal session.

Deployment Improvements

In the future, I hope to:

  • Somehow sign the binary so it does not get a warning message
  • Make it executable before download
  • Add directions to download via some other tool, or ship as a native ruby gem extension.

New to Rust?

Me too! This is my first Rust project, so I'd love to have feedback, advice, and contributions! If you're new to Rust, don't be intimidated! https://www.rust-lang.org has tons of great learning resources.

Comments
  • Parse packwerk.yml to allow generate_cache to read the correct set of files

    Parse packwerk.yml to allow generate_cache to read the correct set of files

    • write trivially passing test
    • remove panic
    • write failing test
    • make tests pass
    • make test pass
    • attempt with glob walker builder
    • add globset
    • make tests pass
    • add to test
    • light cleanup
    • add doc
    • make package paths tests pass
    • make cache enabled test pass
    • panic if cache is disabled but generate-cache is called
    • make cli commands snake_case
    • docs for greet
    • document list packs command -n
    • document remaining methods
    • use sets for package paths and included files
    • take the intersection of input files
    • make tests pass
    • move around readme contents
    • add failing text and fix it
    • fix faiing test
    • add test for dir case
    • add more info on how to use
    opened by alexevanczuk 0
  • Organize code

    Organize code

    • move code into packwerk.rs
    • improve organization of pack tests
    • remove boiler plate test_ prefix of test functions
    • Rename Reference to UnresolvedReference
    • move cache implementation into cache module out of CLI
    • use simpler match arms
    • fill out todo
    opened by alexevanczuk 0
  • Cover some reference extraction cases

    Cover some reference extraction cases

    • write failing test
    • make test pass
    • write fialing test
    • fix other test
    • write failing test
    • address clippy warning
    • try to make test pass
    • clippy
    • make another tests pass
    • Fix typo
    • write failing test
    • make tests pass
    • fix some edge cases in association detection
    opened by alexevanczuk 0
  • First pass at

    First pass at "pks generate_cache"

    • get md5 of filename to pass
    • add test for cache file
    • set cody directive
    • write failing file cache test
    • fix compiler errors
    • move test to be a unti test, get it to almost pass
    • start working on use serde...
    • set max width to 80 for my small personal laptop
    • start updating test...
    • delete dead code
    • implement proper shape serialization
    • getting closer
    • add to gitignore
    • delete tmp
    • getting closer
    • getting a lot closer...!
    • get tests to pass
    opened by alexevanczuk 0
  • generate cache scaffolding

    generate cache scaffolding

    • update readme
    • update fixture to simple_app
    • write failing test for generate_cache
    • fix bad reference to fixture
    • write comment
    • fix test
    • create instructions
    • Move CLI under packs namespace
    • extract string helpers into function
    opened by alexevanczuk 0
  • Fill out some basic things with sample/example code

    Fill out some basic things with sample/example code

    • cargo new packs
    • add dependencies based on what is in codeowners-rs
    • add some failing tests (copied from codeowners-rs)
    • ignore existing tests for now, since they are for quick reference anyways
    • write failing test called "simple dependency test"
    • pull in some stuff from codeowners-rs and start changing, trying to get it to compile
    • try to get it to compile
    • cargo publish errors
    • add license
    • add dev.md
    • rename crate
    opened by alexevanczuk 0
  • Performance Improvements

    Performance Improvements

    Although packs is intended to be fast, there are ways it can be made a lot faster!

    Improve use of references

    As I'm new to Rust, I don't take advantage of a lot of features in Rust that would improve the performance, such as making sure I minimize the use of deep clones and use references.

    Using cache conditionally to avoid cost of a cache miss

    Once packs check is implemented, it should potentially have different cache behaviors:

    • If a list of files is inputted (e.g. used with commit hook, vscode extension, etc), we should consider not attempting to read the cache, but instead parsing the file and then writing to the cache in a separate thread. The reason being that if someone is running packs check with few files, it's likely those files have changed and we'll get a cache miss, so we might be potentially faster by skipping the cache entirely.
    • If no files are inputted, the cache could be loaded for all files.

    Faster cache load

    We could potentially instead have a single, compressed cache file that can be loaded.

    Using modified time instead of file contents digest

    By using modified time, we can avoid opening the entire file and parsing it and calculating the md5 hash. It's possible this would not be a meaningful performance improvement.

    opened by alexevanczuk 0
  • Design Considerations

    Design Considerations

    • Highly parallelized:
      • In parallel threads, should call two functions to generate constant resolver file map (i.e. definitions) and references
      • If possible, references should be pushed to a stack that can immediately be popped and passed through checkers in parallel
      • Validators should also run in parallel
      • Should iterate over files in parallel to build
    • Idea:
      • Cache could be a trie or even just an indexed database that loads into memory?
      • The current implementation does way too much and can be faster
    opened by alexevanczuk 0
  • Various Enhancement Ideas

    Various Enhancement Ideas

    • packs validate (could be part of pks check)
      • Could output connected components rather than "cycles", or just one example cycle.
      • Validate should spit out the count of connected subgraphs and look at modified time of pack YML files to determine which new dependency is causing cycle
    • packs init (could be always run if necessary)
    • packs create | move
    • CLI Could be interactive like use_packs, e.g. https://github.com/mikaelmello/inquire
    • New features turned on with environment flags, e.g.
      • Unnecessary dependency detection
      • Privacy violation inversion
    • Could potentially support "packs" file notation, e.g. package.yml => pack.yml. packwerk.yml => packs.yml. Disable with packwerk: true
    opened by alexevanczuk 0
  • LSP Ideas

    LSP Ideas

    • Make pack names in package.yml files a link
    • Highlight violations
    • Status bar packs (like Sorbet)
      • Run update
      • Jump to package.yml
      • Jump to pack public API
    • add violations for individual constant reference violations
    • One-click to solve violation should, for example, detect for cycles in advance before recommending adding a dependency. It can say “if you were to add this as a dependency to packs/foo/package.yml, you’ll create cycles in the dependency graph, resulting in X strongly connected components.
    opened by alexevanczuk 0
Releases(c997886)
Owner
Alex Evanczuk
Software Engineer at Gusto
Alex Evanczuk
Rbenv - Manage your app's Ruby environment

Seamlessly manage your app’s Ruby environment with rbenv. Use rbenv to pick a Ruby version for your application and guarantee that your development en

null 14.7k Jan 7, 2023
I2P SAMv3 library in Rust (WIP)

SOLITUDE (WIP) i2p SAMv3 library written in Rust for use in the EVA project. Examples Echo Server Creates a UDP service that returns and prints whatev

Syvita Guild 5 Feb 20, 2022
WIP / POC for using the ESP32C3 and ESP32 wifi drivers in bare-metal Rust

Wifi on ESP32C3 and ESP32 (on bare-metal Rust) About This is experimental and work-in-progress! You are welcome to experiment with it and contribute b

esp-rs 135 Jan 2, 2023
A minecraft clone made in Rust - WIP

unsafe {} A minecraft clone made in Rust. The world is infinite in all three directions. DISCLAIMER: Some textures are stolen from the chisel mod HEAV

Adam Harmansky 5 Jul 18, 2022
A command line interface for trash written in Rust (WIP)

trashctl A command line interface for trash Features Add file to trash List files Permanently delete a file Restore file Empty the trash Documentation

0xMRTT 2 Nov 11, 2022
🦀 A Pure Rust Framework For Building AGI (WIP).

?? AutoGPT ??️ (Recommended) ?? cargo install autogpt --all-features docker pull kevinrsdev/autogpt:0.0.1 autogpt-demo.mp4 AutoGPT is a pure rust fram

Kevin RS 10 May 4, 2024
A WIP property-based testing library in Rust, built with generalized targeted-property testing in mind.

Crabcheck A WIP property-based testing library in Rust, built with generalized targeted-property testing in mind. What is property-based testing? TODO

Alperen Keleş 9 Mar 27, 2024
WIP

What is that? AwesomeWM but oxidized and rewritten as Wayland Compositor Awesome-rs is supposed to replace (currently archived) project called way-coo

Bran 13 Oct 21, 2021
Command-line program to manage PS battle logs. WIP.

psbattletools psbattletools is a command-line tool written in Rust for manipulating Pokémon Showdown battle logs. Installation psbattletools currently

Annika 2 Dec 27, 2022
WIP GUI for NixOS documentation + configuration

nixos-druid Highly experimental GUI for NixOS. For now I expect to frequently make large changes and break stuff whenever I'm working on this. Screens

Sybrand Aarnoutse 6 Aug 23, 2022
[WIP] Store bookmarks to anything

Handyman - store bookmarks to anything Handyman Acronym's Noticeably Dumb, Yet Makes A Name The motivation Internet browsers have bookmarks. File mana

Mateusz Koteja 2 Nov 8, 2022
Automatically commit all edits to a wip branch with GPT-3 commit messages

gwipt Automatic work-in-progress commits with descriptive commit messages generated by GPT-3 Codex Never again worry about the tension between "commit

Ben Weinstein-Raun 113 Jan 25, 2023
WIP. Goals: Treesitter highlighting, snippets, and a smooth intergration with neovim.

typst.nvim WIP. Goals: Tree-sitter highlighting, snippets, and a smooth integration with neovim. For the past week, I've been thinking what I want for

SeniorMars 66 Apr 9, 2023
WIP: A program for switching Dygma layouts based on window name or exe name.

Dygma Layer Switcher Config On the first run of dygma-layer-switcher the config.yml will be generated. --- # Toggle logging. logging: false # Port of

Matthew Wilding 5 Nov 11, 2023
A SIMD implementation of Keccak256 for aarch64, forked from Remco Bloeman's Goldilocks K12 implementation.

keccak256-aarch64 Warning This crate was forked from real cryptographers (Goldilocks by Remco Bloeman), by not a real cryptographer. Do not use this k

null 6 Oct 24, 2023
Readline Implementation in Rust

RustyLine Readline implementation in Rust that is based on Antirez' Linenoise Supported Platforms Unix (tested on FreeBSD, Linux and macOS) Windows cm

Katsu Kawakami 1.1k Dec 29, 2022
Rust implementation of the termbox library

Rustbox Rustbox is a Rust implementation of termbox. Currently, this is just a wrapper of the C library by nsf, though my plan is to convert it to be

Greg Chapple 462 Dec 19, 2022
A very fast implementation of tldr in Rust

A very fast implementation of tldr in Rust: Simplified, example based and community-driven man pages.

Danilo Bargen 2.9k Dec 31, 2022
A compact implementation of connect four written in rust.

connect-four A compact implementation of connect four written in rust. Run the game At the moment there no pre-built binaries - but you can build it l

Maximilian Schulke 12 Jul 31, 2022