Skip to content

feat(stackable-versioned): Add support for modules #891

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 38 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c031faa
chore: Add changelog entry
Techassi Oct 14, 2024
cd1fb24
chore: Update PR link in changelog
Techassi Oct 14, 2024
603545e
chore: Merge branch 'main' into feat/stackable-versioned-mod-support
Techassi Oct 15, 2024
70726a2
chore: Merge branch 'main' into feat/stackable-versioned-mod-support
Techassi Oct 17, 2024
1dd3047
refactor: Modularize token generation
Techassi Oct 18, 2024
8839bc7
refactor: Use fully qualified From path
Techassi Oct 18, 2024
b349321
refactor: Adjust enum generation code
Techassi Oct 18, 2024
31378ff
chore: Merge branch 'main' into feat/stackable-versioned-mod-support
Techassi Oct 18, 2024
df643d9
chore: Merge branch 'main' into feat/stackable-versioned-mod-support
Techassi Nov 8, 2024
a922c60
feat: Add support for modules
Techassi Nov 13, 2024
cd125d2
fix: Correctly emit automatically_derived and deprecated attributes
Techassi Nov 14, 2024
488b409
fix: Skip From impls for enum if options are set
Techassi Nov 14, 2024
35d0142
fix: Correctly emit doc commens
Techassi Nov 14, 2024
0e4a704
fix: Correctly emit merged_crd code
Techassi Nov 14, 2024
be3a7a1
fix: Correctly skip merged_crd generation
Techassi Nov 14, 2024
13b2a5e
chore: Fix clippy errors
Techassi Nov 14, 2024
56d5ce2
test: Add module snapshot tests
Techassi Nov 14, 2024
7e233b1
test: Update basic Kubernetes snapshot test
Techassi Nov 15, 2024
f5762dd
doc: Fix doc comment links
Techassi Nov 15, 2024
ab79ec6
chore: Remove unused strum dependency
Techassi Nov 15, 2024
cb008d3
ci(pre-commit): Update rust version and use stackabletech/actions/run…
Techassi Nov 15, 2024
7cb3053
fix: Correctly report missing Spec suffix
Techassi Nov 15, 2024
7da5697
test: Update compile-fail test cases
Techassi Nov 15, 2024
bbf217c
chore: Update changelog
Techassi Nov 15, 2024
4858855
ci(pre-commit): Add rust-src component
Techassi Nov 15, 2024
854f84a
ci(build): Bump Rust version
Techassi Nov 15, 2024
608c2d6
chore: Apply suggestions
Techassi Nov 22, 2024
626915a
chore(test): Add comment about empty versioned attribute
Techassi Nov 22, 2024
e2eed77
chore: Add missing doc comments for supported K8s arguments
Techassi Nov 22, 2024
4e34662
chore: Replace unwrap with expect
Techassi Nov 22, 2024
9147d0b
chore: Adjust FIXME comment
Techassi Nov 22, 2024
5854505
chore: Add explanation comment
Techassi Nov 22, 2024
e9f72bd
chore: Remove outdated comments
Techassi Nov 22, 2024
f267020
chore: Add doc comment to validate_added_action function
Techassi Nov 22, 2024
14b868f
chore: Replace mustn't with must not in error message
Techassi Nov 22, 2024
ad3f460
chore: Use concrete type instead of generic type in BTreeMapExt impl
Techassi Nov 22, 2024
63ec18c
chore: Add doc comments
Techassi Nov 22, 2024
8591456
chore: Merge branch 'main' into feat/stackable-versioned-mod-support
Techassi Nov 22, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: '0'
CARGO_PROFILE_DEV_DEBUG: '0'
RUST_TOOLCHAIN_VERSION: "1.81.0"
RUST_TOOLCHAIN_VERSION: "1.82.0"
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: "-D warnings"
RUST_LOG: "info"
Expand Down
33 changes: 7 additions & 26 deletions .github/workflows/pr_pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN_VERSION: "1.81.0"
RUST_TOOLCHAIN_VERSION: "1.82.0"
HADOLINT_VERSION: "v1.17.6"

jobs:
Expand All @@ -16,29 +16,10 @@ jobs:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
- uses: stackabletech/actions/run-pre-commit@9bd13255f286e4b7a654617268abe1b2f37c3e0a # v0.3.0
with:
python-version: '3.12'
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
components: rustfmt,clippy
- name: Setup Hadolint
shell: bash
run: |
set -euo pipefail

LOCATION_DIR="$HOME/.local/bin"
LOCATION_BIN="$LOCATION_DIR/hadolint"

SYSTEM=$(uname -s)
ARCH=$(uname -m)

mkdir -p "$LOCATION_DIR"
curl -sL -o "${LOCATION_BIN}" "https://github.com/hadolint/hadolint/releases/download/${{ env.HADOLINT_VERSION }}/hadolint-$SYSTEM-$ARCH"
chmod 700 "${LOCATION_BIN}"

echo "$LOCATION_DIR" >> "$GITHUB_PATH"
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}"
rust: ${{ env.RUST_TOOLCHAIN_VERSION }}
# rust-src is required for trybuild stderr output comparison to work
# for our cases.
# See: https://github.com/dtolnay/trybuild/issues/236#issuecomment-1620950759
rust-components: rustfmt,clippy,rust-src
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/stackable-versioned-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ itertools.workspace = true
k8s-openapi = { workspace = true, optional = true }
kube = { workspace = true, optional = true }
proc-macro2.workspace = true
strum.workspace = true
syn.workspace = true
quote.workspace = true

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#[versioned(
version(name = "v1alpha1"),
version(name = "v1"),
version(name = "v2alpha1")
)]
// ---
pub(crate) mod versioned {
pub struct Foo {
bar: usize,

#[versioned(added(since = "v1"))]
baz: bool,

#[versioned(deprecated(since = "v2alpha1"))]
deprecated_foo: String,
}

// The following attribute is just to ensure no strange behavior occurs.
#[versioned]
pub struct Bar {
baz: String,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#[versioned(
version(name = "v1alpha1"),
version(name = "v1"),
version(name = "v2alpha1"),
preserve_module
)]
// ---
pub(crate) mod versioned {
pub struct Foo {
bar: usize,

#[versioned(added(since = "v1"))]
baz: bool,

#[versioned(deprecated(since = "v2alpha1"))]
deprecated_foo: String,
}

#[versioned]
pub struct Bar {
baz: String,
}
}
22 changes: 22 additions & 0 deletions crates/stackable-versioned-macros/fixtures/inputs/k8s/skip.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#[versioned(
version(name = "v1alpha1"),
version(name = "v1beta1"),
version(name = "v1"),
k8s(
group = "stackable.tech",
singular = "foo",
plural = "foos",
namespaced,
skip(merged_crd)
)
)]
// ---
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
pub struct FooSpec {
#[versioned(
added(since = "v1beta1"),
changed(since = "v1", from_name = "bah", from_type = "u16")
)]
bar: usize,
baz: bool,
}

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

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

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

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

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

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

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

Loading
Loading