Skip to content

Add support for ARM64 #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion hooks/command
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install_reporter() {
printf -- "--- :codeclimate: Installing %s cc-test-reporter\\n" "${version}"

curl --location --silent --output ./cc-test-reporter \
"https://codeclimate.com/downloads/test-reporter/test-reporter-${version}-linux-amd64" && \
"https://codeclimate.com/downloads/test-reporter/test-reporter-${version}-linux-${arch}" && \
chmod +x ./cc-test-reporter
# add current working directory to path so cc-test-reporter is accessible
PATH=${PATH}:$(pwd)
Expand Down Expand Up @@ -104,6 +104,20 @@ report=${BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_REPORT:-true}
formatted_file_prefix=${BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_FILE_PREFIX:-"codeclimate"}
version=${BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_VERSION:-"latest"}

march="$(uname -m)"
case $march in
x86_64)
arch="amd64"
;;
aarch64)
arch="arm64"
;;
*)
echo "Unsupported architecture: ${march}"
exit 1
;;
esac

install_reporter
download_artifacts
format_files
Expand Down
43 changes: 42 additions & 1 deletion tests/command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ load '/usr/local/lib/bats/load.bash'
# Uncomment the following line to debug stub failures
# export BUILDKITE_AGENT_STUB_DEBUG=/dev/tty

@test "Installs the latest reporter binary" {
@test "Installs the latest reporter binary amd64" {
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_DOWNLOAD="false"
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_FORMAT="false"
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_REPORT="false"

stub uname "-m : echo 'x86_64'"
stub curl "--location --silent --output ./cc-test-reporter \"https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64\" : echo 'Binary downloaded'"
stub chmod "+x ./cc-test-reporter : echo 'Binary made executable'"
stub cc-test-reporter "-v : echo 'Code Climate Test Reporter version'"
Expand All @@ -22,11 +23,51 @@ load '/usr/local/lib/bats/load.bash'
assert_output --partial "Binary made executable"
assert_output --partial "Code Climate Test Reporter version"

unstub uname
unstub curl
unstub chmod
unstub cc-test-reporter
}

@test "Installs the latest reporter binary arm64" {
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_DOWNLOAD="false"
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_FORMAT="false"
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_REPORT="false"

stub uname "-m : echo 'aarch64'"
stub curl "--location --silent --output ./cc-test-reporter \"https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-arm64\" : echo 'Binary downloaded'"
stub chmod "+x ./cc-test-reporter : echo 'Binary made executable'"
stub cc-test-reporter "-v : echo 'Code Climate Test Reporter version'"

run "$PWD/hooks/command"

assert_success
assert_output --partial "--- :codeclimate: Installing latest cc-test-reporter"
assert_output --partial "Binary downloaded"
assert_output --partial "Binary made executable"
assert_output --partial "Code Climate Test Reporter version"

unstub uname
unstub curl
unstub chmod
unstub cc-test-reporter
}

@test "Installs the latest reporter binary unsupported architecture" {
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_DOWNLOAD="false"
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_FORMAT="false"
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_REPORT="false"

stub uname "-m : echo 'riscv64'"

run "$PWD/hooks/command"

assert_failure
assert_output --partial "Unsupported architecture: riscv64"

unstub uname
}

@test "Downloads artifacts" {
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_INSTALL="false"
export BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_FORMAT="false"
Expand Down