Skip to content

fix: Sort operator versions by semver version #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/pr_pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
- uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 #v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 18
cache: yarn
- run: yarn install --frozen-lockfile
- uses: stackabletech/actions/run-pre-commit@9bd13255f286e4b7a654617268abe1b2f37c3e0a # v0.3.0
with:
rust: ${{ env.RUST_TOOLCHAIN_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: fmt
args: ["--all", "--", "--check"]
- id: clippy
args: ["--all-targets", "--", "-D", "warnings"]
args: ["--all-targets", "--all-features", "--", "-D", "warnings"]

- repo: https://github.com/adrienverge/yamllint
rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # 1.35.1
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ hooks are:
- [`yamllint`](https://github.com/adrienverge/yamllint): Runs linting on all YAML files
- [`markdownlint`](https://github.com/igorshubovych/markdownlint-cli): Runs linting on all Markdown files
- [`prettier`](https://github.com/pre-commit/mirrors-prettier): Runs prettier on files located in `web`
- `cargo clippy -- -D warnings`: Runs Clippy on all files and errors on warnings
- `cargo clippy --all-targets --all-features -- -D warnings`: Runs Clippy on all files and errors on warnings
- `cargo fmt -- --check`: Checks if Rust code needs formatting
- `cargo xtask gen-comp`: Runs shell completions generation for `stackablectl`
- `cargo xtask gen-man`: Runs man page generation for `stackablectl`
Expand All @@ -77,4 +77,3 @@ hooks are:
[pre-commit]: https://pre-commit.com/
[web-readme]: ./web/README.md
[lib-readme]: ./rust/stackable-cockpit/README.md
[xtasks]: ./xtask/src/main.rs
2 changes: 1 addition & 1 deletion crate-hashes.json

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

6 changes: 6 additions & 0 deletions rust/stackablectl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed

- Sort operator versions by semver version instead of alphabetically ([#336]).

[#336]: https://github.com/stackabletech/stackable-cockpit/pull/336

## [24.11.0] - 2024-11-18

### Changed
Expand Down
21 changes: 13 additions & 8 deletions rust/stackablectl/src/cmds/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ pub enum CmdError {
#[snafu(display("invalid repository name"))]
InvalidRepoName { source: InvalidRepoNameError },

#[snafu(display("invalid helm chart version {version:?} (need to be semver)"))]
InvalidHelmChartVersion {
source: semver::Error,
version: String,
},

#[snafu(display("unknown repository name '{name}'"))]
UnknownRepoName { name: String },

Expand Down Expand Up @@ -524,16 +530,15 @@ where
Some(entries) => {
let mut versions = entries
.iter()
.map(|e| Version::parse(&e.version))
.map_while(|r| match r {
Ok(v) => Some(v),
Err(_) => None,
.map(|entry| {
Version::parse(&entry.version).context(InvalidHelmChartVersionSnafu {
version: entry.version.clone(),
})
})
.map(|v| v.to_string())
.collect::<Vec<String>>();

.collect::<Result<Vec<_>, _>>()?;
versions.sort();
Ok(versions)

Ok(versions.iter().map(|version| version.to_string()).collect())
}
None => Ok(vec![]),
}
Expand Down
17 changes: 10 additions & 7 deletions web/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ fn main() {
] {
println!("cargo:rerun-if-changed={tracked_file}");
}
let vite_status = Command::new("yarn")

let mut vite_command = Command::new("yarn");
vite_command
.arg("run")
.arg("build")
.arg("--outDir")
.arg(&vite_out_dir)
.arg("--base")
.arg("/ui/")
.status()
.unwrap();
if !vite_status.success() {
panic!("web-ui build failed: {vite_status}");
}
.arg("/ui/");
let vite_status = vite_command.status();
match vite_status {
Ok(vite_status) if vite_status.success() => {}
_ => panic!("web-ui build failed: command {vite_command:?} resulted in {vite_status:?}"),
};

let mut asset_map = phf_codegen::Map::new();
for asset_file in vite_out_dir.join("assets").read_dir().unwrap() {
let asset_file = asset_file.unwrap();
Expand Down
Loading