Skip to content

Commit

Permalink
Merge pull request #3589 from cpanato/GH-3166
Browse files Browse the repository at this point in the history
add job to test packages with rpmlint
  • Loading branch information
k8s-ci-robot authored Jun 27, 2024
2 parents d694c2e + a468e88 commit 7a79089
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ NOCOLOR:=\\033[0m

##@ Verify

.PHONY: verify verify-boilerplate verify-build verify-dependencies verify-go-mod
.PHONY: verify verify-boilerplate verify-build verify-dependencies verify-go-mod verify-package-specs

verify: release-tools verify-boilerplate verify-build verify-dependencies verify-go-mod ## Runs verification scripts to ensure correct execution
verify: release-tools verify-boilerplate verify-build verify-dependencies verify-go-mod verify-package-specs ## Runs verification scripts to ensure correct execution

verify-boilerplate: ## Runs the file header check
./hack/verify-boilerplate.sh
Expand All @@ -39,6 +39,9 @@ verify-dependencies: ## Runs zeitgeist to verify dependency versions
verify-go-mod: ## Runs the go module linter
./hack/verify-go-mod.sh

verify-package-specs: ## Runs the rpmlint on package specs
./hack/verify-package-specs.sh

##@ Tests

.PHONY: test
Expand Down
4 changes: 2 additions & 2 deletions compile-release-tools
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
set -u
set -o errexit
set -o nounset
set -o pipefail

RELEASE_TOOLS=(
Expand Down
19 changes: 18 additions & 1 deletion hack/get-krel
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

curl_retry() {
curl -sSfL --retry 5 --retry-delay 3 "$@"
Expand Down
4 changes: 3 additions & 1 deletion hack/test-go-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail
set -o errexit
set -o nounset
set -o pipefail

# Default timeout is 1800s
TEST_TIMEOUT=1800
Expand Down
4 changes: 3 additions & 1 deletion hack/test-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail
set -o errexit
set -o nounset
set -o pipefail

# Default timeout is 1800s
TEST_TIMEOUT=1800
Expand Down
5 changes: 3 additions & 2 deletions hack/test-sh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
set -u
set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT=$(git rev-parse --show-toplevel)
cd "${REPO_ROOT}"
find . -type f -name '*_test.sh' -print0 | xargs -0 -n1 /usr/bin/env bash
70 changes: 70 additions & 0 deletions hack/verify-package-specs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash

# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT=$(git rev-parse --show-toplevel)
DIR="$( cd "${REPO_ROOT}" && pwd )"
WORK_DIR=$(mktemp -d -p "${DIR}")

if [[ -z "${WORK_DIR}" || ! -d "${WORK_DIR}" ]]; then
echo "Could not create temp dir"
exit 1
fi

echo "Setting up environment..."
if [[ -z "${RELEASE_TOOL_BIN:-}" ]]; then
if [[ -n "${GOBIN:-}" ]]; then
export RELEASE_TOOL_BIN="${GOBIN}"
else
GOPATH=$(go env GOPATH)
export RELEASE_TOOL_BIN="${GOPATH}/bin"
fi
fi
export PATH="${PATH}:${RELEASE_TOOL_BIN}"

function cleanup {
rm -rf "${WORK_DIR}"
echo "Deleted temp working directory ${WORK_DIR}"
}

trap cleanup EXIT

cd "${WORK_DIR}"

dir_path="${REPO_ROOT}/cmd/krel/templates/latest"
if [[ -d ${dir_path} ]]; then
package_names=$(find "${dir_path}" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)

echo "Directory names in ${dir_path}:"
echo "${package_names}"

for package_name in ${package_names}; do
echo "Processing Package: ${package_name}"
krel obs specs --spec-only --package="${package_name}" --template-dir="${dir_path}"

rpmlintrcArgs=''
if [[ -f "${package_name}.rpmlintrc" ]]; then
rpmlintrcArgs="-r=${package_name}.rpmlintrc"
fi
rpmlint "${package_name}".spec "${rpmlintrcArgs}" -v
done
else
echo "Directory ${dir_path} does not exist."
exit 1
fi

0 comments on commit 7a79089

Please sign in to comment.