Skip to content

Commit

Permalink
Added golang version check target
Browse files Browse the repository at this point in the history
Co-authored-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Adrian Reber <areber@redhat.com>
  • Loading branch information
adrianreber and rst0git committed Apr 14, 2023
1 parent a976c4a commit 740974d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ TEST_PAYLOAD := piggie/piggie
TEST_BINARIES := test $(TEST_PAYLOAD) phaul/phaul
COVERAGE_BINARIES := test.coverage phaul/phaul.coverage

GO_MAJOR_VER = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VER = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MIN_GO_MAJOR_VER = 1
MIN_GO_MINOR_VER = 20
GO_VALIDATION_ERR = Go version is not supported. Please update to at least $(MIN_GO_MAJOR_VER).$(MIN_GO_MINOR_VER)

check-go-version:
@if [ $(GO_MAJOR_VER) -gt $(MIN_GO_MAJOR_VER) ]; then \
exit 0 ;\
elif [ $(GO_MAJOR_VER) -lt $(MIN_GO_MAJOR_VER) ]; then \
echo '$(GO_VALIDATION_ERR)';\
exit 1; \
elif [ $(GO_MINOR_VER) -lt $(MIN_GO_MINOR_VER) ] ; then \
echo '$(GO_VALIDATION_ERR)';\
exit 1; \
fi


all: $(TEST_BINARIES) phaul-test
mkdir -p image
PID=$$(piggie/piggie) && { \
Expand Down Expand Up @@ -81,4 +99,4 @@ clean:
@rm -f $(TEST_BINARIES) $(COVERAGE_BINARIES) codecov
@rm -rf image $(COVERAGE_PATH)

.PHONY: all clean coverage codecov crit-test phaul-test
.PHONY: all clean coverage codecov crit-test phaul-test check-go-version

0 comments on commit 740974d

Please sign in to comment.