Add build util to automatically detect arch from uname

This will help running `test:env` and `test:compose` in environments
other than `amd64`.
This commit is contained in:
pipex 2022-10-17 11:32:41 -03:00
parent 819e184095
commit a1e432f4fa
2 changed files with 35 additions and 2 deletions

33
build-utils/detect-arch.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/sh
# detect-arch.sh
case $(uname -m) in
x86_64)
echo "amd64"
;;
aarch64)
:
echo "aarch64"
;;
arm64)
echo "aarch64"
;;
armv7l)
echo "armv7hf"
;;
armv6l)
echo "rpi"
;;
i686)
:
echo "i386"
;;
i386)
:
echo "i386"
;;
*)
echo >&2 "Unknown architecture $(uname -m)"
exit 1
;;
esac

View File

@ -17,8 +17,8 @@
"test:integration:single": "find test/integration -name *.spec.ts | xargs mocha --config test/integration/.mocharc.js",
"test:legacy": "mocha --config test/legacy/.mocharc.js",
"test:node": "npm run test:unit && npm run test:integration && npm run test:legacy",
"test:env": "docker-compose -f docker-compose.test.yml -f docker-compose.dev.yml up --build; npm run compose:down",
"test:compose": "docker-compose -f docker-compose.yml -f docker-compose.test.yml up --build --remove-orphans --exit-code-from=sut ; npm run compose:down",
"test:env": "ARCH=$(./build-utils/detect-arch.sh) docker-compose -f docker-compose.test.yml -f docker-compose.dev.yml up --build; npm run compose:down",
"test:compose": "ARCH=$(./build-utils/detect-arch.sh) docker-compose -f docker-compose.yml -f docker-compose.test.yml up --build --remove-orphans --exit-code-from=sut ; npm run compose:down",
"test": "npm run lint && npm run test:build && npm run test:unit && npm run test:legacy",
"compose:down": "docker-compose -f docker-compose.test.yml down",
"prettify": "balena-lint -e ts -e js --fix src/ test/ typings/ build-utils/ webpack.config.js",