*.sh: apply automatically all suggestions from shellcheck

This commit was automatically generated using:
```
$ fd --exclude vendor sh | xargs shellcheck -f diff | git apply
```
This commit is contained in:
Martin Sehnoutka 2020-09-17 15:15:16 +02:00 committed by Ondřej Budai
parent 4c476f32c2
commit b06e6dd916
8 changed files with 146 additions and 146 deletions

View file

@ -23,8 +23,8 @@ source /etc/os-release
# Register RHEL if we are provided with a registration script.
if [[ -n "${RHN_REGISTRATION_SCRIPT:-}" ]] && ! sudo subscription-manager status; then
sudo chmod +x $RHN_REGISTRATION_SCRIPT
sudo $RHN_REGISTRATION_SCRIPT
sudo chmod +x "$RHN_REGISTRATION_SCRIPT"
sudo "$RHN_REGISTRATION_SCRIPT"
fi
# Restart systemd to work around some Fedora issues in cloud images.
@ -80,6 +80,6 @@ sudo systemctl enable --now osbuild-composer-koji.socket
# Verify that the API is running.
sudo composer-cli status show
sudo composer-cli sources list
for SOURCE in `sudo composer-cli sources list`; do
sudo composer-cli sources info $SOURCE
for SOURCE in $(sudo composer-cli sources list); do
sudo composer-cli sources info "$SOURCE"
done

View file

@ -21,8 +21,8 @@ fi
# Register RHEL if we are provided with a registration script.
if [[ -n "${RHN_REGISTRATION_SCRIPT:-}" ]] && ! sudo subscription-manager status; then
greenprint "🪙 Registering RHEL instance"
sudo chmod +x $RHN_REGISTRATION_SCRIPT
sudo $RHN_REGISTRATION_SCRIPT
sudo chmod +x "$RHN_REGISTRATION_SCRIPT"
sudo "$RHN_REGISTRATION_SCRIPT"
fi
# Install requirements for building RPMs in mock.
@ -88,27 +88,27 @@ fi
# Compile RPMs in a mock chroot
greenprint "🎁 Building RPMs with mock"
sudo mock -r $MOCK_CONFIG --resultdir $REPO_DIR --with=tests \
sudo mock -r "$MOCK_CONFIG" --resultdir "$REPO_DIR" --with=tests \
rpmbuild/SRPMS/*.src.rpm osbuild/rpmbuild/SRPMS/*.src.rpm
# Change the ownership of all of our repo files from root to our CI user.
sudo chown -R $USER ${REPO_DIR%%/*}
sudo chown -R "$USER" "${REPO_DIR%%/*}"
# Move the logs out of the way.
greenprint "🧹 Retaining logs from mock build"
mv ${REPO_DIR}/*.log $WORKSPACE
mv "${REPO_DIR}"/*.log "$WORKSPACE"
# Create a repo of the built RPMs.
greenprint "⛓️ Creating dnf repository"
createrepo_c ${REPO_DIR}
createrepo_c "${REPO_DIR}"
# Copy the current build to the latest directory.
mkdir -p $REPO_DIR_LATEST
cp -arv ${REPO_DIR}/ ${REPO_DIR_LATEST}/
mkdir -p "$REPO_DIR_LATEST"
cp -arv "${REPO_DIR}"/ "${REPO_DIR_LATEST}"/
# Remove the previous latest build for this branch.
# Don't fail if the path is missing.
s3cmd --recursive rm s3://${REPO_BUCKET}/${JOB_NAME}/latest/${ID}${VERSION_ID//./}_${ARCH} || true
s3cmd --recursive rm s3://${REPO_BUCKET}/"${JOB_NAME}"/latest/"${ID}""${VERSION_ID//./}"_"${ARCH}" || true
# Upload repository to S3.
greenprint "☁ Uploading RPMs to S3"

View file

@ -20,13 +20,13 @@ test_divider () {
# Run a test case and store the result as passed or failed.
run_test_case () {
TEST_NAME=$(basename $1)
TEST_NAME=$(basename "$1")
echo
test_divider
echo "🏃🏻 Running test: ${TEST_NAME}"
test_divider
if sudo ${1} -test.v | tee ${WORKSPACE}/${TEST_NAME}.log; then
if sudo "${1}" -test.v | tee "${WORKSPACE}"/"${TEST_NAME}".log; then
PASSED_TESTS+=($TEST_NAME)
else
FAILED_TESTS+=($TEST_NAME)
@ -44,7 +44,7 @@ cd $WORKING_DIRECTORY
# Run each test case.
for TEST_CASE in "${TEST_CASES[@]}"; do
run_test_case ${TESTS_PATH}/$TEST_CASE
run_test_case ${TESTS_PATH}/"$TEST_CASE"
done
# Print a report of the test results.

View file

@ -21,7 +21,7 @@ test_divider () {
get_test_cases () {
TEST_CASE_SELECTOR="${ID}_${VERSION_ID%.*}-${ARCH}*.json"
pushd $IMAGE_TEST_CASES_PATH > /dev/null
ls $TEST_CASE_SELECTOR
ls "$TEST_CASE_SELECTOR"
popd > /dev/null
}
@ -29,7 +29,7 @@ get_test_cases () {
run_test_case () {
TEST_RUNNER=$1
TEST_CASE_FILENAME=$2
TEST_NAME=$(basename $TEST_CASE_FILENAME)
TEST_NAME=$(basename "$TEST_CASE_FILENAME")
echo
test_divider
@ -58,11 +58,11 @@ run_test_case () {
AZURE_CREDS=${AZURE_CREDS-/dev/null}
OPENSTACK_CREDS=${OPENSTACK_CREDS-/dev/null}
VCENTER_CREDS=${VCENTER_CREDS-/dev/null}
TEST_CMD="env $(cat $AZURE_CREDS $OPENSTACK_CREDS $VCENTER_CREDS) BRANCH_NAME=${BRANCH_NAME-master} BUILD_ID=$BUILD_ID DISTRO_CODE=$DISTRO_CODE $TEST_RUNNER -test.v ${IMAGE_TEST_CASES_PATH}/${TEST_CASE_FILENAME}"
TEST_CMD="env $(cat "$AZURE_CREDS" "$OPENSTACK_CREDS" "$VCENTER_CREDS") BRANCH_NAME=${BRANCH_NAME-master} BUILD_ID=$BUILD_ID DISTRO_CODE=$DISTRO_CODE $TEST_RUNNER -test.v ${IMAGE_TEST_CASES_PATH}/${TEST_CASE_FILENAME}"
# Run the test and add the test name to the list of passed or failed
# tests depending on the result.
if sudo $TEST_CMD 2>&1 | tee ${WORKSPACE}/${TEST_NAME}.log; then
if sudo "$TEST_CMD" 2>&1 | tee "${WORKSPACE}"/"${TEST_NAME}".log; then
PASSED_TESTS+=("$TEST_NAME")
else
FAILED_TESTS+=("$TEST_NAME")
@ -82,7 +82,7 @@ cd $WORKING_DIRECTORY
# Run each test case.
for TEST_CASE in $(get_test_cases); do
run_test_case $IMAGE_TEST_CASE_RUNNER $TEST_CASE
run_test_case $IMAGE_TEST_CASE_RUNNER "$TEST_CASE"
done
# Print a report of the test results.