Skip to content

Commit b1397a1

Browse files
committed
Add optional install of dependencies for golang test
1 parent 816d86f commit b1397a1

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

tests/golang-build/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ help:
22
@echo "Golang build test"
33
@echo "Available targets:"
44
@echo " download # download required sources"
5+
@echo " prepare # download and install dependencies"
56
@echo " test # run the test"
67

78
version = 1.16.6
@@ -13,6 +14,9 @@ ${tarball}:
1314
wget -O $@.tmp https://github.com/golang/go/archive/refs/tags/${tarball}
1415
mv $@.tmp $@
1516

17+
prepare: download
18+
@./install-deps.sh
19+
1620
test: download
1721
@./test.sh
1822

@@ -22,4 +26,4 @@ clean:
2226
distclean: clean
2327
rm -f ${tarball}
2428

25-
.PHONY: download test clean distclean help
29+
.PHONY: download prepare test clean distclean help

tests/golang-build/install-deps.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
. /etc/os-release
6+
7+
sudo=""
8+
if [[ $(id -u) != 0 ]]; then
9+
sudo="sudo"
10+
fi
11+
12+
if [[ "$ID" == "fedora" ]]; then
13+
(set -x; $sudo dnf -y install tar golang)
14+
elif [[ "$ID_LIKE" == "debian" ]]; then
15+
(set -x; $sudo apt-get -y install tar golang-go)
16+
else
17+
echo "Unsupported distro!" >&2
18+
exit 1
19+
fi

0 commit comments

Comments
 (0)