Skip to content

Commit a287530

Browse files
committed
chore: Generated commit to update templated files since the last template run up to stackabletech/operator-templating@26d779f
Reference-to: stackabletech/operator-templating@26d779f (chore: refactor pre-commit config and build workflow)
1 parent 749b027 commit a287530

8 files changed

Lines changed: 986 additions & 232 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -97,223 +97,12 @@ jobs:
9797
echo "skip_helm=true" >> "$GITHUB_OUTPUT"
9898
fi
9999
100-
run_cargodeny:
101-
name: Run Cargo Deny
102-
runs-on: ubuntu-latest
103-
strategy:
104-
matrix:
105-
checks:
106-
- advisories
107-
- bans licenses sources
108-
109-
# Prevent sudden announcement of a new advisory from failing ci:
110-
continue-on-error: ${{ matrix.checks == 'advisories' }}
111-
112-
steps:
113-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
114-
with:
115-
persist-credentials: false
116-
submodules: recursive
117-
- uses: EmbarkStudios/cargo-deny-action@f2ba7abc2abebaf185c833c3961145a3c275caad # v2.0.13
118-
with:
119-
command: check ${{ matrix.checks }}
120-
121-
run_rustfmt:
122-
name: Run Rustfmt
123-
runs-on: ubuntu-latest
124-
steps:
125-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
126-
with:
127-
persist-credentials: false
128-
submodules: recursive
129-
- uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921
130-
with:
131-
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN_VERSION }}
132-
components: rustfmt
133-
- env:
134-
RUST_TOOLCHAIN_VERSION: ${{ env.RUST_NIGHTLY_TOOLCHAIN_VERSION }}
135-
run: cargo "+$RUST_TOOLCHAIN_VERSION" fmt --all -- --check
136-
137-
run_clippy:
138-
name: Run Clippy
139-
runs-on: ubuntu-latest
140-
steps:
141-
- name: Install host dependencies
142-
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
143-
with:
144-
packages: protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
145-
version: ubuntu-latest
146-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
147-
with:
148-
persist-credentials: false
149-
submodules: recursive
150-
- uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921
151-
with:
152-
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
153-
components: clippy
154-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
155-
with:
156-
key: clippy
157-
cache-all-crates: "true"
158-
# TODO (@Techassi): Remove this step (unmaintained action, kinda useless step anyway)
159-
- name: Run clippy action to produce annotations
160-
uses: giraffate/clippy-action@13b9d32482f25d29ead141b79e7e04e7900281e0 # v1.0.1
161-
env:
162-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163-
if: env.GITHUB_TOKEN != null
164-
with:
165-
clippy_flags: --all-targets -- -D warnings
166-
reporter: 'github-pr-review'
167-
github_token: ${{ secrets.GITHUB_TOKEN }}
168-
# TODO (@Techassi): Remove, done by pre-commit
169-
- name: Run clippy manually without annotations
170-
env:
171-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172-
if: env.GITHUB_TOKEN == null
173-
run: cargo clippy --color never -q --all-targets -- -D warnings
174-
175-
# TODO (@Techassi): Can be done by pre-commit
176-
run_rustdoc:
177-
name: Run RustDoc
178-
runs-on: ubuntu-latest
179-
steps:
180-
- name: Install host dependencies
181-
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
182-
with:
183-
packages: protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
184-
version: ubuntu-latest
185-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
186-
with:
187-
submodules: recursive
188-
- uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921
189-
with:
190-
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
191-
components: rustfmt
192-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
193-
with:
194-
key: doc
195-
cache-all-crates: "true"
196-
- run: cargo doc --document-private-items
197-
198-
# TODO (@Techassi): Remove, done by pre-commit
199-
run_tests:
200-
name: Run Cargo Tests
201-
runs-on: ubuntu-latest
202-
steps:
203-
- name: Install host dependencies
204-
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
205-
with:
206-
packages: protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
207-
version: ubuntu-latest
208-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
209-
with:
210-
persist-credentials: false
211-
submodules: recursive
212-
- uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921
213-
with:
214-
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
215-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
216-
with:
217-
key: test
218-
cache-all-crates: "true"
219-
- run: cargo test
220-
221-
222-
# Similar to check_charts, this tries to render the README, and see if there are unintended changes.
223-
# This will save us from merging changes to the wrong file (instead of the templated source), and from
224-
# forgetting to render out modifications to the README.
225-
check_readme:
226-
name: Check if committed README is the one we would render from the available parts
227-
runs-on: ubuntu-latest
228-
steps:
229-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
230-
with:
231-
persist-credentials: false
232-
submodules: recursive
233-
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
234-
with:
235-
python-version: ${{ env.PYTHON_VERSION }}
236-
- name: Install jinja2-cli
237-
run: pip install jinja2-cli==0.8.2
238-
- name: Regenerate charts
239-
run: make render-readme
240-
- name: Check if committed README were up to date
241-
run: git diff --exit-code
242-
- name: Git Diff showed uncommitted changes
243-
if: ${{ failure() }}
244-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
245-
with:
246-
script: |
247-
core.setFailed('Committed README are not up to date, please make sure to apply them to the templated partials, and re-commit!')
248-
249-
# This job cleans up the CRDs and Helm charts, followed by rebuilding them
250-
# It then runs a `git diff` and fails the entire workflow, if any difference is encountered.
251-
#
252-
# Since CRD files are generated during the 'cargo build' process we need to run this once after
253-
# removing the CRD files to ensure that the checked in versions match what the code expects.
254-
#
255-
# The reason for this step is, that developers are expected to check in up-to-date versions of charts
256-
# as we'd otherwise have to build these in CI and commit them back to the PR, which
257-
# creates all kinds of problems.
258-
# This failsafe simply aborts anything that has not had charts rebuilt before pushing.
259-
check_charts:
260-
name: Check if committed Helm charts are up to date
261-
runs-on: ubuntu-latest
262-
steps:
263-
- name: Install host dependencies
264-
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
265-
with:
266-
packages: protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
267-
version: ubuntu-latest
268-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
269-
with:
270-
persist-credentials: false
271-
submodules: recursive
272-
- name: Set up Helm
273-
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
274-
with:
275-
version: v3.16.1
276-
- name: Set up cargo
277-
uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921
278-
with:
279-
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
280-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
281-
with:
282-
key: charts
283-
cache-all-crates: "true"
284-
- name: Regenerate charts
285-
run: make regenerate-charts
286-
- name: Check if committed charts were up to date
287-
run: git diff --exit-code
288-
- name: Git Diff showed uncommitted changes
289-
if: ${{ failure() }}
290-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
291-
with:
292-
script: |
293-
core.setFailed('Committed charts were not up to date, please regenerate and re-commit!')
294-
295-
tests_passed:
296-
name: All tests passed
297-
needs:
298-
- run_udeps
299-
- run_cargodeny
300-
- run_clippy
301-
- run_rustfmt
302-
- run_rustdoc
303-
- run_tests
304-
- check_charts
305-
- check_readme
306-
runs-on: ubuntu-latest
307-
steps:
308-
- name: log
309-
run: echo All tests have passed!
310-
311100
# TODO (@Techassi): Most of these publishing and signing tasks can be done by our own actions.
312101
# Make use of them just like we do in docker-images.
313102
package_and_publish:
314103
name: Package Charts, Build Docker Image and publish them - ${{ matrix.runner }}
315104
needs:
316-
- tests_passed
105+
- run_udeps
317106
- check_helm_publish
318107
strategy:
319108
matrix:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ result
1313
image.tar
1414

1515
tilt_options.json
16-
local_values.yaml
1716

1817
.direnv/
1918
.direnvrc

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ repos:
1414
args: ["--allow-missing-credentials"]
1515
- id: detect-private-key
1616

17+
- repo: https://github.com/EmbarkStudios/cargo-deny
18+
# Failing to compile cargo-deny with version >0.18.3, needs rust 1.88.0
19+
rev: baa02b0a0c54e0578aae6bb7c7181ad00dc290af # 0.18.3
20+
hooks:
21+
- id: cargo-deny
22+
args: ["--all-features", "check", "advisories", "bans", "licenses", "sources"]
23+
1724
- repo: https://github.com/adrienverge/yamllint
1825
rev: 79a6b2b1392eaf49cdd32ac4f14be1a809bbd8f7 # 1.37.1
1926
hooks:
@@ -72,6 +79,22 @@ repos:
7279
pass_filenames: false
7380
files: Cargo\.lock
7481

82+
- id: check-readme
83+
name: check-readme
84+
language: system
85+
entry: make render-readme
86+
stages: [pre-commit, pre-merge-commit]
87+
pass_filenames: false
88+
files: .readme
89+
90+
- id: cargo-doc
91+
name: cargo-doc
92+
language: system
93+
entry: cargo doc --document-private-items
94+
stages: [pre-commit, pre-merge-commit]
95+
pass_filenames: false
96+
files: \.rs$|Cargo\.(toml|lock)
97+
7598
- id: cargo-test
7699
name: cargo-test
77100
language: system

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ compile-chart: version crds config
105105

106106
chart-clean:
107107
rm -rf "deploy/helm/${OPERATOR_NAME}/configs"
108+
rm -rf "deploy/helm/${OPERATOR_NAME}/crds"
108109

109110
version:
110111
cat "deploy/helm/${OPERATOR_NAME}/Chart.yaml" | yq ".version = \"${VERSION}\" | .appVersion = \"${VERSION}\"" > "deploy/helm/${OPERATOR_NAME}/Chart.yaml.new"
@@ -116,11 +117,9 @@ config:
116117
cp -r deploy/config-spec/* "deploy/helm/${OPERATOR_NAME}/configs";\
117118
fi
118119

119-
# We generate a crds.yaml, so that the effect of code changes are visible.
120-
# The operator will take care of the CRD rollout itself.
121120
crds:
122-
mkdir -p extra
123-
cargo run --bin stackable-"${OPERATOR_NAME}" -- crd > extra/crds.yaml
121+
mkdir -p deploy/helm/"${OPERATOR_NAME}"/crds
122+
cargo run --bin stackable-"${OPERATOR_NAME}" -- crd | yq eval '.metadata.annotations["helm.sh/resource-policy"]="keep"' - > "deploy/helm/${OPERATOR_NAME}/crds/crds.yaml"
124123

125124
chart-lint: compile-chart
126125
docker run -it -v $(shell pwd):/build/helm-charts -w /build/helm-charts quay.io/helmpack/chart-testing:v3.5.0 ct lint --config deploy/helm/ct.yaml

Tiltfile

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ custom_build(
1717
outputs_image_ref_to='result/ref',
1818
)
1919

20+
# Load the latest CRDs from Nix
21+
watch_file('result')
22+
if os.path.exists('result'):
23+
k8s_yaml('result/crds.yaml')
24+
2025
# We need to set the correct image annotation on the operator Deployment to use e.g.
2126
# oci.stackable.tech/sandbox/opa-operator:7y19m3d8clwxlv34v5q2x4p7v536s00g instead of
2227
# oci.stackable.tech/sandbox/opa-operator:0.0.0-dev (which does not exist)
@@ -30,12 +35,18 @@ helm_values = settings.get('helm_values', None)
3035

3136
helm_override_image_repository = 'image.repository=' + registry + '/' + operator_name
3237

33-
k8s_yaml(helm(
34-
'deploy/helm/' + operator_name,
35-
name=operator_name,
36-
namespace="stackable-operators",
37-
set=[
38-
helm_override_image_repository,
39-
],
40-
values=helm_values,
41-
))
38+
# Exclude stale CRDs from Helm chart, and apply the rest
39+
helm_crds, helm_non_crds = filter_yaml(
40+
helm(
41+
'deploy/helm/' + operator_name,
42+
name=operator_name,
43+
namespace="stackable-operators",
44+
set=[
45+
helm_override_image_repository,
46+
],
47+
values=helm_values,
48+
),
49+
api_version = "^apiextensions\\.k8s\\.io/.*$",
50+
kind = "^CustomResourceDefinition$",
51+
)
52+
k8s_yaml(helm_non_crds)

0 commit comments

Comments
 (0)