diff --git a/.github/workflows/validation.yaml b/.github/workflows/validation.yaml index dd64348fe..b452c0d8a 100644 --- a/.github/workflows/validation.yaml +++ b/.github/workflows/validation.yaml @@ -398,16 +398,65 @@ jobs: run: | sh -x ./test/test_nodebuilder --ref "${GITHUB_SHA}" [ "$?" -gt 0 ] && echo "test_nodebuilder exited with status $?" >&2 && exit 1 - [ -f "/home/bitcoin/.bitcoin/debug.log" ] && cp "/home/bitcoin/.bitcoin/debug.log" . - find / -name debug.log 2> /dev/null | grep bitcoin || true + [ -f '/home/bitcoin/.bitcoin/debug.log' ] && cp '/home/bitcoin/.bitcoin/debug.log' . - name: Save Bitcoin Core log as artifact uses: actions/upload-artifact@v4 with: name: openbsd-source-bitcoin-debug.log path: /home/runner/work/nodebuilder/nodebuilder/debug.log + + run-nodebuilder-qemu: + name: Test ${{ matrix.job-purpose }} on ${{ matrix.arch }} + needs: [changes, shell-lint, yaml-lint] + if: >- + ${{ + github.event.action == 'prerelease' || + github.event.action == 'published' || + needs.changes.outputs.ci == 'true' || + needs.changes.outputs.dependencies == 'true' || + needs.changes.outputs.shell == 'true' + }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + distro: [ubuntu_latest, alpine_latest] + arch: [aarch64, riscv64] + include: + - distro: ubuntu_latest + job-purpose: package + - distro: alpine_latest + job-purpose: source + steps: + - uses: actions/checkout@v4 + - name: Test the console output + uses: uraimo/run-on-arch-action@v2 + timeout-minutes: 330 + with: + arch: ${{ matrix.arch }} + distro: ${{ matrix.distro }} + dockerRunArgs: --volume "${PWD}/artifacts:/artifacts" + githubToken: ${{ github.token }} + setup: | + echo "${TERM:-TERM is not found}" + uname -a + id -u + df -h + tput colors + date -u + mkdir -p "${PWD}/artifacts" + run: | + sh -x ./test/test_nodebuilder --ref "${GITHUB_SHA}" + [ -f /root/.bitcoin/debug.log ] && cp /root/.bitcoin/debug.log /artifacts/ + chmod o+r /artifacts/debug.log + - name: Save Bitcoin Core log as artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.distro }}-${{ matrix.arch }}-bitcoin-debug.log + path: /home/runner/work/nodebuilder/nodebuilder/artifacts/debug.log run-nodebuilder-docker: - name: Docker image for ${{ matrix.container }} + name: Build docker image for ${{ matrix.container }} needs: [changes, dockerfile-lint, shell-lint, yaml-lint] if: >- github.event.action != 'prerelease' && diff --git a/nodebuilder b/nodebuilder index 6fc0889e5..7830f919b 100755 --- a/nodebuilder +++ b/nodebuilder @@ -461,7 +461,7 @@ ensure_curl_dependency() sudo apk --quiet add curl ;; debian | ubuntu) - sudo apt-get install -y curl > /dev/null + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl > /dev/null ;; fedora* | rhel | centos* | rocky | ol) sudo dnf install --allowerasing --assumeyes curl > /dev/null @@ -496,7 +496,7 @@ ensure_curl_dependency() if command -v apk > /dev/null; then sudo apk --quiet add curl elif command -v apt-get > /dev/null; then - sudo apt-get -qq install -y curl > /dev/null + sudo DEBIAN_FRONTEND=noninteractive apt-get -qq install -y curl > /dev/null elif command -v dnf > /dev/null; then sudo dnf install --allowerasing --assumeyes curl > /dev/null elif command -v pacman > /dev/null; then @@ -527,7 +527,11 @@ ensure_sudo_dependency() apk --quiet add sudo ;; debian | ubuntu) - apt-get install -y sudo > /dev/null + readonly STDERR_INSTALL_LOG_FILE="${TEMP_DIRECTORY}/stderr_install.log" + apt-get update > /dev/null + DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes --quiet sudo > /dev/null 2> "${STDERR_INSTALL_LOG_FILE}" + grep -v 'apt-utils' "${STDERR_INSTALL_LOG_FILE}" >&2 || true + rm "${STDERR_INSTALL_LOG_FILE}" ;; fedora* | rhel | centos* | rocky | ol) dnf install --allowerasing --assumeyes sudo > /dev/null @@ -1017,6 +1021,16 @@ install_runtime_dependencies_aptget() [ -z "${dependencies:-}" ] && throw_error 'The list of dependencies is empty.' sudo apt-get -qq update printf '%s\n' "${dependencies}" | xargs sudo DEBIAN_FRONTEND=noninteractive apt-get -qq install --assume-yes --no-install-recommends > /dev/null 2>&1 + case "${TARGET_ARCHITECTURE}" in + powerpc64) + # TODO: make this a CI step not in the script + sudo DEBIAN_FRONTEND=noninteractive apt-get -qq install --assume-yes --no-install-recommends libc6:ppc64el > /dev/null 2>&1 + ;; + riscv64) + sudo DEBIAN_FRONTEND=noninteractive apt-get -qq install --assume-yes --no-install-recommends libatomic1 > /dev/null 2>&1 + ;; + *) ;; + esac } install_runtime_dependencies_darwin() @@ -1225,7 +1239,8 @@ install_system_updates_aptget() { check_dpkg_lock readonly STDERR_INSTALL_LOG_FILE="${TEMP_DIRECTORY}/stderr_install.log" - sudo apt-get -qq update && sudo NEEDRESTART_MODE=a apt-get -qq dist-upgrade --assume-yes > /dev/null 2> "${STDERR_INSTALL_LOG_FILE}" + sudo apt-get -qq update && + sudo NEEDRESTART_MODE=a apt-get -qq dist-upgrade --assume-yes > /dev/null 2> "${STDERR_INSTALL_LOG_FILE}" grep -v 'apt-utils' "${STDERR_INSTALL_LOG_FILE}" >&2 || true rm "${STDERR_INSTALL_LOG_FILE}" } @@ -1554,7 +1569,13 @@ readonly BYTES_TO_KIB=1024 readonly KIB_TO_MIB="${BYTES_TO_KIB}" readonly MIB_TO_GIB="${BYTES_TO_KIB}" -TARGET_ARCHITECTURE="$(uname -m)" +TARGET_ARCHITECTURE=$(uname -m) +case "${TARGET_ARCHITECTURE}" in + ppc64le) + TARGET_ARCHITECTURE='powerpc64' + ;; + *) ;; +esac readonly TARGET_ARCHITECTURE TARGET_KERNEL="$(uname -s)" readonly TARGET_KERNEL @@ -1869,9 +1890,9 @@ if [ "${ibd_status}" = 'true' ]; then log_info 'Disabling system sleep, suspend, and hibernate.' sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target > /dev/null 2>&1 fi - log_info "Close this Terminal window by clicking on the 'X'." - log_info "This screen will refresh in ${SLEEP_TIME_SECONDS} seconds." fi + log_info "Close this Terminal window by clicking on the 'X'." + log_info "This screen will refresh in ${SLEEP_TIME_SECONDS} seconds." sleep "${SLEEP_TIME_SECONDS}" else log_info 'Your node has already synced the blockchain.' diff --git a/test/test_nodebuilder b/test/test_nodebuilder index 528d35d78..16716eff1 100755 --- a/test/test_nodebuilder +++ b/test/test_nodebuilder @@ -28,9 +28,15 @@ get_operating_system() handle_exit() { kill_tail_process - [ -f nodebuilder ] && rm nodebuilder - [ -f "${STDOUT_TEST_FILENAME}" ] && rm "${STDOUT_TEST_FILENAME}" - [ -f "${STDERR_TEST_FILENAME}" ] && rm "${STDERR_TEST_FILENAME}" + if [ -f nodebuilder ]; then + rm nodebuilder + fi + if [ -f "${STDOUT_TEST_FILENAME}" ]; then + rm "${STDOUT_TEST_FILENAME}" + fi + if [ -f "${STDERR_TEST_FILENAME}" ]; then + rm "${STDERR_TEST_FILENAME}" + fi } handle_error() @@ -91,12 +97,14 @@ validate_bitcoin_version() validate_git_ref_short_name() { - [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = 'true' ] || - throw_error 'Not inside a Git repository.' "${LINENO}" - [ "$(basename "$(git rev-parse --show-toplevel)")" = 'nodebuilder' ] || - throw_error 'Not in the nodebuilder repository.' "${LINENO}" - git rev-parse --quiet --verify "$1" || - throw_error "$1 is not a valid branch, tag, or commit." "${LINENO}" + if command -v git > /dev/null 2>&1; then + [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = 'true' ] || + throw_error 'Not inside a Git repository.' "${LINENO}" + [ "$(basename "$(git rev-parse --show-toplevel)")" = 'nodebuilder' ] || + throw_error 'Not in the nodebuilder repository.' "${LINENO}" + git rev-parse --quiet --verify "$1" || + throw_error "$1 is not a valid branch, tag, or commit." "${LINENO}" + fi } readonly VALID_BITCOIN_VERSION_LIST='0.9.5 0.10.0 0.10.1 0.10.2 0.10.3 0.10.4 \ @@ -183,8 +191,7 @@ fi # Execute the script with optional command line arguments printf 'Executing command: %s\n' "${RUN_NODEBUILDER_COMMAND}" if ! ${RUN_NODEBUILDER_COMMAND} \ - > "${STDOUT_TEST_FILENAME}" \ - 2> "${STDERR_TEST_FILENAME}"; then + > "${STDOUT_TEST_FILENAME}"; then throw_error "Failed to execute nodebuilder command." fi