Skip to content

Commit e76fec4

Browse files
authored
ci: Introduce pre-commit hooks (#765)
* add pre-commit config * ignore yaml list indentation style * ignore long lines in python (because we want inline comments for version info) * fix lint issues fix python lint * move actionlint.yaml to the right place * add shellcheck pre-commit hook * replace flake8 with ruff * remove flake8 config * ci: add pre-commit checks on pull request * ci: disable pr-commit action until after the workflow is registered * ci: rename reviewdog workflow to be grouped with other PR workflows * fix lint issues
1 parent 86555b3 commit e76fec4

File tree

76 files changed

+236
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+236
-127
lines changed

.github/pull_request_template.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
*Please add a description here.*
44

5-
65
## Definition of Done Checklist
76

87
- Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
98
- Please make sure all these things are done and tick the boxes
10-
9+
1110
```[tasklist]
1211
- [ ] Changes are OpenShift compatible
1312
- [ ] All added packages (via microdnf or otherwise) have a comment on why they are added

.github/workflows/pr_pre-commit.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
pull_request:
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
12+
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
13+
with:
14+
python-version: '3.12'
15+
# NOTE (@NickLarsenNZ): Disabled until the workflow is registered in Github Actions (after merge to main)
16+
# - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
33
*.py[cod]
4-

.markdownlint.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ MD013:
1818
MD024:
1919
# Only check sibling headings
2020
siblings_only: true
21+
22+
# MD033/no-inline-html Inline HTML
23+
MD033:
24+
allowed_elements: [details, summary, img]

.pre-commit-config.yaml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
# See https://pre-commit.com for more information
3+
fail_fast: false
4+
5+
exclude: \.patch$
6+
7+
# See https://pre-commit.com/hooks.html for more hooks
8+
repos:
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v4.2.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: detect-aws-credentials
15+
args: ["--allow-missing-credentials"]
16+
- id: detect-private-key
17+
18+
- repo: https://github.com/adrienverge/yamllint
19+
rev: v1.26.3
20+
hooks:
21+
- id: yamllint
22+
23+
- repo: https://github.com/igorshubovych/markdownlint-cli
24+
rev: v0.31.1
25+
hooks:
26+
- id: markdownlint
27+
28+
- repo: https://github.com/koalaman/shellcheck-precommit
29+
rev: v0.10.0
30+
hooks:
31+
- id: shellcheck
32+
args: ["--severity=info"]
33+
34+
# WARNING (@NickLarsenNZ): Nix users need to install ruff first.
35+
# If you do not, you will need to delete the cached ruff binary shown in the
36+
# error message
37+
- repo: https://github.com/astral-sh/ruff-pre-commit
38+
rev: v0.5.1
39+
hooks:
40+
# Run the linter.
41+
- id: ruff
42+
# Run the formatter.
43+
- id: ruff-format
44+
45+
- repo: local
46+
hooks:
47+
- id: update-readme-badges
48+
name: update-readme-badges
49+
language: system
50+
entry: .scripts/update_readme_badges.sh
51+
stages: [commit, merge-commit, manual]
52+
pass_filenames: false

.scripts/enumerate-product-versions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
]
2323

2424
for product in conf.products:
25-
product_name = product['name']
25+
product_name = product["name"]
2626
if product_name not in PRODUCTS:
2727
continue
2828

29-
for version in product['versions']:
29+
for version in product["versions"]:
3030
print(f"{product_name}#{version['product']}")

.scripts/upload_new_tini_version.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ for arch in "${ARCHITECTURES[@]}"; do
3838
# tini does not currently publish signatures or SBOMs
3939
# renaming binary because original file name has no version
4040
echo "Downloading TINI"
41-
curl --fail -Ls -o "tini-$VERSION-$arch" "https://github.com/krallin/tini/releases/download/v$VERSION/tini-$arch"
41+
curl --fail -Ls -o "tini-$VERSION-$arch" "https://github.com/krallin/tini/releases/download/v$VERSION/tini-$arch"
4242

4343
echo "Uploading to Nexus"
4444
curl --fail -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "tini-$VERSION-$arch" 'https://repo.stackable.tech/repository/packages/tini/'

.scripts/upload_sig_storage_driver.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
#
13
# Don't do this on your machine, as we need to sign the mirrored image, which should be done by a GitHub CI.
24
# Use the action "Mirror container image" in the docker-images repo for that.
35
# You can e.g. pull the image from

.yamllint.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ rules:
1010
check-keys: false
1111
comments:
1212
min-spaces-from-content: 1 # Needed due to https://github.com/adrienverge/yamllint/issues/443
13+
indentation: disable

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository contains Dockerfiles and scripts to build base images for use within Stackable.
44

5-
<!-- start:badges: autogenerated by ./update_readme_badges.sh -->
5+
<!-- start:badges: autogenerated by .scripts/update_readme_badges.sh -->
66
| | | | |
77
| -: | -: | -: | -: |
88
| [![Build Airflow]][dev_airflow.yaml] | [![Build Druid]][dev_druid.yaml] | [![Build Hadoop]][dev_hadoop.yaml] | [![Build HBase]][dev_hbase.yaml] |
@@ -95,7 +95,7 @@ USER 1000:1000
9595
ENTRYPOINT ["/stackable-zookeeper-operator"]
9696
```
9797

98-
<!-- start:links: autogenerated by ./update_readme_badges.sh -->
98+
<!-- start:links: autogenerated by .scripts/update_readme_badges.sh -->
9999
[Build Airflow]: https://github.com/stackabletech/docker-images/actions/workflows/dev_airflow.yaml/badge.svg
100100
[dev_airflow.yaml]: https://github.com/stackabletech/docker-images/actions/workflows/dev_airflow.yaml
101101
[Build Druid]: https://github.com/stackabletech/docker-images/actions/workflows/dev_druid.yaml/badge.svg

airflow/stackable/utils/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ if [[ -n "${_PIP_ADDITIONAL_REQUIREMENTS=}" ]] ; then
311311
>&2 echo " the container starts, so it is onlny useful for testing and trying out"
312312
>&2 echo " of adding dependencies."
313313
>&2 echo
314-
pip install --root-user-action ignore --no-cache-dir ${_PIP_ADDITIONAL_REQUIREMENTS}
314+
pip install --root-user-action ignore --no-cache-dir "${_PIP_ADDITIONAL_REQUIREMENTS}"
315315
fi
316316

317317

airflow/stackable/utils/run-airflow.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This wrapper script allows commands that are embedded in environment variables
33
# to be invoked to carry out actions when the main container is complete.
44
# N.B. for airflow services (scheduler, webserver, worker) this will not be relevant
5-
# as the service has to be terminated, but for pods spawned and terminated by the
5+
# as the service has to be terminated, but for pods spawned and terminated by the
66
# kubernetes executor this allows us to stop other containers, such as vector.
77
eval "$_STACKABLE_PRE_HOOK"
88

druid/licenses/DRUID_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

druid/licenses/PROMETHEUS_EMITTER_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

druid/licenses/STACKABLE_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ e) to display the Original Work publicly.
4040

4141
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
4242

43-
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
43+
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

druid/stackable/bin/run-druid

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ fi
88

99
WHATAMI="$1"
1010
CONFDIR="$(cd "$2" && pwd)"
11+
# shellcheck disable=SC1091 # java-util is not available at this scripts source
1112
JAVA_BIN="$(source ./bin/java-util && get_java_bin_dir)"
1213
if [ -z "$JAVA_BIN" ]; then
1314
>&2 echo "Could not find java - please run ./bin/verify-java to confirm it is installed."
1415
exit 1
1516
fi
16-
exec "$JAVA_BIN"/java `cat "$CONFDIR"/jvm.config | xargs` \
17+
# shellcheck disable=SC2046 # unsure how this `cat | xargs` works, and this script might rely on discouraged behaviour
18+
exec "$JAVA_BIN"/java $(cat "$CONFDIR"/jvm.config | xargs) \
1719
-cp "$CONFDIR":"./lib/*" \
18-
org.apache.druid.cli.Main server "$WHATAMI"
20+
org.apache.druid.cli.Main server "$WHATAMI"

hadoop/licenses/HADOOP_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

hadoop/licenses/JMX_EXPORTER_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

hadoop/licenses/STACKABLE_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ e) to display the Original Work publicly.
4040

4141
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
4242

43-
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
43+
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

hbase/licenses/HBASE_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

hbase/licenses/JMX_EXPORTER_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

hbase/licenses/STACKABLE_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ e) to display the Original Work publicly.
4040

4141
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
4242

43-
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
43+
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

hbase/stackable/jmx/master.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
---
12
rules:
23
- pattern: ".*"

hbase/stackable/jmx/regionserver.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
---
12
rules:
23
- pattern: ".*"

hbase/stackable/jmx/restserver.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
---
12
rules:
23
- pattern: ".*"

hello-world/versions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
versions = [
22
{
33
"product": "0.0.1-SNAPSHOT",
4-
"java-base": "17"
5-
}
4+
"java-base": "17",
5+
},
66
]

hive/licenses/HIVE_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

hive/licenses/JMX_EXPORTER_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

hive/licenses/STACKABLE_LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ e) to display the Original Work publicly.
4040

4141
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
4242

43-
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
43+
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

0 commit comments

Comments
 (0)