Files
IronFox/scripts/ci-compress.sh
Akash Yadav aeb8d3a5f0 feat: lint shell scripts with shellcheck + shfmt in CI and pre-commit
ironfox-oss/IronFox!162
Add a blocking `lint` CI stage (runs first, on a lightweight Alpine
image) plus a core.hooksPath pre-commit hook, with scripts/lint.sh as
the shared runner for CI, the hook, and manual use. Checks are
configured in .shellcheckrc and formatting in .editorconfig.

Reformat all scripts with shfmt (2-space indent, switch-case indent,
space redirects) via .editorconfig, so a bare `shfmt` is consistent
everywhere. bootstrap.sh installs shellcheck + shfmt per-OS and
enables the pre-commit hook.

The hook is a convenience (bypassable with --no-verify); the CI
`lint-scripts` job is the enforcement gate. SC2086/SC2046 are
disabled for now as tracked follow-up.

MR-author: Akash Yadav <itsaky01@gmail.com>
Co-authored-by: Akash Yadav <contact@itsaky.com>
Approved-by: celenity <celenity@celenity.dev>
Merged-by: celenity <celenity@celenity.dev>
2026-07-31 02:33:10 +00:00

65 lines
1.6 KiB
Bash

#!/bin/bash
## This script is expected to be executed in a CI environment, or possibly in our Docker image instance
## DO NOT execute this manually!
set -euo pipefail
# Set-up our environment
if [[ -z "${IRONFOX_CI+x}" ]]; then
export IRONFOX_CI=1
fi
source $(dirname $0)/env.sh
# Include utilities
source "${IRONFOX_UTILS}"
# Set verbosity
if [[ "${IRONFOX_VERBOSE}" == 1 ]]; then
set -x
else
set +x
fi
readonly artifact_name="$1"
readonly artifact_archive="${artifact_name}.tar.xz"
readonly artifact_path="${IRONFOX_ARTIFACTS}/${artifact_archive}"
function ironfox_package_artifacts() {
# For debugging purposes
echo "Listing available artifacts"
"${IRONFOX_FIND}" "${IRONFOX_ARTIFACTS}"
local -r includes=$(echo "${IRONFOX_ARTIFACT_INCLUDES}" | tr ";" "\n")
local paths=()
for include in ${includes}; do
local path="${IRONFOX_ARTIFACTS}/${include}"
if [[ -e "${path}" ]]; then
echo "Including ${path}"
paths+=("${include}")
else
echo_red_text "Warning: ${path} does not exist!"
fi
done
if [[ ${#paths[@]} -eq 0 ]]; then
echo_red_text "No valid artifact paths found. Creating empty artifact."
"${IRONFOX_TOUCH}" "${artifact_path}"
return
fi
"${IRONFOX_MKDIR}" -p "${IRONFOX_ARTIFACTS}"
"${IRONFOX_TAR}" cvJf "${artifact_path}" -C "${IRONFOX_ARTIFACTS}" "${paths[@]}"
}
if [[ -z "${IRONFOX_ARTIFACT_INCLUDES+x}" ]]; then
echo_red_text "IRONFOX_ARTIFACT_INCLUDES has not been specified. Creating empty artifact."
"${IRONFOX_TOUCH}" "${artifact_path}"
else
ironfox_package_artifacts
fi
if [ "${IRONFOX_CI_BUILD_FAILED}" == 1 ]; then
exit 1
fi