Files
dokku/tests/unit/makefile-arch.bats
T
Jose Diaz-Gonzalez 825fa8968c fix: default source installs to the host architecture
Installing from source on an arm64 host downloaded amd64 dependencies and built amd64 plugins, failing once `plugin:install` ran the first binary. The `TARGETARCH` and `GOARCH` make variables now default to the host architecture and remain overridable, and debian packages are labelled with the architecture they were built for. Closes #9217.
2026-11-06 17:11:28 -05:00

68 lines
2.4 KiB
Bash

#!/usr/bin/env bats
load test_helper
setup() {
REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)"
HOST_ARCH="$(dpkg --print-architecture)"
OTHER_ARCH="amd64"
if [[ "$HOST_ARCH" == "amd64" ]]; then
OTHER_ARCH="arm64"
fi
}
@test "(makefile) [arch] dependency urls default to the host architecture" {
run make -n -C "$REPO_ROOT" docker-image-labeler
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "$(dependency_url docker-image-labeler "$HOST_ARCH")" -1
}
@test "(makefile) [arch] TARGETARCH overrides the dependency architecture" {
run env TARGETARCH="$OTHER_ARCH" make -n -C "$REPO_ROOT" docker-image-labeler
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "$(dependency_url docker-image-labeler "$OTHER_ARCH")" -1
}
@test "(makefile) [arch] plugin builds default to the host architecture" {
run make -B -n -C "$REPO_ROOT" go-build-plugin PLUGIN_NAME=common PLUGIN_MAKE_TARGET=build
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "GOARCH=$HOST_ARCH go build" -1
assert_output_contains "GOARCH=$OTHER_ARCH" 0
}
@test "(makefile) [arch] TARGETARCH sets the plugin build architecture" {
run env TARGETARCH="$OTHER_ARCH" make -B -n -C "$REPO_ROOT" go-build-plugin PLUGIN_NAME=common PLUGIN_MAKE_TARGET=build
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "GOARCH=$OTHER_ARCH go build" -1
assert_output_contains "GOARCH=$HOST_ARCH" 0
}
@test "(makefile) [arch] GOARCH overrides the plugin build architecture" {
run env GOARCH="$OTHER_ARCH" make -B -n -C "$REPO_ROOT" go-build-plugin PLUGIN_NAME=common PLUGIN_MAKE_TARGET=build
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "GOARCH=$OTHER_ARCH go build" -1
assert_output_contains "GOARCH=$HOST_ARCH" 0
run env GOARCH="$OTHER_ARCH" make -n -C "$REPO_ROOT" docker-image-labeler
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "$(dependency_url docker-image-labeler "$HOST_ARCH")" -1
}
dependency_url() {
declare desc="print the url for a dependency in contrib/dependencies.json"
declare NAME="$1" ARCH="$2"
jq -r --arg name "$NAME" --arg arch "$ARCH" '.dependencies[] | select(.name == $name) | .urls[$arch]' "$REPO_ROOT/contrib/dependencies.json"
}