Commit 4b16cd6c by Oleg Gaidarenko Committed by GitHub

Build: Introduce shellcheck (#18081)

* Build: introduce shellcheck

Fixes #16198
parent 87a794fe
...@@ -127,6 +127,15 @@ jobs: ...@@ -127,6 +127,15 @@ jobs:
name: Lint Go name: Lint Go
command: 'make lint-go' command: 'make lint-go'
shellcheck:
machine: true
working_directory: ~/go/src/github.com/grafana/grafana
steps:
- checkout
- run:
name: ShellCheck
command: 'make shellcheck'
test-frontend: test-frontend:
docker: docker:
- image: circleci/node:10 - image: circleci/node:10
...@@ -650,6 +659,8 @@ workflows: ...@@ -650,6 +659,8 @@ workflows:
filters: *filter-only-master filters: *filter-only-master
- lint-go: - lint-go:
filters: *filter-only-master filters: *filter-only-master
- shellcheck:
filters: *filter-only-master
- test-frontend: - test-frontend:
filters: *filter-only-master filters: *filter-only-master
- test-backend: - test-backend:
...@@ -665,6 +676,7 @@ workflows: ...@@ -665,6 +676,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
- build-oss-msi - build-oss-msi
...@@ -677,6 +689,7 @@ workflows: ...@@ -677,6 +689,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
filters: *filter-only-master filters: *filter-only-master
...@@ -687,6 +700,7 @@ workflows: ...@@ -687,6 +700,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
- build-all-enterprise - build-all-enterprise
...@@ -698,6 +712,7 @@ workflows: ...@@ -698,6 +712,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
filters: *filter-only-master filters: *filter-only-master
...@@ -724,6 +739,8 @@ workflows: ...@@ -724,6 +739,8 @@ workflows:
filters: *filter-only-release filters: *filter-only-release
- lint-go: - lint-go:
filters: *filter-only-release filters: *filter-only-release
- shellcheck:
filters: *filter-only-release
- test-frontend: - test-frontend:
filters: *filter-only-release filters: *filter-only-release
- test-backend: - test-backend:
...@@ -739,6 +756,7 @@ workflows: ...@@ -739,6 +756,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
- build-oss-msi - build-oss-msi
...@@ -751,6 +769,7 @@ workflows: ...@@ -751,6 +769,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
filters: *filter-only-release filters: *filter-only-release
...@@ -762,6 +781,7 @@ workflows: ...@@ -762,6 +781,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
filters: *filter-only-release filters: *filter-only-release
...@@ -772,6 +792,7 @@ workflows: ...@@ -772,6 +792,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
filters: *filter-only-release filters: *filter-only-release
...@@ -791,6 +812,10 @@ workflows: ...@@ -791,6 +812,10 @@ workflows:
filters: *filter-not-release-or-master filters: *filter-not-release-or-master
- lint-go: - lint-go:
filters: *filter-not-release-or-master filters: *filter-not-release-or-master
- lint-go:
filters: *filter-not-release-or-master
- shellcheck:
filters: *filter-not-release-or-master
- test-frontend: - test-frontend:
filters: *filter-not-release-or-master filters: *filter-not-release-or-master
- test-backend: - test-backend:
...@@ -808,6 +833,7 @@ workflows: ...@@ -808,6 +833,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
- cache-server-test - cache-server-test
...@@ -819,6 +845,7 @@ workflows: ...@@ -819,6 +845,7 @@ workflows:
- test-frontend - test-frontend
- codespell - codespell
- lint-go - lint-go
- shellcheck
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
- cache-server-test - cache-server-test
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
GO = GO111MODULE=on go GO = GO111MODULE=on go
GO_FILES ?= ./pkg/... GO_FILES ?= ./pkg/...
SH_FILES ?= $(shell find ./scripts -name *.sh)
all: deps build all: deps build
...@@ -111,6 +112,11 @@ go-vet: ...@@ -111,6 +112,11 @@ go-vet:
lint-go: go-vet golangci-lint revive revive-alerting gosec lint-go: go-vet golangci-lint revive revive-alerting gosec
# with disabled SC1071 we are ignored some TCL,Expect `/usr/bin/env expect` scripts
shellcheck: $(SH_FILES)
@docker run --rm -v "$$PWD:/mnt" koalaman/shellcheck:stable \
$(SH_FILES) -e SC1071
run: scripts/go/bin/bra run: scripts/go/bin/bra
@scripts/go/bin/bra run @scripts/go/bin/bra run
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
set -e set -e
# shellcheck disable=SC2124
EXTRA_OPTS="$@" EXTRA_OPTS="$@"
CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
...@@ -15,9 +16,6 @@ CCOSX64=/tmp/osxcross/target/bin/o64-clang ...@@ -15,9 +16,6 @@ CCOSX64=/tmp/osxcross/target/bin/o64-clang
CCWIN64=x86_64-w64-mingw32-gcc CCWIN64=x86_64-w64-mingw32-gcc
CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
GOPATH=/go
REPO_PATH=$GOPATH/src/github.com/grafana/grafana
cd /go/src/github.com/grafana/grafana cd /go/src/github.com/grafana/grafana
echo "current dir: $(pwd)" echo "current dir: $(pwd)"
...@@ -34,16 +32,16 @@ echo "current dir: $(pwd)" ...@@ -34,16 +32,16 @@ echo "current dir: $(pwd)"
# build only amd64 for enterprise # build only amd64 for enterprise
if echo "$EXTRA_OPTS" | grep -vq enterprise ; then if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build go run build.go -goarch armv6 -cc "${CCARMV6}" "${OPT}" build
go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build go run build.go -goarch armv7 -cc "${CCARMV7}" "${OPT}" build
go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build go run build.go -goarch arm64 -cc "${CCARM64}" "${OPT}" build
go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build go run build.go -goos darwin -cc "${CCOSX64}" "${OPT}" build
fi fi
go run build.go -goos windows -cc ${CCWIN64} ${OPT} build go run build.go -goos windows -cc "${CCWIN64}" "${OPT}" build
# Do not remove CC from the linux build, its there for compatibility with Centos6 # Do not remove CC from the linux build, its there for compatibility with Centos6
CC=${CCX64} go run build.go ${OPT} build CC=${CCX64} go run build.go "${OPT}" build
yarn install --pure-lockfile --no-progress yarn install --pure-lockfile --no-progress
...@@ -53,35 +51,36 @@ else ...@@ -53,35 +51,36 @@ else
echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH" echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
fi fi
echo "Building frontend" echo "Building frontend"
go run build.go ${OPT} build-frontend go run build.go "${OPT}" build-frontend
if [ -d "dist" ]; then if [ -d "dist" ]; then
rm -rf dist rm -rf dist
fi fi
mkdir dist mkdir dist
go run build.go -gen-version ${OPT} > dist/grafana.version go run build.go -gen-version "${OPT}" > dist/grafana.version
# Load ruby, needed for packing with fpm # Load ruby, needed for packing with fpm
# shellcheck disable=SC1091
source /etc/profile.d/rvm.sh source /etc/profile.d/rvm.sh
echo "Packaging" echo "Packaging"
go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only go run build.go -goos linux -pkg-arch amd64 "${OPT}" package-only
#removing amd64 phantomjs bin for armv7/arm64 packages #removing amd64 phantomjs bin for armv7/arm64 packages
rm tools/phantomjs/phantomjs rm tools/phantomjs/phantomjs
# build only amd64 for enterprise # build only amd64 for enterprise
if echo "$EXTRA_OPTS" | grep -vq enterprise ; then if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
go run build.go -goos linux -pkg-arch armv6 ${OPT} -skipRpm package-only go run build.go -goos linux -pkg-arch armv6 "${OPT}" -skipRpm package-only
go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only go run build.go -goos linux -pkg-arch armv7 "${OPT}" package-only
go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only go run build.go -goos linux -pkg-arch arm64 "${OPT}" package-only
if [ -d '/tmp/phantomjs/darwin' ]; then if [ -d '/tmp/phantomjs/darwin' ]; then
cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs
else else
echo 'PhantomJS binaries for darwin missing!' echo 'PhantomJS binaries for darwin missing!'
fi fi
go run build.go -goos darwin -pkg-arch amd64 ${OPT} package-only go run build.go -goos darwin -pkg-arch amd64 "${OPT}" package-only
fi fi
if [ -d '/tmp/phantomjs/windows' ]; then if [ -d '/tmp/phantomjs/windows' ]; then
...@@ -90,6 +89,6 @@ if [ -d '/tmp/phantomjs/windows' ]; then ...@@ -90,6 +89,6 @@ if [ -d '/tmp/phantomjs/windows' ]; then
else else
echo 'PhantomJS binaries for Windows missing!' echo 'PhantomJS binaries for Windows missing!'
fi fi
go run build.go -goos windows -pkg-arch amd64 ${OPT} package-only go run build.go -goos windows -pkg-arch amd64 "${OPT}" package-only
go run build.go latest go run build.go latest
...@@ -9,10 +9,6 @@ CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g ...@@ -9,10 +9,6 @@ CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g
CCARMV7=arm-linux-gnueabihf-gcc CCARMV7=arm-linux-gnueabihf-gcc
CCARM64=aarch64-linux-gnu-gcc CCARM64=aarch64-linux-gnu-gcc
CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
##########
GOPATH=/go
REPO_PATH=$GOPATH/src/github.com/grafana/grafana
##########
BUILD_FAST=0 BUILD_FAST=0
BUILD_BACKEND=1 BUILD_BACKEND=1
...@@ -51,9 +47,9 @@ while [ "$1" != "" ]; do ...@@ -51,9 +47,9 @@ while [ "$1" != "" ]; do
esac esac
done done
# shellcheck disable=SC2124
EXTRA_OPTS="$@" EXTRA_OPTS="$@"
cd /go/src/github.com/grafana/grafana cd /go/src/github.com/grafana/grafana
echo "current dir: $(pwd)" echo "current dir: $(pwd)"
...@@ -73,7 +69,7 @@ function build_backend_linux_amd64() { ...@@ -73,7 +69,7 @@ function build_backend_linux_amd64() {
if [ ! -d "dist" ]; then if [ ! -d "dist" ]; then
mkdir dist mkdir dist
fi fi
CC=${CCX64} go run build.go ${OPT} build CC=${CCX64} go run build.go "${OPT}" build
} }
function build_backend() { function build_backend() {
...@@ -81,9 +77,9 @@ function build_backend() { ...@@ -81,9 +77,9 @@ function build_backend() {
mkdir dist mkdir dist
fi fi
go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build go run build.go -goarch armv6 -cc ${CCARMV6} "${OPT}" build
go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build go run build.go -goarch armv7 -cc ${CCARMV7} "${OPT}" build
go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build go run build.go -goarch arm64 -cc ${CCARM64} "${OPT}" build
build_backend_linux_amd64 build_backend_linux_amd64
} }
...@@ -93,22 +89,22 @@ function build_frontend() { ...@@ -93,22 +89,22 @@ function build_frontend() {
fi fi
yarn install --pure-lockfile --no-progress yarn install --pure-lockfile --no-progress
echo "Building frontend" echo "Building frontend"
go run build.go ${OPT} build-frontend go run build.go "${OPT}" build-frontend
echo "FRONTEND: finished" echo "FRONTEND: finished"
} }
function package_linux_amd64() { function package_linux_amd64() {
echo "Packaging Linux AMD64" echo "Packaging Linux AMD64"
go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only go run build.go -goos linux -pkg-arch amd64 "${OPT}" package-only
go run build.go latest go run build.go latest
echo "PACKAGE LINUX AMD64: finished" echo "PACKAGE LINUX AMD64: finished"
} }
function package_all() { function package_all() {
echo "Packaging ALL" echo "Packaging ALL"
go run build.go -goos linux -pkg-arch armv6 ${OPT} -skipRpm package-only go run build.go -goos linux -pkg-arch armv6 "${OPT}" -skipRpm package-only
go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only go run build.go -goos linux -pkg-arch armv7 "${OPT}" package-only
go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only go run build.go -goos linux -pkg-arch arm64 "${OPT}" package-only
package_linux_amd64 package_linux_amd64
echo "PACKAGE ALL: finished" echo "PACKAGE ALL: finished"
} }
...@@ -119,8 +115,9 @@ function package_setup() { ...@@ -119,8 +115,9 @@ function package_setup() {
rm -rf dist rm -rf dist
fi fi
mkdir dist mkdir dist
go run build.go -gen-version ${OPT} > dist/grafana.version go run build.go -gen-version "${OPT}" > dist/grafana.version
# Load ruby, needed for packing with fpm # Load ruby, needed for packing with fpm
# shellcheck disable=SC1091
source /etc/profile.d/rvm.sh source /etc/profile.d/rvm.sh
} }
......
#!/bin/bash #!/bin/bash
cd /tmp cd /tmp || exit 1
tar xfJ x86_64-centos6-linux-gnu.tar.xz tar xfJ x86_64-centos6-linux-gnu.tar.xz
tar xfJ osxcross.tar.xz tar xfJ osxcross.tar.xz
#!/bin/bash #!/bin/bash
set -e set -e
WORKING_DIRECTORY=`pwd` WORKING_DIRECTORY=$(pwd)
# copy zip file to /tmp/dist # copy zip file to /tmp/dist
mkdir -p /tmp/dist mkdir -p /tmp/dist
cp ./dist/*.zip /tmp/dist cp ./dist/*.zip /tmp/dist
...@@ -23,12 +23,12 @@ echo "Building MSI" ...@@ -23,12 +23,12 @@ echo "Building MSI"
python3 generator/build.py "$@" python3 generator/build.py "$@"
chmod a+x /tmp/scratch/*.msi chmod a+x /tmp/scratch/*.msi
echo "MSI: Copy to $WORKING_DIRECTORY/dist" echo "MSI: Copy to $WORKING_DIRECTORY/dist"
cp /tmp/scratch/*.msi $WORKING_DIRECTORY/dist cp /tmp/scratch/*.msi "$WORKING_DIRECTORY/dist"
echo "MSI: Generate SHA256" echo "MSI: Generate SHA256"
MSI_FILE=`ls $WORKING_DIRECTORY/dist/*.msi` MSI_FILE=$(ls "$WORKING_DIRECTORY/dist/*.msi")
SHA256SUM=`sha256sum $MSI_FILE | cut -f1 -d' '` SHA256SUM=$(sha256sum "$MSI_FILE" | cut -f1 -d' ')
echo $SHA256SUM > $MSI_FILE.sha256 echo "$SHA256SUM" > "$MSI_FILE.sha256"
echo "MSI: SHA256 file content:" echo "MSI: SHA256 file content:"
cat $MSI_FILE.sha256 cat "$MSI_FILE.sha256"
echo "MSI: contents of $WORKING_DIRECTORY/dist" echo "MSI: contents of $WORKING_DIRECTORY/dist"
ls -al $WORKING_DIRECTORY/dist ls -al "$WORKING_DIRECTORY/dist"
...@@ -21,7 +21,7 @@ ls -al /home/xclient/wix/light.exe.config ...@@ -21,7 +21,7 @@ ls -al /home/xclient/wix/light.exe.config
cat /home/xclient/wix/light.exe.config cat /home/xclient/wix/light.exe.config
cp /master/light.exe.config /home/xclient/wix/light.exe.config cp /master/light.exe.config /home/xclient/wix/light.exe.config
cat /home/xclient/wix/light.exe.config cat /home/xclient/wix/light.exe.config
cd /master cd /master || exit 1
echo "Building MSI" echo "Building MSI"
python3 generator/build.py "$@" python3 generator/build.py "$@"
# #
......
#!/bin/bash #!/bin/bash
cd /oss cd /oss || exit 1
make make
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
cd .. cd ..
if [ -z "$CIRCLE_TAG" ]; then if [ -z "$CIRCLE_TAG" ]; then
_target="master" _target="master"
else else
...@@ -11,5 +10,5 @@ fi ...@@ -11,5 +10,5 @@ fi
git clone -b "$_target" --single-branch git@github.com:grafana/grafana-enterprise.git --depth 1 git clone -b "$_target" --single-branch git@github.com:grafana/grafana-enterprise.git --depth 1
cd grafana-enterprise cd grafana-enterprise || exit
./build.sh ./build.sh
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# no relation to publish.go # no relation to publish.go
# shellcheck disable=SC2124
EXTRA_OPTS="$@" EXTRA_OPTS="$@"
# Right now we hack this in into the publish script. # Right now we hack this in into the publish script.
...@@ -10,7 +12,7 @@ _releaseNoteUrl="https://community.grafana.com/t/release-notes-v6-0-x/14010" ...@@ -10,7 +12,7 @@ _releaseNoteUrl="https://community.grafana.com/t/release-notes-v6-0-x/14010"
_whatsNewUrl="http://docs.grafana.org/guides/whats-new-in-v6-0/" _whatsNewUrl="http://docs.grafana.org/guides/whats-new-in-v6-0/"
./scripts/build/release_publisher/release_publisher \ ./scripts/build/release_publisher/release_publisher \
--wn ${_whatsNewUrl} \ --wn "${_whatsNewUrl}" \
--rn ${_releaseNoteUrl} \ --rn "${_releaseNoteUrl}" \
--version ${CIRCLE_TAG} \ --version "${CIRCLE_TAG}" \
--apikey ${GRAFANA_COM_API_KEY} ${EXTRA_OPTS} --apikey "${GRAFANA_COM_API_KEY}" "${EXTRA_OPTS}"
...@@ -8,5 +8,5 @@ cp ./scripts/build/rpmmacros ~/.rpmmacros ...@@ -8,5 +8,5 @@ cp ./scripts/build/rpmmacros ~/.rpmmacros
for package in dist/*.rpm; do for package in dist/*.rpm; do
[ -e "$package" ] || continue [ -e "$package" ] || continue
./scripts/build/sign_expect $GPG_KEY_PASSWORD $package ./scripts/build/sign_expect "$GPG_KEY_PASSWORD" "$package"
done done
...@@ -9,7 +9,7 @@ GCP_REPO_BUCKET="${6:-grafana-repo}" ...@@ -9,7 +9,7 @@ GCP_REPO_BUCKET="${6:-grafana-repo}"
REPO="grafana" REPO="grafana"
if [ -z "$RELEASE_TYPE" -o -z "$GPG_PASS" -o -z "$DIST_PATH" ]; then if [ -z "$RELEASE_TYPE" ] || [ -z "$GPG_PASS" ] || [ -z "$DIST_PATH" ]; then
echo "Both RELEASE_TYPE (arg 1), GPG_PASS (arg 2) and DIST_PATH (arg 4) has to be set" echo "Both RELEASE_TYPE (arg 1), GPG_PASS (arg 2) and DIST_PATH (arg 4) has to be set"
exit 1 exit 1
fi fi
...@@ -36,7 +36,7 @@ mkdir -p /deb-repo/db \ ...@@ -36,7 +36,7 @@ mkdir -p /deb-repo/db \
gsutil -m rsync -r -d "gs://$GCP_DB_BUCKET/$RELEASE_TYPE" /deb-repo/db gsutil -m rsync -r -d "gs://$GCP_DB_BUCKET/$RELEASE_TYPE" /deb-repo/db
# Add the new release to the repo # Add the new release to the repo
cp $DIST_PATH/*.deb /deb-repo/tmp cp "$DIST_PATH/*.deb" /deb-repo/tmp
rm /deb-repo/tmp/grafana_latest*.deb || true rm /deb-repo/tmp/grafana_latest*.deb || true
aptly repo add "$REPO" /deb-repo/tmp #adds too many packages in enterprise aptly repo add "$REPO" /deb-repo/tmp #adds too many packages in enterprise
...@@ -64,5 +64,5 @@ gsutil -m rsync -r /deb-repo/repo/grafana/pool "gs://$GCP_REPO_BUCKET/$RELEASE_T ...@@ -64,5 +64,5 @@ gsutil -m rsync -r /deb-repo/repo/grafana/pool "gs://$GCP_REPO_BUCKET/$RELEASE_T
gsutil -m rsync -r -d /deb-repo/repo/grafana "gs://$GCP_REPO_BUCKET/$RELEASE_TYPE/deb" gsutil -m rsync -r -d /deb-repo/repo/grafana "gs://$GCP_REPO_BUCKET/$RELEASE_TYPE/deb"
# usage: # usage:
# #
# deb https://packages.grafana.com/oss/deb stable main # deb https://packages.grafana.com/oss/deb stable main
...@@ -8,7 +8,7 @@ GCP_REPO_BUCKET="${5:-grafana-repo}" ...@@ -8,7 +8,7 @@ GCP_REPO_BUCKET="${5:-grafana-repo}"
REPO="rpm" REPO="rpm"
if [ -z "$RELEASE_TYPE" -o -z "$GPG_PASS" -o -z "$DIST_PATH" ]; then if [ -z "$RELEASE_TYPE" ] || [ -z "$GPG_PASS" ] || [ -z "$DIST_PATH" ]; then
echo "Both RELEASE_TYPE (arg 1), GPG_PASS (arg 2) and DIST_PATH (arg 4) has to be set" echo "Both RELEASE_TYPE (arg 1), GPG_PASS (arg 2) and DIST_PATH (arg 4) has to be set"
exit 1 exit 1
fi fi
...@@ -33,7 +33,7 @@ mkdir -p /rpm-repo ...@@ -33,7 +33,7 @@ mkdir -p /rpm-repo
gsutil -m rsync -r "$BUCKET" /rpm-repo gsutil -m rsync -r "$BUCKET" /rpm-repo
# Add the new release to the repo # Add the new release to the repo
cp $DIST_PATH/*.rpm /rpm-repo # adds to many files for enterprise cp "$DIST_PATH/*.rpm" /rpm-repo # adds to many files for enterprise
rm /rpm-repo/grafana-latest-1*.rpm || true rm /rpm-repo/grafana-latest-1*.rpm || true
createrepo /rpm-repo createrepo /rpm-repo
......
#!/bin/bash #!/bin/bash
_files=$* _files=$*
ALL_SIGNED=0 ALL_SIGNED=0
for file in $_files; do for file in $_files; do
rpm -K "$file" | grep "pgp.*OK" -q if rpm -K "$file" | grep "pgp.*OK" -q; then
if [[ $? != 0 ]]; then
ALL_SIGNED=1 ALL_SIGNED=1
echo $file NOT SIGNED echo "$file" NOT SIGNED
else else
echo $file OK echo "$file" OK
fi fi
done done
......
...@@ -11,19 +11,19 @@ ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --noImpl ...@@ -11,19 +11,19 @@ ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --noImpl
DIRECTIVES="$(grep -r -o directive public/app/**/* | wc -l)" DIRECTIVES="$(grep -r -o directive public/app/**/* | wc -l)"
CONTROLLERS="$(grep -r -oP 'class .*Ctrl' public/app/**/* | wc -l)" CONTROLLERS="$(grep -r -oP 'class .*Ctrl' public/app/**/* | wc -l)"
if [ $ERROR_COUNT -gt $ERROR_COUNT_LIMIT ]; then if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
echo -e "Typescript errors $ERROR_COUNT exceeded $ERROR_COUNT_LIMIT so failing build" echo -e "Typescript errors $ERROR_COUNT exceeded $ERROR_COUNT_LIMIT so failing build"
exit -1 exit 1
fi fi
if [ $DIRECTIVES -gt $DIRECTIVES_LIMIT ]; then if [ "$DIRECTIVES" -gt $DIRECTIVES_LIMIT ]; then
echo -e "Directive count $DIRECTIVES exceeded $DIRECTIVES_LIMIT so failing build" echo -e "Directive count $DIRECTIVES exceeded $DIRECTIVES_LIMIT so failing build"
exit -1 exit 1
fi fi
if [ $CONTROLLERS -gt $CONTROLLERS_LIMIT ]; then if [ "$CONTROLLERS" -gt $CONTROLLERS_LIMIT ]; then
echo -e "Controllers count $CONTROLLERS exceeded $CONTROLLERS_LIMIT so failing build" echo -e "Controllers count $CONTROLLERS exceeded $CONTROLLERS_LIMIT so failing build"
exit -1 exit 1
fi fi
echo -e "Typescript errors: $ERROR_COUNT" echo -e "Typescript errors: $ERROR_COUNT"
...@@ -32,7 +32,7 @@ echo -e "Controllers: $CONTROLLERS" ...@@ -32,7 +32,7 @@ echo -e "Controllers: $CONTROLLERS"
if [ "${CIRCLE_BRANCH}" == "master" ]; then if [ "${CIRCLE_BRANCH}" == "master" ]; then
./scripts/ci-metrics-publisher.sh \ ./scripts/ci-metrics-publisher.sh \
grafana.ci-code.noImplicitAny=$ERROR_COUNT \ grafana.ci-code.noImplicitAny="$ERROR_COUNT" \
grafana.ci-code.directives=$DIRECTIVES \ grafana.ci-code.directives="$DIRECTIVES" \
grafana.ci-code.controllers=$CONTROLLERS grafana.ci-code.controllers="$CONTROLLERS"
fi fi
...@@ -13,6 +13,6 @@ for ((i = 1; i <= $#; i++ )); do ...@@ -13,6 +13,6 @@ for ((i = 1; i <= $#; i++ )); do
data=''$data'{"name": "'${first}'", "value": '${remainder}', "interval": 60, "mtype": "gauge", "time": '$(date +%s)'}' data=''$data'{"name": "'${first}'", "value": '${remainder}', "interval": 60, "mtype": "gauge", "time": '$(date +%s)'}'
done done
curl https://6371:$GRAFANA_MISC_STATS_API_KEY@graphite-us-central1.grafana.net/metrics \ curl "https://6371:$GRAFANA_MISC_STATS_API_KEY@graphite-us-central1.grafana.net/metrics" \
-H 'Content-type: application/json' \ -H 'Content-type: application/json' \
-d "[$data]" -d "[$data]"
...@@ -12,7 +12,7 @@ function prapare_version_commit () { ...@@ -12,7 +12,7 @@ function prapare_version_commit () {
} }
#Get current version from lerna.json #Get current version from lerna.json
PACKAGE_VERSION=`grep '"version"' lerna.json | cut -d '"' -f 4` PACKAGE_VERSION=$(grep '"version"' lerna.json | cut -d '"' -f 4)
# Get short current commit's has # Get short current commit's has
GIT_SHA=$(parse_git_hash) GIT_SHA=$(parse_git_hash)
...@@ -20,16 +20,14 @@ echo "Commit: ${GIT_SHA}" ...@@ -20,16 +20,14 @@ echo "Commit: ${GIT_SHA}"
echo "Current lerna.json version: ${PACKAGE_VERSION}" echo "Current lerna.json version: ${PACKAGE_VERSION}"
# check if there were any changes to packages between current and previous commit # check if there were any changes to packages between current and previous commit
count=`git diff HEAD~1..HEAD --name-only -- packages | awk '{c++} END {print c}'` count=$(git diff HEAD~1..HEAD --name-only -- packages | awk '{c++} END {print c}')
if [ -z "$count" ]; then
if [ -z $count ]; then
echo "No changes in packages, skipping packages publishing" echo "No changes in packages, skipping packages publishing"
else else
echo "Changes detected in ${count} packages" echo "Changes detected in ${count} packages"
echo "Releasing packages under ${PACKAGE_VERSION}-${GIT_SHA}" echo "Releasing packages under ${PACKAGE_VERSION}-${GIT_SHA}"
npx lerna version ${PACKAGE_VERSION}-${GIT_SHA} --no-git-tag-version --no-push --force-publish -y npx lerna version "${PACKAGE_VERSION}-${GIT_SHA}" --no-git-tag-version --no-push --force-publish -y
echo $'\nGit status:' echo $'\nGit status:'
git status -s git status -s
......
#!/bin/bash #!/bin/bash
function exit_if_fail {
command=$@ # shellcheck source=./scripts/helpers/exit-if-fail.sh
echo "Executing '$command'" source "$(dirname "$0")/helpers/exit-if-fail.sh"
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
}
echo "building backend with install to cache pkgs" echo "building backend with install to cache pkgs"
exit_if_fail time go install ./pkg/cmd/grafana-server exit_if_fail time go install ./pkg/cmd/grafana-server
...@@ -16,5 +9,5 @@ exit_if_fail time go install ./pkg/cmd/grafana-server ...@@ -16,5 +9,5 @@ exit_if_fail time go install ./pkg/cmd/grafana-server
echo "running go test" echo "running go test"
set -e set -e
time for d in $(go list ./pkg/...); do time for d in $(go list ./pkg/...); do
exit_if_fail go test -tags=integration -covermode=atomic $d exit_if_fail go test -tags=integration -covermode=atomic "$d"
done done
#!/bin/bash #!/bin/bash
function exit_if_fail {
command=$@ # shellcheck source=./scripts/helpers/exit-if-fail.sh
echo "Executing '$command'" source "$(dirname "$0")/helpers/exit-if-fail.sh"
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
}
echo "running redis and memcache tests" echo "running redis and memcache tests"
......
#!/bin/bash #!/bin/bash
function exit_if_fail { # shellcheck source=./scripts/helpers/exit-if-fail.sh
command=$@ source "$(dirname "$0")/helpers/exit-if-fail.sh"
echo "Executing '$command'"
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
}
start=$(date +%s) start=$(date +%s)
......
#!/bin/bash #!/bin/bash
function exit_if_fail {
command=$@ # shellcheck source=./scripts/helpers/exit-if-fail.sh
echo "Executing '$command'" source "$(dirname "$0")/helpers/exit-if-fail.sh"
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
}
export GRAFANA_TEST_DB=mysql export GRAFANA_TEST_DB=mysql
time for d in $(go list ./pkg/...); do time for d in $(go list ./pkg/...); do
exit_if_fail go test -tags=integration $d exit_if_fail go test -tags=integration "$d"
done done
\ No newline at end of file
#!/bin/bash #!/bin/bash
function exit_if_fail {
command=$@ # shellcheck source=./scripts/helpers/exit-if-fail.sh
echo "Executing '$command'" source "$(dirname "$0")/helpers/exit-if-fail.sh"
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
}
export GRAFANA_TEST_DB=postgres export GRAFANA_TEST_DB=postgres
time for d in $(go list ./pkg/...); do time for d in $(go list ./pkg/...); do
exit_if_fail go test -tags=integration $d exit_if_fail go test -tags=integration "$d"
done done
\ No newline at end of file
#!/bin/bash
function exit_if_fail {
# shellcheck disable=SC2124
command=$@
echo "Executing '$command'"
eval "$command"
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
}
...@@ -6,12 +6,12 @@ set -e ...@@ -6,12 +6,12 @@ set -e
_tag=$1 _tag=$1
_branch="$(git rev-parse --abbrev-ref HEAD)" _branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "${_tag}" == "" ]; then if [ "${_tag}" == "" ]; then
echo "Missing version param. ex './scripts/tag_release.sh v5.1.1'" echo "Missing version param. ex './scripts/tag_release.sh v5.1.1'"
exit 1 exit 1
fi fi
if [ "${_branch}" == "master" ]; then if [ "${_branch}" == "master" ]; then
echo "you cannot tag releases from the master branch" echo "you cannot tag releases from the master branch"
echo "please checkout the release branch" echo "please checkout the release branch"
echo "ex 'git checkout v5.1.x'" echo "ex 'git checkout v5.1.x'"
...@@ -20,9 +20,9 @@ fi ...@@ -20,9 +20,9 @@ fi
# always make sure to pull latest changes from origin # always make sure to pull latest changes from origin
echo "pulling latest changes from ${_branch}" echo "pulling latest changes from ${_branch}"
git pull origin ${_branch} git pull origin "${_branch}"
# create signed tag for latest commit # create signed tag for latest commit
git tag -s "${_tag}" -m "release ${_tag}" git tag -s "${_tag}" -m "release ${_tag}"
# verify the signed tag # verify the signed tag
...@@ -31,7 +31,7 @@ git tag -v "${_tag}" ...@@ -31,7 +31,7 @@ git tag -v "${_tag}"
echo "Make sure the tag is signed as expected" echo "Make sure the tag is signed as expected"
echo "press [y] to push the tags" echo "press [y] to push the tags"
read -n 1 confirm read -n -r 1 confirm
if [ "${confirm}" == "y" ]; then if [ "${confirm}" == "y" ]; then
git push origin "${_branch}" --tags git push origin "${_branch}" --tags
......
#!/bin/bash #!/bin/bash
_circle_token=$1 _circle_token=$1
_grafana_version=$2 _grafana_version=$2
trigger_build_url=https://circleci.com/api/v1/project/grafana/grafana-docker/tree/master?circle-token=${_circle_token} trigger_build_url="https://circleci.com/api/v1/project/grafana/grafana-docker/tree/master?circle-token=${_circle_token}"
post_data=$(cat <<EOF post_data=$(cat <<EOF
{ {
...@@ -14,10 +14,10 @@ post_data=$(cat <<EOF ...@@ -14,10 +14,10 @@ post_data=$(cat <<EOF
EOF EOF
) )
echo ${post_data} echo "${post_data}"
curl \ curl \
--header "Accept: application/json" \ --header "Accept: application/json" \
--header "Content-Type: application/json" \ --header "Content-Type: application/json" \
--data "${post_data}" \ --data "${post_data}" \
--request POST ${trigger_build_url} --request POST "${trigger_build_url}"
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
_circle_token=$1 _circle_token=$1
trigger_build_url=https://circleci.com/api/v1/project/grafana/grafana-packer/tree/master?circle-token=${_circle_token} trigger_build_url="https://circleci.com/api/v1/project/grafana/grafana-packer/tree/master?circle-token=${_circle_token}"
curl \ curl \
--header "Accept: application/json" \ --header "Accept: application/json" \
--header "Content-Type: application/json" \ --header "Content-Type: application/json" \
--request POST ${trigger_build_url} --request POST "${trigger_build_url}"
\ No newline at end of file
...@@ -17,7 +17,7 @@ post_data=$(cat <<EOF ...@@ -17,7 +17,7 @@ post_data=$(cat <<EOF
EOF EOF
) )
echo ${post_data} echo "${post_data}"
curl \ curl \
--header "Accept: application/json" \ --header "Accept: application/json" \
......
...@@ -6,49 +6,49 @@ docker_build () { ...@@ -6,49 +6,49 @@ docker_build () {
package=$3 package=$3
tag=$4 tag=$4
docker build -f $dockerfile \ docker build -f "$dockerfile" \
--build-arg "REPO_CONFIG=$repo_file" \ --build-arg "REPO_CONFIG=$repo_file" \
--build-arg "PACKAGE=$package" \ --build-arg "PACKAGE=$package" \
--tag $tag \ --tag "$tag" \
--no-cache \ --no-cache \
. .
retval=$(docker run --rm $tag cat /usr/share/grafana/VERSION) retval=$(docker run --rm "$tag" cat /usr/share/grafana/VERSION)
} }
CHECK_BETA=$1 CHECK_BETA=$1
if [[ $CHECK_BETA == "beta" ]]; then if [[ $CHECK_BETA == "beta" ]]; then
# Testing deb repos # Testing deb repos
docker_build "Dockerfile.deb" "deb-oss-beta.list" "grafana" "gf-oss-deb-repo-test" docker_build "Dockerfile.deb" "deb-oss-beta.list" "grafana" "gf-oss-deb-repo-test"
_oss_deb_v=$retval _oss_deb_v="$retval"
docker_build "Dockerfile.deb" "deb-ee-beta.list" "grafana-enterprise" "gf-ee-deb-repo-test" docker_build "Dockerfile.deb" "deb-ee-beta.list" "grafana-enterprise" "gf-ee-deb-repo-test"
_ee_deb_v=$retval _ee_deb_v="$retval"
# Testing rpm repos # Testing rpm repos
docker_build "Dockerfile.rpm" "rpm-oss-beta.list" "grafana" "gf-oss-rpm-repo-test" docker_build "Dockerfile.rpm" "rpm-oss-beta.list" "grafana" "gf-oss-rpm-repo-test"
_oss_rpm_v=$retval _oss_rpm_v="$retval"
docker_build "Dockerfile.rpm" "rpm-ee-beta.list" "grafana-enterprise" "gf-ee-rpm-repo-test" docker_build "Dockerfile.rpm" "rpm-ee-beta.list" "grafana-enterprise" "gf-ee-rpm-repo-test"
_ee_rpm_v=$retval _ee_rpm_v="$retval"
else else
# Testing deb repos # Testing deb repos
docker_build "Dockerfile.deb" "deb-oss-stable.list" "grafana" "gf-oss-deb-repo-test" docker_build "Dockerfile.deb" "deb-oss-stable.list" "grafana" "gf-oss-deb-repo-test"
_oss_deb_v=$retval _oss_deb_v="$retval"
docker_build "Dockerfile.deb" "deb-ee-stable.list" "grafana-enterprise" "gf-ee-deb-repo-test" docker_build "Dockerfile.deb" "deb-ee-stable.list" "grafana-enterprise" "gf-ee-deb-repo-test"
_ee_deb_v=$retval _ee_deb_v="$retval"
# Testing rpm repos # Testing rpm repos
docker_build "Dockerfile.rpm" "rpm-oss-stable.list" "grafana" "gf-oss-rpm-repo-test" docker_build "Dockerfile.rpm" "rpm-oss-stable.list" "grafana" "gf-oss-rpm-repo-test"
_oss_rpm_v=$retval _oss_rpm_v="$retval"
docker_build "Dockerfile.rpm" "rpm-ee-stable.list" "grafana-enterprise" "gf-ee-rpm-repo-test" docker_build "Dockerfile.rpm" "rpm-ee-stable.list" "grafana-enterprise" "gf-ee-rpm-repo-test"
_ee_rpm_v=$retval _ee_rpm_v="$retval"
fi fi
echo Versions: echo Versions:
echo OSS deb = ${_oss_deb_v} echo OSS deb = "${_oss_deb_v}"
echo OSS rpm = ${_oss_rpm_v} echo OSS rpm = "${_oss_rpm_v}"
echo EE deb = ${_ee_deb_v} echo EE deb = "${_ee_deb_v}"
echo EE rpm = ${_ee_rpm_v} echo EE rpm = "${_ee_rpm_v}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment