-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathcheck
executable file
·55 lines (42 loc) · 1.59 KB
/
check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
set -e
# For the check step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
if [[ $(uname) == 'Darwin' ]]; then
READLINK_BIN="greadlink"
else
READLINK_BIN="readlink"
fi
if [[ -z "${SOURCE_PATH}" ]]; then
export SOURCE_PATH="$(${READLINK_BIN} -f $(dirname ${0})/..)"
else
export SOURCE_PATH="$(${READLINK_BIN} -f "${SOURCE_PATH}")"
fi
export GOBIN="${SOURCE_PATH}/tmp/bin"
export PATH="${GOBIN}:${PATH}"
# Install golangci-lint (linting tool).
if [[ -z "${GOLANGCI_LINT_VERSION}" ]]; then
export GOLANGCI_LINT_VERSION=v1.60.3
fi
echo "Fetching golangci-lint tool"
go install github.com/golangci/golangci-lint/cmd/golangci-lint@"${GOLANGCI_LINT_VERSION}"
echo "Successfully fetched golangci-lint"
golangci-lint version
###############################################################################
cd ${SOURCE_PATH}
PACKAGES="$(go list -e ./... | grep -vE '/tmp/')"
LINT_FOLDERS="$(echo ${PACKAGES} | sed "s|github.com/gardener/machine-controller-manager-provider-aws|.|g")"
# Execute static code checks.
echo "Running go vet..."
go vet ${PACKAGES}
# Execute automatic code formatting directive.
echo "Running go fmt..."
go fmt ${PACKAGES}
echo "Executing golangci-lint..."
# golangci-lint can't be run from outside the directory
(cd ${SOURCE_PATH} && golangci-lint run -c .golangci.yaml --timeout 10m)
# Run Static Application Security Testing (SAST) using gosec
make sast-report