diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..dc6a6623e --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/.circleci/docker-image-build.sh b/.circleci/docker-image-build.sh new file mode 100755 index 000000000..b744ad6ff --- /dev/null +++ b/.circleci/docker-image-build.sh @@ -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}" diff --git a/.circleci/install.sh b/.circleci/install.sh new file mode 100755 index 000000000..4eccd04e4 --- /dev/null +++ b/.circleci/install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# install & unit test zammad +# + +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 diff --git a/.circleci/lint-scripts.sh b/.circleci/lint-scripts.sh new file mode 100755 index 000000000..da44ac63e --- /dev/null +++ b/.circleci/lint-scripts.sh @@ -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}" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d4adaadc4..000000000 --- a/.travis.yml +++ /dev/null @@ -1,70 +0,0 @@ -dist: xenial -sudo: false -notifications: - email: - - me+tv@zammad.com -env: - - DB=mysql - - DB=postgresql -addons: - apt: - packages: - - autoconf - - automake - - autotools-dev - - bison - - build-essential - - curl - - git-core - - libffi-dev - - libgdbm-dev - - libgmp-dev - - libmysqlclient-dev - - 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 -services: - - mysql - - postgresql -language: ruby -rvm: - - 2.4.4 -before_install: - - gem update --system # Due to: https://github.com/travis-ci/travis-ci/issues/8978 - - git fetch --unshallow - - if [ "${DB}" = "mysql" ]; then mysql -u root -e "CREATE USER 'some_user'@'localhost' IDENTIFIED BY 'some_pass';"; fi - - if [ "${DB}" = "mysql" ]; then mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'localhost';"; fi - - if [ "${DB}" = "mysql" ]; then cp contrib/travis-ci.org/database.yml.test-mysql config/database.yml; fi - - if [ "${DB}" = "postgresql" ]; then psql -c 'create database zammad_test;' -U postgres; fi - - if [ "${DB}" = "postgresql" ]; then cp contrib/travis-ci.org/database.yml.test-postgresql config/database.yml; fi - - export RAILS_ENV=test - - export ZAMMAD_VERSION=$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g') -install: - - if [ "${DB}" = "mysql" ]; then bundle install --without postgres; fi - - if [ "${DB}" = "postgresql" ]; then bundle install; fi -script: - - bundle exec rubocop - - rake db:create - - 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 -after_success: - - if [ "${DB}" = "mysql" ]; then contrib/travis-ci.org/trigger_docker_image_build.sh; fi - - if [ "${DB}" = "mysql" ]; then contrib/travis-ci.org/trigger_docker_image_compose_build.sh; fi - - if [ "${DB}" = "mysql" ]; then contrib/travis-ci.org/trigger_docker_image_univention_build.sh; fi diff --git a/README.md b/README.md index ae977c35e..9871f97d9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Zammad is a web based open source helpdesk/customer support system with many features to manage customer communication via several channels like telephone, -facebook, twitter, chat and e-mails. It is distributed under version 3 of the +facebook, twitter, chat and e-mails. It is distributed under version 3 of the GNU AFFERO General Public License (GNU AGPLv3). Do you receive many e-mails and want to answer them with a team of agents? @@ -11,7 +11,7 @@ You're going to love Zammad! ## Status -- Build: [![Build Status](https://travis-ci.org/zammad/zammad.svg?branch=develop)](https://travis-ci.org/zammad/zammad) +- Build: [![Build Status](https://circleci.com/gh/zammad/zammad.svg?style=svg)](https://circleci.com/gh/zammad/zammad) - Code: [![Code Climate](https://codeclimate.com/github/zammad/zammad/badges/gpa.svg)](https://codeclimate.com/github/zammad/zammad) [![Coverage Status](https://coveralls.io/repos/github/zammad/zammad/badge.svg)](https://coveralls.io/github/zammad/zammad) - Docs: [![Documentation Status](https://readthedocs.org/projects/zammad/badge/)](https://docs.zammad.org) - Issues: [![Percentage of issues still open](http://isitmaintained.com/badge/open/zammad/zammad.svg)](https://github.com/zammad/zammad/issues "Percentage of issues still open") [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/zammad/zammad.svg)](https://github.com/zammad/zammad/issues?q=is%3Aissue+is%3Aclosed "Average time to resolve an issue") @@ -44,4 +44,3 @@ https://zammad.org/participate Thanks! ❤️ ❤️ ❤️ Your Zammad Team - diff --git a/contrib/travis-ci.org/database.yml.test-mysql b/contrib/travis-ci.org/database.yml.test-mysql deleted file mode 100644 index f6b525b4c..000000000 --- a/contrib/travis-ci.org/database.yml.test-mysql +++ /dev/null @@ -1,11 +0,0 @@ -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: mysql2 - database: zammad_test - pool: 50 - timeout: 5000 - encoding: utf8 - username: some_user - password: some_pass diff --git a/contrib/travis-ci.org/database.yml.test-postgresql b/contrib/travis-ci.org/database.yml.test-postgresql deleted file mode 100644 index bda094235..000000000 --- a/contrib/travis-ci.org/database.yml.test-postgresql +++ /dev/null @@ -1,11 +0,0 @@ -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: postgresql - database: zammad_test - pool: 50 - timeout: 5000 - encoding: utf8 - username: postgres - password: diff --git a/contrib/travis-ci.org/trigger_docker_image_build.sh b/contrib/travis-ci.org/trigger_docker_image_build.sh deleted file mode 100755 index f27972919..000000000 --- a/contrib/travis-ci.org/trigger_docker_image_build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# trigger build of https://github.com/zammad/zammad-docker on https://travis-ci.org/zammad/zammad-docker and upload it to https://hub.docker.com/r/zammad/zammad -# - -REPO_USER="zammad" -REPO="zammad-docker" -BRANCH="master" - -if [ "${TRAVIS_BRANCH}" == 'develop' ]; then - curl -X POST \ - -H "Content-Type: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Accept: application/json" \ - -H "Authorization: token ${TRAVIS_API_TOKEN}" \ - -d '{"request":{ "message": "'"${TRAVIS_COMMIT_MESSAGE}"'","branch":"'${BRANCH}'","config":{"env":{"ZAMMAD_VERSION":"'${ZAMMAD_VERSION}'"}}}}' \ - "https://api.travis-ci.org/repo/${REPO_USER}%2F${REPO}/requests" -fi diff --git a/contrib/travis-ci.org/trigger_docker_image_compose_build.sh b/contrib/travis-ci.org/trigger_docker_image_compose_build.sh deleted file mode 100755 index 2b209d5be..000000000 --- a/contrib/travis-ci.org/trigger_docker_image_compose_build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# trigger build of https://github.com/zammad/zammad-docker-compose on https://travis-ci.org/zammad/zammad-docker-compose and upload it to https://hub.docker.com/r/zammad/zammad-docker-compose/ -# - -REPO_USER="zammad" -REPO="zammad-docker-compose" -BRANCH="master" - -if [ "${TRAVIS_BRANCH}" == 'stable' ]; then - curl -X POST \ - -H "Content-Type: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Accept: application/json" \ - -H "Authorization: token ${TRAVIS_API_TOKEN}" \ - -d '{"request":{ "message": "'"${TRAVIS_COMMIT_MESSAGE}"'","branch":"'${BRANCH}'","config":{"env":{"ZAMMAD_VERSION":"'${ZAMMAD_VERSION}'"}}}}' \ - "https://api.travis-ci.org/repo/${REPO_USER}%2F${REPO}/requests" -fi diff --git a/contrib/travis-ci.org/trigger_docker_image_univention_build.sh b/contrib/travis-ci.org/trigger_docker_image_univention_build.sh deleted file mode 100755 index 0e83bc280..000000000 --- a/contrib/travis-ci.org/trigger_docker_image_univention_build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# trigger build of https://github.com/zammad/zammad-docker-univention on https://travis-ci.org/zammad/zammad-docker-univention and upload it to https://hub.docker.com/r/zammad/zammad-docker-univention -# - -REPO_USER="zammad" -REPO="zammad-docker-univention" -BRANCH="master" - -if [ "${TRAVIS_BRANCH}" == 'stable' ]; then - curl -X POST \ - -H "Content-Type: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Accept: application/json" \ - -H "Authorization: token ${TRAVIS_API_TOKEN}" \ - -d '{"request":{ "message": "'"${TRAVIS_COMMIT_MESSAGE}"'","branch":"'${BRANCH}'","config":{"env":{"ZAMMAD_VERSION":"'${ZAMMAD_VERSION}'"}}}}' \ - "https://api.travis-ci.org/repo/${REPO_USER}%2F${REPO}/requests" -fi