diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9bcbf63..f5f26466 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: - uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0 with: key: udeps - - run: cargo install cargo-udeps + - run: cargo install --locked cargo-udeps@0.1.39 - run: cargo udeps --workspace # This job evaluates the github environment to determine why this action is running and selects the appropriate @@ -139,18 +139,19 @@ jobs: with: key: clippy - name: Run clippy action to produce annotations + uses: giraffate/clippy-action@13b9d32482f25d29ead141b79e7e04e7900281e0 # v1.0.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # renovate: tag=v1.0.7 if: env.GITHUB_TOKEN != null with: - args: --all-targets -- -D warnings - token: ${{ secrets.GITHUB_TOKEN }} + clippy_flags: --all-targets -- -D warnings + reporter: 'github-pr-review' + github_token: ${{ secrets.GITHUB_TOKEN }} - name: Run clippy manually without annotations env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: env.GITHUB_TOKEN == null - run: cargo clippy --all-targets -- -D warnings + run: cargo clippy --color never -q --all-targets -- -D warnings run_rustdoc: name: Run RustDoc @@ -200,9 +201,9 @@ jobs: uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: submodules: recursive - - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4 + - uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.6.1 with: - python-version: '3.10' + python-version: '3.11' - name: Install jinja2-cli run: pip install jinja2-cli==0.8.2 - name: Regenerate charts @@ -296,21 +297,17 @@ jobs: uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: submodules: recursive - - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4 - if: ${{ github.event_name == 'pull_request' }} - uses: dtolnay/rust-toolchain@1.68.2 with: components: rustfmt - - name: Install requirements for version tool - if: ${{ github.event_name == 'pull_request' }} - run: pip install -r python/requirements.txt - # This step checks if the current run was triggered by a push to a pr (or a pr being created). # If this is the case it changes the version of this project in all Cargo.toml files to include the suffix # "-pr" so that the published artifacts can be linked to this PR. - name: Update version if PR if: ${{ github.event_name == 'pull_request' }} - run: python/cargo_version.py -m pr${{ github.event.pull_request.number }} + run: | + cargo install cargo-edit --version 0.11.11 + cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} # Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the # default value in the makefile if called from this action, but not otherwise (i.e. when called locally). diff --git a/.github/workflows/daily_security.yml b/.github/workflows/daily_security.yml index 06b5d462..ca67debf 100644 --- a/.github/workflows/daily_security.yml +++ b/.github/workflows/daily_security.yml @@ -15,6 +15,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: actions-rs/audit-check@35b7b53b1e25b55642157ac01b4adceb5b9ebef3 # renovate: tag=v1.2.0 + - uses: rustsec/audit-check@dd51754d4e59da7395a4cd9b593f0ff2d61a9b95 # v1.4.1 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/reviewdog.yaml b/.github/workflows/reviewdog.yaml index fbc81952..1c4bff8d 100644 --- a/.github/workflows/reviewdog.yaml +++ b/.github/workflows/reviewdog.yaml @@ -22,9 +22,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4 + - uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.6.1 with: - python-version: "3.9" + python-version: "3.11" - uses: reviewdog/action-flake8@b6435e67f0cfda225b9e0c9283cfb7ea7c551bdb # tag=v3.6.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 61e9b85b..44b2140f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,4 @@ crate-hashes.json result image.tar -tilt_options.json - -**/bundle/ -**/bundle.Dockerfile \ No newline at end of file +tilt_options.json \ No newline at end of file diff --git a/Makefile b/Makefile index 19d495d1..ec0bbc0a 100644 --- a/Makefile +++ b/Makefile @@ -80,4 +80,4 @@ publish: build docker-publish helm-publish run-dev: kubectl apply -f deploy/stackable-operators-ns.yaml - nix run -f. tilt -- up --port 5436 --namespace stackable-operators + nix run -f. tilt -- up --port 5437 --namespace stackable-operators diff --git a/python/cargo_version.py b/python/cargo_version.py deleted file mode 100755 index 245e5e1c..00000000 --- a/python/cargo_version.py +++ /dev/null @@ -1,197 +0,0 @@ -#!/usr/bin/env python3 -# -# Utility for viewing and managing versions of cargo workspaces and crates. -# For workspaces, it assumes that all crate members use a single shared version. -# -# usage: cargo-version.py [-h] [-p PROJECT] [-r] [-n {major,minor,patch}] [-s SET] [-o] [-m PRERELEASE] -# -import argparse - -import toml -import semver - - -class Crate: - def __init__(self, path, name, version, dependencies): - self.path = path - self.name = name - self.version = version - self.dependencies = dependencies - - def with_dependencies(self, names): - deps = {k: v for k, v in self.dependencies.items() if k in names} - return Crate(self.path, self.name, self.version, deps) - - @classmethod - def finalize(cls, version): - return str(semver.VersionInfo.parse(version).finalize_version()) - - @classmethod - def bump_level(cls, version, level): - ver = semver.VersionInfo.parse(version) - if level == "major": - return str(ver.bump_major()) - if level == "minor": - return str(ver.bump_minor()) - if level == "patch": - return str(ver.bump_patch()) - - return str(ver.bump_prerelease("nightly"))[ - :-2 - ] # remove the .1 suffix that semver always adds to the prererelease. - - @classmethod - def prerelease(cls, version, prerelease): - ver = semver.VersionInfo.parse(version) - return str(semver.VersionInfo(ver.major, ver.minor, ver.patch, prerelease)) - - def finalize_version(self): - return Crate( - self.path, self.name, Crate.finalize(self.version), self.dependencies.copy() - ) - - def bump_version(self, level): - return Crate( - self.path, - self.name, - Crate.bump_level(self.version, level), - self.dependencies.copy(), - ) - - def set_version(self, version): - return Crate(self.path, self.name, version, self.dependencies.copy()) - - def set_prerelease(self, prerelease): - return Crate( - self.path, - self.name, - Crate.prerelease(self.version, prerelease), - self.dependencies.copy(), - ) - - def next_version(self): - return Crate( - self.path, - self.name, - str(semver.VersionInfo.parse(self.version).next_version("patch")), - self.dependencies.copy(), - ) - - def show_version(self): - return self.version - - def save(self, previous): - contents = [] - cargo_file = f"{self.path}/Cargo.toml" - with open(cargo_file, "r", encoding="utf8") as ctl: - for line in ctl.readlines(): - if line.startswith("version"): - line = line.replace(previous.version, self.version) - else: - for dname, dversion in self.dependencies.items(): - if line.startswith(dname): - line = line.replace(previous.dependencies[dname], dversion) - contents.append(line) - with open(cargo_file, "w", encoding="utf8") as ctl: - ctl.write("".join(contents)) - - def __str__(self): - return f"Crate({self.path}, {self.name}, {self.version}, {self.dependencies})" - - -class Workspace: - def __init__(self, crates): - names = {c.name for c in crates} - self.crates = {c.name: c.with_dependencies(names) for c in crates} - - def finalize_version(self): - crates = {c.name: c.finalize_version() for c in self.crates.values()} - return Workspace(Workspace.update_dependencies(crates).values()) - - def bump_version(self, level): - crates = {c.name: c.bump_version(level) for c in self.crates.values()} - return Workspace(Workspace.update_dependencies(crates).values()) - - def set_version(self, version): - crates = {c.name: c.set_version(version) for c in self.crates.values()} - return Workspace(Workspace.update_dependencies(crates).values()) - - def set_prerelease(self, prerelease): - crates = {c.name: c.set_prerelease(prerelease) for c in self.crates.values()} - return Workspace(Workspace.update_dependencies(crates).values()) - - def next_version(self): - crates = {c.name: c.next_version() for c in self.crates.values()} - return Workspace(Workspace.update_dependencies(crates).values()) - - def show_version(self): - for cts in self.crates.values(): - return cts.show_version() - return "0.0.0" - - @classmethod - def update_dependencies(cls, crate_dict): - for crate in crate_dict.values(): - for dep in crate.dependencies.keys(): - crate.dependencies[dep] = crate_dict[dep].version - return crate_dict - - def __str__(self): - return f"Workspace({[str(c) for c in self.crates.values()]})" - - def save(self, previous): - for crn in self.crates.keys(): - self.crates[crn].save(previous.crates[crn]) - - -def load(root): - ctl = toml.load(f"{root}/Cargo.toml") - if "workspace" in ctl: - return Workspace( - [load(f"{root}/{path}") for path in ctl["workspace"]["members"]] - ) - - return Crate( - path=root, - name=ctl["package"]["name"], - version=ctl["package"]["version"], - dependencies={ - dn: ctl["dependencies"][dn]["version"] - for dn in ctl["dependencies"] - if "version" in ctl["dependencies"][dn] - }, - ) - - -def parse_args(): - parser = argparse.ArgumentParser(description="Change versions of cargo projects.") - parser.add_argument("-p", "--project", help="Project folder", default=".") - parser.add_argument("-r", "--release", help="Version", action="store_true") - parser.add_argument( - "-n", "--next", help="Version", choices=["major", "minor", "patch"] - ) - parser.add_argument("-s", "--set", help="Version") - parser.add_argument("-o", "--show", help="Version", action="store_true") - parser.add_argument("-m", "--prerelease", help="Set pre-prelease string.") - return parser.parse_args() - - -if __name__ == "__main__": - args = parse_args() - old = load(args.project.rstrip("/")) - if args.release: - new = old.finalize_version() - new.save(old) - elif args.next: - new = old.bump_version(args.next).bump_version("prerelease") - new.save(old) - elif args.set: - # sanity check - semver.VersionInfo.parse(args.set) - new = old.set_version(args.set) - new.save(old) - elif args.prerelease: - new = old.set_prerelease(args.prerelease) - new.save(old) - elif args.show: - print(old.show_version()) diff --git a/python/requirements.txt b/python/requirements.txt deleted file mode 100644 index 143c5421..00000000 --- a/python/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -semver==2.13.0 -toml==0.10.2