Skip to content

Commit d9e668f

Browse files
committed
Add reference Makefile and tests
Signed-off-by: Thomas Stromberg <[email protected]>
1 parent 2093404 commit d9e668f

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# BEGIN: lint-install .
3+
# http://github.com/tinkerbell/lint-install
4+
5+
GOLINT_VERSION ?= v1.42.0
6+
HADOLINT_VERSION ?= v2.7.0
7+
SHELLCHECK_VERSION ?= v0.7.2
8+
LINT_OS := $(shell uname)
9+
LINT_ARCH := $(shell uname -m)
10+
11+
# shellcheck and hadolint lack arm64 native binaries: rely on x86-64 emulation
12+
ifeq ($(LINT_OS),Darwin)
13+
ifeq ($(LINT_ARCH),arm64)
14+
LINT_ARCH=x86_64
15+
endif
16+
endif
17+
18+
LINT_LOWER_OS = $(shell echo $(LINT_OS) | tr '[:upper:]' '[:lower:]')
19+
GOLINT_CONFIG:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/.golangci.yml
20+
21+
lint: out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH)
22+
out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH) run
23+
out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) -t info $(shell find . -name "*Dockerfile")
24+
out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck $(shell find . -name "*.sh")
25+
26+
out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck:
27+
mkdir -p out/linters
28+
curl -sSfL https://github.com/koalaman/shellcheck/releases/download/$(SHELLCHECK_VERSION)/shellcheck-$(SHELLCHECK_VERSION).$(LINT_LOWER_OS).$(LINT_ARCH).tar.xz | tar -C out/linters -xJf -
29+
mv out/linters/shellcheck-$(SHELLCHECK_VERSION) out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)
30+
31+
out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH):
32+
mkdir -p out/linters
33+
curl -sfL https://github.com/hadolint/hadolint/releases/download/v2.6.1/hadolint-$(LINT_OS)-$(LINT_ARCH) > out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH)
34+
chmod u+x out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH)
35+
36+
out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH):
37+
mkdir -p out/linters
38+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b out/linters $(GOLINT_VERSION)
39+
mv out/linters/golangci-lint out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH)
40+
41+
# END: lint-install .

test/test.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM ubuntu:hirsute-20210723
2+
RUN echo hello world

test/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/sh

0 commit comments

Comments
 (0)