Skip to content

Commit 006c42a

Browse files
authored
build: add shellcheck pre-commit hook (#1130)
Signed-off-by: behnazh-w <[email protected]>
1 parent fab7158 commit 006c42a

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ repos:
7676
hooks:
7777
- id: actionlint
7878

79+
# Check shell scripts with shellcheck.
80+
- repo: https://github.com/shellcheck-py/shellcheck-py
81+
rev: v0.10.0.1
82+
hooks:
83+
- id: shellcheck
84+
exclude: ^tests/
85+
7986
# Run Pylint from the local repo to make sure venv packages
8087
# specified in pyproject.toml are available.
8188
- repo: local

golang/internal/bashparser/resources/valid.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Copyright (c) 2022 - 2022, Oracle and/or its affiliates. All rights reserved.
2-
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
1+
#!/bin/bash
32

4-
#! bin/bash
3+
# Copyright (c) 2022 - 2025, Oracle and/or its affiliates. All rights reserved.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
55

66
set -euo pipefail
77
if [[ "$COMPILE_BUILDER" = true ]]; then

scripts/release_scripts/check_vsa.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
55

66
# This script checks the Verification Summary Attestation generated by Macaron.
@@ -111,15 +111,15 @@ fi
111111

112112
# Check the purl and obtain the matching subject.
113113
if [[ -n "${purl:-}" ]]; then
114-
subject_digest=$(cat "$arg_vsa_path" | jq -r ".payload" | base64 -d | jq -r ".subject[] | select(.uri == \"$purl\") | .digest.sha256")
114+
subject_digest=$(jq -r '.payload' < "$arg_vsa_path" | base64 -d | jq -r ".subject[] | select(.uri == \"$purl\") | .digest.sha256")
115115
else
116116
log_err "Please provide the package URL."
117117
print_help
118118
exit 1
119119
fi
120120

121-
verify_result=$(cat "$arg_vsa_path" | jq -r ".payload" | base64 -d | jq -r ".predicate.verificationResult")
122-
verifier=$(cat "$arg_vsa_path" | jq -r ".payload" | base64 -d | jq -r ".predicate.verifier.id")
121+
verify_result=$(jq -r ".payload" < "$arg_vsa_path" | base64 -d | jq -r ".predicate.verificationResult")
122+
verifier=$(jq -r ".payload" < "$arg_vsa_path" | base64 -d | jq -r ".predicate.verifier.id")
123123

124124

125125
# Check if the subject and artifact digests match.

scripts/release_scripts/run_macaron.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright (c) 2023 - 2024, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2023 - 2025, Oracle and/or its affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
55

66
# This script runs the Macaron Docker image.
@@ -231,6 +231,10 @@ function mount_dir_rw_allow_create() {
231231
# $1: The macaron argument from which the directory is passed into this script.
232232
# $2: The path to the directory on the host.
233233
# $3: The path to the directory inside the container.
234+
#
235+
# Note: This function is currently unused but retained to avoid using `_mount_dir`
236+
# if not necessary, which may have unintended side effects.
237+
# shellcheck disable=SC2317
234238
function mount_dir_rw_forbid_create() {
235239
arg_name=$1
236240
dir_on_host=$2

0 commit comments

Comments
 (0)