innobead / huber

Huber 📦, Package Install Manager for GitHub repos
Apache License 2.0
185 stars 16 forks source link

Help with fixxing and adding packages #97

Closed sarg3nt closed 1 year ago

sarg3nt commented 1 year ago

Hello, I'm trying to help contribute by fixing a couple broken packages and adding a couple others I find useful but am having issues getting build generate to succeed. First let me say that I'm not a rust developer, I'm a DevOps engineer that is finding huber very useful so I wanted to help support the project where I can. Since I don't have a rust development environment set up, I started by adding a VS Code Dev Container that I based on your Dockerfile.build.

Note: Github does nto

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
    "name": "huber-rust",
    "image": "rust:1.65",
    "runArgs": [
        "--name=huber-rust"
    ],
    "containerEnv": { 
        "GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
        "GITHUB_KEY": "/root/.ssh/id_rsa",
        "BUILD_TARGET": "debug",
        "MAKE_TARGET": "build"
    },
    // Use 'mounts' to make the cargo cache persistent in a Docker Volume.
    "mounts": [
        {
            "source": "${localEnv:HOME}/.ssh",
            "target": "/root/.ssh",
            "type": "bind"
        }
    ],

    // Features to add to the dev container. More info: https://containers.dev/features.
    "features": {
        "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
            "packages": "sudo"
        }
    },

    "postAttachCommand": "make setup-dev",

    // Configure tool-specific properties.
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-vscode.makefile-tools",
                "rust-lang.rust-analyzer"
              ]
        }
    }
}

As you can see from the above I set the following environment vars

"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
"GITHUB_KEY": "/root/.ssh/id_rsa",
"BUILD_TARGET": "debug",
"MAKE_TARGET": "build"

and I have confirmed that GITHUB_TOKEN is populated with a general read only github token that is mapped inside of the dev container.

I modified the /crates/generator/src/pkg/k9s.rs as there were two lines in artifact_templates, the old URL format and the new one and I'm guessing that is making huber not install the bin file. Note: This may be a bug in Huber, that is an array so I'm guessing that the intent was to have two different URLs for transitions? In any case, it's not working and I thought the easiest way to fix it would be to get rid of the old invalid URL.

I then ran make generate from inside of the dev container.
Everything seems to build correctly but I get an error at the end and the generated/packages/k9s.yaml file is not modified. Here's the last few lines of output.

Finished dev [unoptimized + debuginfo] target(s) in 3.81s
rustup component add rustfmt clippy
info: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'clippy' for target 'x86_64-unknown-linux-gnu' is up to date
cargo fmt
cargo build 
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
make[1]: Leaving directory '/workspaces/huber'
/workspaces/huber/hack/generate-packages.md.sh: line 24: $1: unbound variable
make: *** [Makefile:60: generate] Error 123

Looks to me like the generate-packages.md.sh script is not getting anything passed to it.

I ran huber search after setting MANAGED_PKG_ROOT_DIR to what I think is the correct directory but the command gives no output:

root@5dd336c70a0d:/workspaces/huber# MANAGED_PKG_ROOT_DIR=/workspaces/huber/generated target/debug/huber search

# AND

root@5dd336c70a0d:/workspaces/huber/target/debug# MANAGED_PKG_ROOT_DIR=/workspaces/huber/generated ./huber search

Both resulted in no output.

Questions:

  1. What setup am I missing in the dev container?
  2. Any idea why make generate is failing?
  3. If I get this working and do a PR would you like me to include the dev container. I feel like it could improve your community support if standing up the environment was easier for non rust developers.
innobead commented 1 year ago

Your process is correct. The cause of the empty output of the search command is the incompatible serde-yaml version which was incorrectly updated by the dependency bot.

The issue has been fixed in this commit, https://github.com/innobead/huber/commit/10fa35d29fcb17471c81d6619de05a142b31ad11. You can try it later. It should work.

BTW, I also update the K9s incorrect path as you mentioned, and also added ./hack/run-make-by-docker.sh, so you don't need to have rust env but still be able to add/update packages.

@sarg3nt Thanks for your contribution :+1: