Files
IronFox/scripts/ci-build.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

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
if [[ "${CI_COMMIT_REF_NAME}" == "${PRODUCTION_BRANCH}" ]]; then
# Target release
export IRONFOX_RELEASE=1
fi
# Set-up our environment
if [[ -z "${IRONFOX_CI+x}" ]]; then
export IRONFOX_CI=1
fi
if [[ -z "${IRONFOX_SET_ENVS+x}" ]]; then
/bin/bash $(dirname $0)/env.sh
fi
source $(dirname $0)/env.sh
# Include utilities
source "${IRONFOX_UTILS}"
# Set-up target parameters
readonly ci_target=$(echo "${1}" | "${IRONFOX_AWK}" '{print tolower($0)}')
if [[ -z "${2+x}" ]]; then
readonly ci_project='fenix'
else
readonly ci_project=$(echo "${2}" | "${IRONFOX_AWK}" '{print tolower($0)}')
fi
# Function to compress our archives
function compress_archives() {
if [[ "${ci_project}" == 'geckoview' ]]; then
local -r ci_job_artifact="build-geckoview-${ci_target}"
elif [[ "${ci_project}" == 'fenix' ]]; then
local -r ci_job_artifact="build-fenix-${ci_target}"
fi
/bin/bash "${IRONFOX_SCRIPTS}/ci-compress.sh" "${ci_job_artifact}"
}
# By default, we know the build hasn't failed...
IRONFOX_CI_BUILD_FAILED=0
# Build IronFox
readonly IRONFOX_FROM_CI_BUILD=1
export IRONFOX_FROM_CI_BUILD
/bin/bash "${IRONFOX_SCRIPTS}/ci-build-if.sh" "${ci_target}" "${ci_project}" || IRONFOX_CI_BUILD_FAILED=1
readonly IRONFOX_CI_BUILD_FAILED
export IRONFOX_CI_BUILD_FAILED
# Compress our archives
#compress_archives