Commit 2de79a4d by Stephanie Closson Committed by GitHub

Because alpine uses musl instead of libc, the e2e/cypress was not compatible (#23602)

So:
- Created new VM based on debian-slim
- Could also be used as a build VM

Fixes:
- ginstall issue with merge somewhere.
- Trimmed down the alpine VM since we don't need the extra libraries for cypress
parent ed51ce3a
......@@ -59,12 +59,13 @@ fi
version=$1
if [ "$version" == "latest" ]; then
version="$latest"
wget -O - "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz" | tar -C /opt -zxf
ln -s /opt/grafana-${version} /opt/grafana
wget -O - "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz" | tar -C /opt -zxf -
elif [ "$version" == "canary" ]; then
version="$canary"
wget -O - "https://dl.grafana.com/oss/master/grafana-${version}.linux-amd64.tar.gz" | tar -C /opt -zxf -
fi
/bin/rm -rf /opt/grafana > /dev/null 2>&1 || true
ln -s /opt/grafana-${version} /opt/grafana
# nohup /opt/grafana/bin/grafana-server -config /opt/grafana/conf/defaults.ini -homepath /opt/grafana >/dev/null 2>&1 &
......
......@@ -9,7 +9,12 @@ rm /bin/cp
mv /usr/local/bin/cp /bin/cp
sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories
apk add nodejs npm yarn build-base openssh
apk add nodejs npm yarn build-base openssh
#
# Only relevant for testing, but cypress does not work with musl/alpine.
#
# apk add xvfb glib nss nspr gdk-pixbuf "gtk+3.0" pango atk cairo dbus-libs libxcomposite libxrender libxi libxtst libxrandr libxscrnsaver alsa-lib at-spi2-atk at-spi2-core cups-libs gcompat libc6-compat
# Install Go
filename="go1.14.linux-amd64.tar.gz"
......
FROM debian:buster-slim
USER root
ADD scripts scripts
ADD install /usr/local/bin
RUN cd scripts && ./deploy.sh
# Using this docker image
Currently tagged and uploaded to dockerhub as srclosson/integrations-ci-build
Based off of `circleci/node:12-browsers`
## User
The user will be `circleci`
The home directory will be `/home/circleci`
## Node
- node 12 is installed
- yarn is installed globally
- npm is installed globally
## Go
- Go 1.14 is installed in `/usr/local/bin/go`
- golangci-lint 1.23.7 is installed in `/usr/local/bin/golangci-lint`
- mage is installed in `/home/circleci/go/bin/mage`
All of the above directories are in the path, so there is no need to specify fully qualified paths.
## Grafana
- Installed in `/home/circleci/src/grafana`
- `yarn install` has been run
## Integration/Release Testing
There are 4 previous versions pre-downloaded to /usr/local/grafana. These versions are:
1. 6.6.2
2. 6.5.3
3. 6.4.5
4. 6.3.7
To test, your CircleCI config will need a run section with something similar to the following
```
- run:
name: Setup Grafana (local install)
command: |
sudo dpkg -i /usr/local/grafana/deb/grafana_6.6.2_amd64.deb
sudo cp ci/grafana-test-env/custom.ini /usr/share/grafana/conf/custom.ini
sudo cp ci/grafana-test-env/custom.ini /etc/grafana/grafana.ini
sudo service grafana-server start
grafana-cli --version
```
# Building
To build, cd to `<srcroot>/packages/grafana-toolkit/docker/grafana-plugin-ci`
```
./build.sh
```
# Developing/Testing
To test, you should have docker-compose installed.
```
cd test
./start.sh
```
You will be in /home/circleci/test with the buildscripts installed to the local directory.
Do your edits/run tests. When saving, your edits will be available in the container immediately.
\ No newline at end of file
#!/bin/bash
source ./common.sh
output=$(docker build . | tee /dev/tty)
hash=$(echo "$output" | tail -1 | sed -ne "s/^Successfully built \(.*\)/\1/p")
docker tag "$hash" $DOCKER_IMAGE_NAME:latest
docker push $DOCKER_IMAGE_NAME:latest
#!/bin/bash
##
## Common variable declarations
##
DOCKER_IMAGE_NAME="srclosson/grafana-plugin-ci-e2e"
#!/bin/sh
if [ "$1" == "-rn" ]; then
false | busybox cp -i -r "$2" "$3" 2>/dev/null
else
busybox cp $*
fi
#!/bin/sh
##
# gget
# A script to get and install grafana versions
# for usage information see "show_help" below.
#
latest=$(wget -O - 'https://raw.githubusercontent.com/grafana/grafana/master/latest.json' | jq -r '.stable')
canary=$(wget -O - "https://grafana.com/api/grafana/versions" | jq ".items[0].version" | tr -d '"')
show_help() {
echo "Usage: gget <version>"
echo ""
echo "where <version> can be:"
echo " 1) A version from https://grafana.com/grafana/download (ex x.y.z)"
echo " 2) latest (currently $latest)"
echo " 3) canary (currently $canary)"
echo ""
echo " -h, --help: Display this help message"
echo ""
exit 0
}
opts=$(getopt -o h --long help -n 'gget' -- "$@")
[ $? -eq 0 ] || {
show_help
}
eval set -- "$opts"
while true; do
case "$1" in
-h | --help)
show_help
;;
--)
shift
break
;;
*)
break
;;
esac
shift
done
[ -z "$1" ] && show_help
# Make sure the script is being run as root
if [ $EUID -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
##
# MAIN
#
# Enough setup, let's actually do something
#
version=$1
if [ "$version" == "latest" ]; then
version="$latest"
wget -O - "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz" | tar -C /opt -zxf -
elif [ "$version" == "canary" ]; then
version="$canary"
wget -O - "https://dl.grafana.com/oss/master/grafana-${version}.linux-amd64.tar.gz" | tar -C /opt -zxf -
fi
/bin/rm -rf /opt/grafana > /dev/null 2>&1 || true
ln -s /opt/grafana-${version} /opt/grafana
# nohup /opt/grafana/bin/grafana-server -config /opt/grafana/conf/defaults.ini -homepath /opt/grafana >/dev/null 2>&1 &
#!/bin/bash
##
# Script to deploy a docker image. Must return exit code 0
#
do_exit() {
message="$1"
exit_code="$2"
echo "$message"
exit $exit_code
}
##
# Get file, get's a file, validates the SHA
# @param filename
# @param expected sha value
# @returns 0 if successful, -1 of checksum validation failed.
#
get_file () {
[ -n "$1" ] && url=$1 || do_exit "url required" -1
[ -n "$2" ] && dest=$2 || do_exit "destination required" -2
sha=$3
file=$(basename $dest)
wget "$url" -O "$dest"
if [ -n "$sha" ]; then
echo "$sha $dest" | sha256sum --check --status || do_exit "Checksum validation failed for $file. Exiting" -1
fi
}
untar_file () {
[ -n "$1" ] && src=$1 || do_exit "src required" -1
[ -n "$2" ] && dest=$2 || dest="/usr/local"
tar -C "$dest" -xf "$src" && /bin/rm -rf "$src"
}
\ No newline at end of file
#!/bin/bash
source "/etc/profile"
apt-get --allow-insecure-repositories update
apt-get install --allow-unauthenticated -y build-essential wget git sudo adduser libfontconfig1 locate libnss3 libnspr4 libgdk-pixbuf2.0-0 libgtk-3-0 libpangocairo-1.0-0 libpango-1.0-0 libatk1.0-0 libcairo2 libdbus-1-3 libxcomposite1 libxrender1 libxcursor1 libxi6 libxtst6 libxrandr2 libxss1 libasound2 libatk-bridge2.0-0 libatspi2.0-0 libcups2
#!/bin/bash
source "/etc/profile"
source "./deploy-slim.sh"
source "./deploy-common.sh"
NODEVER="v12.16.2-linux-x64"
# Install Node
wget -O - "https://nodejs.org/dist/v12.16.2/node-${NODEVER}.tar.xz" | tar Jvxf - -C "/tmp"
# Move node to /usr/local so it's in the path
pushd /tmp/node-${NODEVER}
/bin/rm -f CHANGELOG.md README.md LICENSE
/bin/cp -r * /usr/local
/bin/cp -r .??* /usr/local
popd
/bin/rm -rf /tmp/node-${NODEVER}
# Resource the profile so we know our path is being honoured
source "/etc/profile"
# Install Yarn. Not in the path yet so fully qualified
npm i -g yarn
# Install Go
filename="go1.14.linux-amd64.tar.gz"
get_file "https://dl.google.com/go/$filename" "/tmp/$filename" "08df79b46b0adf498ea9f320a0f23d6ec59e9003660b4c9c1ce8e5e2c6f823ca"
untar_file "/tmp/$filename"
# Install golangci-lint
filename="golangci-lint-1.23.7-linux-amd64.tar.gz"
get_file "https://github.com/golangci/golangci-lint/releases/download/v1.23.7/$filename" \
"/tmp/$filename" \
"34df1794a2ea8e168b3c98eed3cc0f3e13ed4cba735e4e40ef141df5c41bc086"
untar_file "/tmp/$filename"
chmod 755 /usr/local/bin/golangci-lint
ln -s /usr/local/golangci-lint-1.23.7-linux-amd64/golangci-lint /usr/local/bin/golangci-lint
ln -s /usr/local/go/bin/go /usr/local/bin/go
ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
# Install code climate
get_file "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64" \
"/usr/local/bin/cc-test-reporter" \
"38f2442892027f61a07f52c845818750261b2ba58bffb043a582495339d37c05"
chmod 755 /usr/local/bin/cc-test-reporter
# Install Mage
mkdir -pv /tmp/mage $HOME/go/bin
git clone https://github.com/magefile/mage.git /tmp/mage
pushd /tmp/mage && go run bootstrap.go && popd
mv $HOME/go/bin/mage /usr/local/bin
# Cleanup after yourself
/bin/rm -rf /tmp/mage
/bin/rm -rf $HOME/go
# Get the size down
/bin/rm -rf /var/lib/apt/lists
version: '3'
services:
citest:
image: "debian:buster-slim"
user: root
volumes:
- ../scripts:/root/scripts
- ../install:/root/install
- ${HOME}/.ssh:/root/.ssh
- ../../..:/root/grafana-toolkit
cibuilt:
image: "srclosson/grafana-plugin-ci-e2e"
user: root
volumes:
- ../scripts:/root/scripts
- ../install:/root/install
- ${HOME}/.ssh:/root/.ssh
- ../../..:/root/grafana-toolkit
#!/bin/bash
function finish {
echo "Exiting and cleaning up docker image"
docker-compose down
}
trap finish EXIT
# Enter the docker container
if [ "$1" = "built" ]; then
docker-compose run cibuilt sh -c "cd /root; exec bash --login -i"
else
docker-compose run citest sh -c "cd /root; exec bash --login -i"
fi
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