Skip to content

Commit 0f62acd

Browse files
sbernauerTechassi
andauthored
fix: Sort operator versions by semver version (#336)
* fix: Sort operator versions by semver version instead of alphabetically * changelog * Improve error message * Fix pre-commit stuff * Add node to pre-commit CI action * Improve error reporting in web/build.rs * Install node thingies in pre-commit action * changelog * changelog * Apply suggestions from code review Co-authored-by: Techassi <[email protected]> * cargo fmt --------- Co-authored-by: Techassi <[email protected]>
1 parent a60b677 commit 0f62acd

File tree

7 files changed

+37
-19
lines changed

7 files changed

+37
-19
lines changed

.github/workflows/pr_pre-commit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
- uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 #v30
2020
with:
2121
github_access_token: ${{ secrets.GITHUB_TOKEN }}
22+
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
23+
with:
24+
node-version: 18
25+
cache: yarn
26+
- run: yarn install --frozen-lockfile
2227
- uses: stackabletech/actions/run-pre-commit@9bd13255f286e4b7a654617268abe1b2f37c3e0a # v0.3.0
2328
with:
2429
rust: ${{ env.RUST_TOOLCHAIN_VERSION }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- id: fmt
2424
args: ["--all", "--", "--check"]
2525
- id: clippy
26-
args: ["--all-targets", "--", "-D", "warnings"]
26+
args: ["--all-targets", "--all-features", "--", "-D", "warnings"]
2727

2828
- repo: https://github.com/adrienverge/yamllint
2929
rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # 1.35.1

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ hooks are:
6565
- [`yamllint`](https://github.com/adrienverge/yamllint): Runs linting on all YAML files
6666
- [`markdownlint`](https://github.com/igorshubovych/markdownlint-cli): Runs linting on all Markdown files
6767
- [`prettier`](https://github.com/pre-commit/mirrors-prettier): Runs prettier on files located in `web`
68-
- `cargo clippy -- -D warnings`: Runs Clippy on all files and errors on warnings
68+
- `cargo clippy --all-targets --all-features -- -D warnings`: Runs Clippy on all files and errors on warnings
6969
- `cargo fmt -- --check`: Checks if Rust code needs formatting
7070
- `cargo xtask gen-comp`: Runs shell completions generation for `stackablectl`
7171
- `cargo xtask gen-man`: Runs man page generation for `stackablectl`
@@ -77,4 +77,3 @@ hooks are:
7777
[pre-commit]: https://pre-commit.com/
7878
[web-readme]: ./web/README.md
7979
[lib-readme]: ./rust/stackable-cockpit/README.md
80-
[xtasks]: ./xtask/src/main.rs

crate-hashes.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/stackablectl/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ All notable changes to this project will be documented in this file.
88

99
- Add shell completions for Nushell and Elvish ([#337]).
1010

11+
### Fixed
12+
13+
- Sort operator versions by semver version instead of alphabetically ([#336]).
14+
15+
[#336]: https://github.com/stackabletech/stackable-cockpit/pull/336
1116
[#337]: https://github.com/stackabletech/stackable-cockpit/pull/337
1217

1318
## [24.11.0] - 2024-11-18

rust/stackablectl/src/cmds/operator.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ pub enum CmdError {
130130
#[snafu(display("invalid repository name"))]
131131
InvalidRepoName { source: InvalidRepoNameError },
132132

133+
#[snafu(display("invalid semantic helm chart version {version:?}"))]
134+
InvalidHelmChartVersion {
135+
source: semver::Error,
136+
version: String,
137+
},
138+
133139
#[snafu(display("unknown repository name '{name}'"))]
134140
UnknownRepoName { name: String },
135141

@@ -524,16 +530,15 @@ where
524530
Some(entries) => {
525531
let mut versions = entries
526532
.iter()
527-
.map(|e| Version::parse(&e.version))
528-
.map_while(|r| match r {
529-
Ok(v) => Some(v),
530-
Err(_) => None,
533+
.map(|entry| {
534+
Version::parse(&entry.version).with_context(|_| InvalidHelmChartVersionSnafu {
535+
version: entry.version.clone(),
536+
})
531537
})
532-
.map(|v| v.to_string())
533-
.collect::<Vec<String>>();
534-
538+
.collect::<Result<Vec<_>, _>>()?;
535539
versions.sort();
536-
Ok(versions)
540+
541+
Ok(versions.iter().map(|version| version.to_string()).collect())
537542
}
538543
None => Ok(vec![]),
539544
}

web/build.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ fn main() {
1616
] {
1717
println!("cargo:rerun-if-changed={tracked_file}");
1818
}
19-
let vite_status = Command::new("yarn")
19+
20+
let mut vite_command = Command::new("yarn");
21+
vite_command
2022
.arg("run")
2123
.arg("build")
2224
.arg("--outDir")
2325
.arg(&vite_out_dir)
2426
.arg("--base")
25-
.arg("/ui/")
26-
.status()
27-
.unwrap();
28-
if !vite_status.success() {
29-
panic!("web-ui build failed: {vite_status}");
30-
}
27+
.arg("/ui/");
28+
29+
let vite_status = vite_command.status();
30+
match vite_status {
31+
Ok(vite_status) if vite_status.success() => {}
32+
_ => panic!("web-ui build failed: command {vite_command:?} resulted in {vite_status:?}"),
33+
};
34+
3135
let mut asset_map = phf_codegen::Map::new();
3236
for asset_file in vite_out_dir.join("assets").read_dir().unwrap() {
3337
let asset_file = asset_file.unwrap();

0 commit comments

Comments
 (0)