kraken.std.cargo
kraken.std.cargo
Provides tasks for Rust projects that build using Cargo.
CargoAuthProxyTask
Bases: BackgroundTask
This task starts a local proxy server that injects HTTP basic authentication credentials in HTTP(S) requests to a Cargo repository to work around Cargo's current inability to interface with private repositories.
Source code in kraken/std/cargo/tasks/cargo_auth_proxy_task.py
CargoBuildTask
Bases: Task
This task runs cargo build
using the specified parameters. It will respect the authentication
credentials configured in :attr:CargoProjectSettings.auth
.
Source code in kraken/std/cargo/tasks/cargo_build_task.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
CargoClippyTask
Bases: CargoBuildTask
Runs cargo clippy
for linting or applying suggestions.
Source code in kraken/std/cargo/tasks/cargo_clippy_task.py
CargoProject
dataclass
Container for all Cargo related settings that can be automatically managed from a Kraken build.
Source code in kraken/std/cargo/config.py
add_registry
add_registry(
alias: str,
index: str,
read_credentials: tuple[str, str] | None = None,
publish_token: str | None = None,
) -> None
Add a registry to the project.
:param alias: The alias of the registry. This alias is used inCargo.toml
to describe which registry to look
up a create in. It is also used to designate the registry to publish to in cargo publish
.
:param index: The registry index URL.
:param read_credentials: A (username, password)
tuple for reading from the repository (optional).
:param publish_token: A token to publish to the repository (optional).
Source code in kraken/std/cargo/config.py
CargoPublishTask
Bases: CargoBuildTask
Publish a Cargo crate.
Source code in kraken/std/cargo/tasks/cargo_publish_task.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
prepare
prepare() -> TaskStatus | None
Checks if the crate@version already exists in the registry. If so, the task will be skipped
Source code in kraken/std/cargo/tasks/cargo_publish_task.py
CargoRegistry
dataclass
Represents a Cargo registry.
Source code in kraken/std/cargo/config.py
CargoSqlxDatabaseCreateTask
Bases: CargoBaseSqlxTask
Create a database using sqlx-cli.
Source code in kraken/std/cargo/tasks/cargo_sqlx_database_create.py
CargoSqlxDatabaseDropTask
Bases: CargoBaseSqlxTask
Drop a database using sqlx-cli.
Source code in kraken/std/cargo/tasks/cargo_sqlx_database_drop.py
CargoSqlxMigrateTask
Bases: CargoBaseSqlxTask
Apply SQL migrations using sqlx-cli.
Source code in kraken/std/cargo/tasks/cargo_sqlx_migrate.py
CargoSqlxPrepareTask
Bases: CargoBaseSqlxTask
Generate sqlx's query-.json files for offline mode using sqlx-cli. If check=True, verify that the query-.json files are up-to-date with the current database schema and code queries.
Source code in kraken/std/cargo/tasks/cargo_sqlx_prepare.py
CargoSyncConfigTask
Bases: RenderFileTask
This task updates the .cargo/config.toml
file to inject configuration values.
Source code in kraken/std/cargo/tasks/cargo_sync_config_task.py
CargoTestTask
Bases: CargoBuildTask
This task runs cargo test
using the specified parameters. It will respect the authentication
credentials configured in :attr:CargoProjectSettings.auth
.
Source code in kraken/std/cargo/tasks/cargo_test_task.py
cargo_auth_proxy
cargo_auth_proxy(
*, project: Project | None = None
) -> CargoAuthProxyTask
Creates a background task that the :func:cargo_build
and :func:cargo_publish
tasks will depend on to
inject the read credentials for private registries into HTTPS requests made by Cargo. This is only needed when
private registries are used.
Source code in kraken/std/cargo/__init__.py
cargo_build
cargo_build(
mode: Literal["debug", "release"],
incremental: bool | None = None,
env: dict[str, str] | None = None,
workspace: bool = False,
*,
exclude: Collection[str] = (),
group: str | None = "build",
name: str | None = None,
project: Project | None = None,
features: list[str] | None = None,
depends_on: Sequence[Task] = (),
locked: bool | None = None
) -> CargoBuildTask
Creates a task that runs cargo build
.
:param mode: Whether to create a task that runs the debug or release build.
:param incremental: Whether to build incrementally or not (with the --incremental=
option). If not
specified, the option is not specified and the default behaviour is used.
:param env: Override variables for the build environment variables. Values in this dictionary override
variables in :attr:CargoProject.build_env
.
:param exclude: List of workspace crates to exclude from the build.
:param name: The name of the task. If not specified, defaults to :cargoBuild{mode.capitalised()}
.
:param features: List of Cargo features to enable in the build.
Source code in kraken/std/cargo/__init__.py
cargo_check_toolchain_version
cargo_check_toolchain_version(
minimal_version: str, *, project: Project | None = None
) -> CargoCheckToolchainVersionTask
Creates a task that checks that cargo is at least at version minimal_version
Source code in kraken/std/cargo/__init__.py
cargo_deny
cargo_deny(
*,
project: Project | None = None,
checks: Sequence[str] | Supplier[Sequence[str]] = (),
config_file: Path | Supplier[Path] | None = None,
error_message: str | None = None
) -> CargoDenyTask
Adds a task running cargo-deny for cargo projects. This checks different rules on dependencies, such as scanning for vulnerabilities, unwanted licences, or custom bans.
:param checks: The list of cargo-deny checks to run, as defined in https://embarkstudios.github.io/cargo-deny/checks/index.html. If not provided, defaults to all of them. :param config_file: The configuration file as defined in https://embarkstudios.github.io/cargo-deny/checks/cfg.html If not provided defaults to cargo-deny default location. :param error_message: The error message to show if the task fails.
Source code in kraken/std/cargo/__init__.py
cargo_login
cargo_login(
*, project: Project | None = None
) -> CargoLoginTask
Creates a task that will be added to the build and publish support groups to login in the Cargo registries
Source code in kraken/std/cargo/__init__.py
cargo_publish
cargo_publish(
registry: str,
incremental: bool | None = None,
env: dict[str, str] | None = None,
*,
verify: bool = True,
retry_attempts: int = 0,
additional_args: Sequence[str] = (),
name: str = "cargoPublish",
package_name: str | None = None,
project: Project | None = None,
version: str | None = None,
cargo_toml_file: Path = Path("Cargo.toml"),
allow_overwrite: bool = False
) -> CargoPublishTask
Creates a task that publishes the create to the specified registry.
:param registry: The alias of the registry to publish to.
:param incremental: Incremental builds on or off.
:param env: Environment variables (overrides :attr:CargoProject.build_env
).
:param verify: If this is enabled, the cargo publish
task will build the crate after it is packaged.
Disabling this just packages the crate and publishes it. Only if this is enabled will the created
task depend on the auth proxy.
:param retry_attempts: Retry the publish task if it fails, up to a maximum number of attempts. Sometimes
cargo publishes can be flakey depending on the destination. Defaults to 0 retries.
Source code in kraken/std/cargo/__init__.py
cargo_registry
cargo_registry(
alias: str,
index: str,
read_credentials: tuple[str, str] | None = None,
publish_token: str | None = None,
project: Project | None = None,
) -> None
Adds a Cargo registry to the project. The registry must be synced to disk into the .cargo/config.toml
configuration file. You need to make sure to add a sync task using :func:cargo_sync_config
if you manage
your Cargo registries with this function. Can be called multiple times.
:param alias: The registry alias.
:param index: The registry index URL (usually an HTTPS URL that ends in .git
).
:param read_credentials: Username/password to read from the registry (only for private registries).
:param publish_token: The token to use with cargo publish
.
Note
It appears that for Artifactory, the publish_token must be of the form Bearer <TOKEN>
where the token
is a token generated manually via the JFrog UI. It cannot be an API key.
Source code in kraken/std/cargo/__init__.py
cargo_sync_config
cargo_sync_config(
*, replace: bool = False, project: Project | None = None
) -> CargoSyncConfigTask
Creates a task that the :func:cargo_build
and :func:cargo_publish
tasks will depend on to synchronize
the .cargo/config.toml
configuration file, ensuring that the Cargo registries configured with the
:func:cargo_registry
function are present and up to date.
Source code in kraken/std/cargo/__init__.py
cargo_test
cargo_test(
incremental: bool | None = None,
env: dict[str, str] | None = None,
*,
group: str | None = "test",
project: Project | None = None,
features: list[str] | None = None,
depends_on: Sequence[Task] = (),
workspace: bool | None = None
) -> CargoTestTask
Creates a task that runs cargo test
.
:param incremental: Whether to build the tests incrementally or not (with the --incremental=
option). If not
specified, the option is not specified and the default behaviour is used.
:param env: Override variables for the build environment variables. Values in this dictionary override
variables in :attr:CargoProject.build_env
.
:param features: List of Cargo features to enable in the build.
:param workspace: Run tests in all workspace crates (by default only the default members are selected).
Source code in kraken/std/cargo/__init__.py
rustup_target_add
rustup_target_add(
target: str,
*,
group: str | None = None,
project: Project | None = None
) -> RustupTargetAddTask
Creates a task that installs a given target for Cargo