added circle ci
Signed-off-by: André Bauer <monotek23@gmail.com>
This commit is contained in:
parent
575606981b
commit
6dc34f4f76
4 changed files with 163 additions and 0 deletions
67
.circleci/config.yml
Normal file
67
.circleci/config.yml
Normal file
|
@ -0,0 +1,67 @@
|
|||
version: 2.1
|
||||
jobs:
|
||||
lint-scripts:
|
||||
docker:
|
||||
- image: koalaman/shellcheck-alpine
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: lint-scripts
|
||||
command: .circleci/lint-scripts.sh
|
||||
|
||||
install-mysql:
|
||||
docker:
|
||||
- image: circleci/ruby:2.4.4
|
||||
- image: circleci/mysql:5.7-ram
|
||||
command: --max_allowed_packet=64MB
|
||||
environment:
|
||||
MYSQL_DATABASE: zammad_test
|
||||
MYSQL_USER: zammad_test
|
||||
MYSQL_PASSWORD: zammad_test
|
||||
environment:
|
||||
RAILS_ENV: test
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: install-mysql
|
||||
command: .circleci/install.sh
|
||||
|
||||
install-postgresql:
|
||||
docker:
|
||||
- image: circleci/ruby:2.4.4
|
||||
- image: circleci/postgres:11-ram
|
||||
environment:
|
||||
POSTGRES_DB: zammad_test
|
||||
POSTGRES_USER: zammad_test
|
||||
POSTGRES_PASSWORD: zammad_test
|
||||
environment:
|
||||
RAILS_ENV: test
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: install-postgresql
|
||||
command: .circleci/install.sh
|
||||
|
||||
docker-image-build:
|
||||
machine: true
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: docker-image-build
|
||||
command: .circleci/docker-image-build.sh
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
install_unittest_dockerbuild:
|
||||
jobs:
|
||||
- lint-scripts
|
||||
- install-mysql:
|
||||
requires:
|
||||
- lint-scripts
|
||||
- install-postgresql:
|
||||
requires:
|
||||
- lint-scripts
|
||||
- docker-image-build:
|
||||
requires:
|
||||
- install-mysql
|
||||
- install-postgresql
|
35
.circleci/docker-image-build.sh
Executable file
35
.circleci/docker-image-build.sh
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# build zammads docker & docker-compose images
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
REPO_USER="zammad"
|
||||
ZAMMAD_VERSION="$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g')"
|
||||
export ZAMMAD_VERSION
|
||||
|
||||
if [ "${CIRCLE_BRANCH}" == 'develop' ]; then
|
||||
DOCKER_REPOSITORY="zammad-docker"
|
||||
BUILD_SCRIPT="scripts/build_image.sh"
|
||||
elif [ "${CIRCLE_BRANCH}" == 'stable' ]; then
|
||||
DOCKER_REPOSITORY="zammad-docker-compose"
|
||||
BUILD_SCRIPT="hooks/build.sh"
|
||||
else
|
||||
echo "branch is ${CIRCLE_BRANCH}... no docker image build needed..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# dockerhub auth
|
||||
echo "${DOCKER_PASSWORD}" | docker login --username="${DOCKER_USERNAME}" --password-stdin
|
||||
|
||||
# clone docker repo
|
||||
git clone https://github.com/"${REPO_USER}"/"${DOCKER_REPOSITORY}"
|
||||
|
||||
# enter dockerfile dir
|
||||
cd "${REPO_ROOT}/${DOCKER_REPOSITORY}"
|
||||
|
||||
# build & push docker image
|
||||
# shellcheck disable=SC1090
|
||||
source "${REPO_ROOT}/${DOCKER_REPOSITORY}/${BUILD_SCRIPT}"
|
43
.circleci/install.sh
Executable file
43
.circleci/install.sh
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# install & unit test zammad
|
||||
#
|
||||
|
||||
exit 0
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
DB_CONFIG="test:\n adapter: postgresql\n database: zammad_test\n host: 127.0.0.1\n pool: 50\n timeout: 5000\n encoding: utf8\n username: zammad_test\n password: zammad_test"
|
||||
|
||||
# install build dependencies
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends autoconf automake autotools-dev bison build-essential curl git-core libffi-dev libgdbm-dev libgmp-dev libmariadbclient-dev-compat libncurses5-dev libreadline-dev libsqlite3-dev libssl-dev libtool libxml2-dev libxslt1-dev libyaml-0-2 libyaml-dev patch pkg-config postfix sqlite3 zlib1g-dev
|
||||
|
||||
if [ "${CIRCLE_JOB}" == "install-mysql" ]; then
|
||||
DB_ADAPTER="mysql2"
|
||||
INSTALL_OPTION="postgres"
|
||||
elif [ "${CIRCLE_JOB}" == "install-postgresql" ]; then
|
||||
DB_ADAPTER="postgresql"
|
||||
INSTALL_OPTION="mysql"
|
||||
else
|
||||
echo "nothing to do for circle ci job ${CIRCLE_JOB}..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# create db config
|
||||
echo -e "${DB_CONFIG}" | sed "s/adapter: postgresql/adapter: ${DB_ADAPTER}/g" > config/database.yml
|
||||
|
||||
# install zammad
|
||||
bundle install --without "${INSTALL_OPTION}"
|
||||
|
||||
# unit tests
|
||||
bundle exec rubocop
|
||||
rake db:migrate
|
||||
rake db:seed
|
||||
bundle exec rspec -t ~type:system
|
||||
bundle exec rake db:environment:set RAILS_ENV=test
|
||||
rake db:reset
|
||||
rake test:units
|
||||
ruby -I test/ test/integration/object_manager_test.rb
|
||||
ruby -I test/ test/integration/package_test.rb
|
18
.circleci/lint-scripts.sh
Executable file
18
.circleci/lint-scripts.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# lint bash scripts
|
||||
#
|
||||
|
||||
set -o errexit
|
||||
|
||||
CONFIG_DIR="./.circleci"
|
||||
TMP_FILE="$(mktemp)"
|
||||
|
||||
find "${CONFIG_DIR}" -type f -name "*.sh" > "${TMP_FILE}"
|
||||
|
||||
while read -r FILE; do
|
||||
echo lint "${FILE}"
|
||||
shellcheck -x "${FILE}"
|
||||
done < "${TMP_FILE}"
|
||||
|
||||
rm "${TMP_FILE}"
|
Loading…
Reference in a new issue