Skip to content

Commit

Permalink
Update CI and more chores
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Mar 7, 2024
1 parent 4cb2100 commit e0684e2
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 107 deletions.
28 changes: 0 additions & 28 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md

This file was deleted.

10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/setup-python@v1
# We install instead of just build for insta-cmd TODO(cnpryer)
- name: Install huak
run: cargo install --path crates/huak-cli
run: cargo install --path crates/huak-cli --locked
- name: Test
run: cargo test --workspace --all-features

Expand Down
69 changes: 48 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ glob = "0.3.1"
hex = "0.4.3"
human-panic = "1.1.5"
lazy_static = "1.4.0"
pep440_rs = "0.3.11"
pep508_rs = "0.2.1"
pep440_rs = "0.4.0"
pep508_rs = "0.3.0"
regex = "1.10.2"
sha2 = "0.10.8"
tempfile = "3.7.1"
Expand Down
10 changes: 4 additions & 6 deletions crates/huak-package-manager/src/ops/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use termcolor::Color;
/// already installed to the toolchain, and a version is provided that's different from the
/// installed tool, then replace the installed tool with the desired version.
pub fn add_tool(tool: &LocalTool, channel: Option<&Channel>, config: &Config) -> HuakResult<()> {
// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.
// Resolve a toolchain if a channel is provided. Otherwise resolve the current.
let toolchain = config.workspace().resolve_local_toolchain(channel)?;

add_tool_to_toolchain(tool, &toolchain, config)
Expand Down Expand Up @@ -360,7 +360,7 @@ pub fn remove_tool(tool: &LocalTool, channel: Option<&Channel>, config: &Config)
unimplemented!()
}

// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.
// Resolve a toolchain if a channel is provided. Otherwise resolve the current.
let toolchain = config.workspace().resolve_local_toolchain(channel)?;
let venv = PythonEnvironment::new(toolchain.root().join(".venv"))?;

Expand Down Expand Up @@ -492,7 +492,7 @@ pub fn update_toolchain(
channel: Option<&Channel>,
config: &Config,
) -> HuakResult<()> {
// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.
// Resolve a toolchain if a channel is provided. Otherwise resolve the current.
let toolchain = config.workspace().resolve_local_toolchain(channel)?;

let mut terminal = config.terminal();
Expand Down Expand Up @@ -551,9 +551,7 @@ pub fn use_toolchain(channel: &Channel, config: &Config) -> HuakResult<()> {
}

fn resolve_installed_toolchains(config: &Config) -> Option<Vec<LocalToolchain>> {
let Some(home) = config.home.clone() else {
return None;
};
let home = config.home.clone()?;

let Ok(toolchains) = std::fs::read_dir(home.join("toolchains")) else {
return None;
Expand Down
2 changes: 1 addition & 1 deletion crates/huak-package-manager/src/python_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ mod tests {
fn python_search() {
let dir = tempdir().unwrap();
std::fs::write(dir.path().join("python3.11"), "").unwrap();
let path_vals = vec![dir.path().to_str().unwrap().to_string()];
let path_vals = [dir.path().to_str().unwrap().to_string()];
std::env::set_var("PATH", path_vals.join(":"));
let mut interpreter_paths = python_paths();

Expand Down
5 changes: 0 additions & 5 deletions crates/huak-package-manager/src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ pub enum Verbosity {
Quiet,
}

pub trait ToTerminal {
/// Get a `Terminal`.
fn to_terminal(&self) -> Terminal;
}

/// An abstraction around terminal output that remembers preferences for output
/// verbosity and color (inspired by cargo's `Shell`).
pub struct Terminal {
Expand Down
6 changes: 1 addition & 5 deletions crates/huak-package-manager/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ fn resolve_local_toolchain(
channel: Option<&Channel>,
) -> Option<LocalToolchain> {
let config = &workspace.config;

let Some(home) = config.home.as_ref() else {
return None;
};

let home = config.home.as_ref()?;
let toolchains = home.join("toolchains");
let settings = toolchains.join("settings.toml");

Expand Down
14 changes: 4 additions & 10 deletions crates/huak-pyproject-toml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,10 @@ impl PyProjectToml {

#[must_use]
pub fn project_dependencies(&self) -> Option<Vec<String>> {
let Some(array) = self
let array = self
.project_table()
.and_then(|it| it.get("dependencies"))
.and_then(Item::as_array)
else {
return None;
};
.and_then(Item::as_array)?;

Some(
array
Expand Down Expand Up @@ -245,13 +242,10 @@ impl PyProjectToml {

#[must_use]
pub fn project_optional_dependencies(&self) -> Option<HashMap<String, Vec<String>>> {
let Some(table) = self
let table = self
.project_table()
.and_then(|it| it.get("optional-dependencies"))
.and_then(Item::as_table)
else {
return None;
};
.and_then(Item::as_table)?;

let mut deps = HashMap::new();
let groups = table.iter().map(|(k, _)| k).collect::<Vec<_>>();
Expand Down
10 changes: 6 additions & 4 deletions crates/huak-python-manager/scripts/generate_python_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Release(NamedTuple):
checksum: str
url: str

# TODO(cnpryer): avoid this
def to_rust_string(self) -> str:
(major, minor, patch) = self.version.split(".")
version = f"Version::new({major}, {minor}, {patch})"
Expand All @@ -58,11 +59,12 @@ def get_checksum(url: str) -> str | None:
return res.text.strip()


path = FILE.parent / "generated_python_releases.parquet"
# TODO(cnpryer): structured json
path = FILE.parent / "generated_python_releases.json"
generated = (
pl.DataFrame({"url": [], "string": []}, schema={"url": pl.Utf8, "string": pl.Utf8})
if not path.exists()
else pl.read_parquet(path)
else pl.read_json(path)
)
new_releases = {"url": [], "string": []}

Expand Down Expand Up @@ -177,5 +179,5 @@ def get_checksum(url: str) -> str | None:
path.write_text(module)

new_releases = pl.DataFrame(new_releases, schema={"url": pl.Utf8, "string": pl.Utf8})
path = FILE.parent / "generated_python_releases.parquet"
pl.concat((generated, new_releases)).write_parquet(path)
path = FILE.parent / "generated_python_releases.json"
pl.concat((generated, new_releases)).write_json(path)

Large diffs are not rendered by default.

Binary file not shown.
Loading

0 comments on commit e0684e2

Please sign in to comment.