Skip to content

Commit

Permalink
Merge pull request #1 from zammad/develop
Browse files Browse the repository at this point in the history
promote
  • Loading branch information
boie0025 authored Aug 14, 2020
2 parents 209951b + 03a6077 commit 8c19277
Show file tree
Hide file tree
Showing 1,297 changed files with 87,541 additions and 32,182 deletions.
67 changes: 0 additions & 67 deletions .circleci/config.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .circleci/docker-image-build.sh

This file was deleted.

30 changes: 16 additions & 14 deletions .circleci/install.sh → .github/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,38 @@
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 libimlib2 libimlib2-dev

if [ "${CIRCLE_JOB}" == "install-mysql" ]; then
# create db config
DB_CONFIG="test:\n adapter: postgresql\n database: zammad_test\n host: 127.0.0.1\n port: DB_PORT\n pool: 50\n timeout: 5000\n encoding: utf8\n username: DB_USERNAME\n password: DB_PASSWORD"

if [ "${ZAMMAD_DBS}" == "mysql" ]; then
DB_ADAPTER="mysql2"
DB_USERNAME="root"
DB_PASSWORD="password"
DB_PORT="13306"
INSTALL_OPTION="postgres"
elif [ "${CIRCLE_JOB}" == "install-postgresql" ]; then
elif [ "${ZAMMAD_DBS}" == "postgresql" ]; then
DB_ADAPTER="postgresql"
DB_USERNAME="postgres"
DB_PASSWORD="postgres"
DB_PORT="5432"
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
echo -e "${DB_CONFIG}" | sed -e "s/adapter: postgresql/adapter: ${DB_ADAPTER}/g" -e "s/DB_USERNAME/${DB_USERNAME}/g" -e "s/DB_PASSWORD/${DB_PASSWORD}/g" -e "s/DB_PORT/${DB_PORT}/g" > config/database.yml

# install zammad
gem install bundler:1.7.3
bundle install --without "${INSTALL_OPTION}"

# unit tests
bundle exec rubocop
rake db:migrate
rake db:seed
bundle exec rake zammad:db:init
bundle exec rspec -t ~type:system -t ~searchindex
bundle exec rake db:environment:set RAILS_ENV=test
rake db:reset
rake test:units
bundle exec rake zammad:db:reset
bundle exec rake test:units
ruby -I test/ test/integration/object_manager_test.rb
ruby -I test/ test/integration/package_test.rb
39 changes: 39 additions & 0 deletions .github/docker-image-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
#
# build zammads docker & docker-compose images

set -o errexit
set -o pipefail

DOCKER_REGISTRY="index.docker.io"
REPO_ROOT="$(git rev-parse --show-toplevel)"
ZAMMAD_VERSION="$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g')"

# dockerhub auth
echo "${DOCKER_PASSWORD}" | docker login --username="${DOCKER_USERNAME}" --password-stdin

# clone docker repo
DOCKER_REPOSITORY_CLONE_URL="https://github.com/${REPO_USER}/${DOCKER_GITHUB_REPOSITORY}"
echo "Cloning ${DOCKER_REPOSITORY_CLONE_URL}"
git clone "${DOCKER_REPOSITORY_CLONE_URL}"

# enter dockerfile dir
cd "${REPO_ROOT}/${DOCKER_GITHUB_REPOSITORY}"

# shellcheck disable=SC2153
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
echo "Build Zammad Docker image ${DOCKER_IMAGE} with version ${ZAMMAD_VERSION} for DockerHubs ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY} repo"

if [ "${DOCKER_REPOSITORY}" == "zammad-docker-compose" ]; then
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}" -t "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-latest" -t "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${ZAMMAD_VERSION}" -f "containers/${DOCKER_IMAGE}/Dockerfile" .

docker push "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}"
docker push "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-latest"
docker push "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${ZAMMAD_VERSION}"
else
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:latest" -t "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${ZAMMAD_VERSION}" .

docker push "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:latest"
docker push "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${ZAMMAD_VERSION}"
fi
done
4 changes: 2 additions & 2 deletions .circleci/lint-scripts.sh → .github/lint-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

set -o errexit

CONFIG_DIR="./.circleci"
CONFIG_DIR=".github"

TMP_FILE="$(mktemp)"

find "${CONFIG_DIR}" -type f -name "*.sh" > "${TMP_FILE}"
Expand All @@ -15,4 +16,3 @@ while read -r FILE; do
shellcheck -x "${FILE}"
done < "${TMP_FILE}"

rm "${TMP_FILE}"
24 changes: 24 additions & 0 deletions .github/workflows/build-docker-compose-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build-docker-compose-images

on:
push:
branches: [stable**]

jobs:
build-docker-compose-images:
runs-on: ubuntu-latest
env:
DOCKER_GITHUB_REPOSITORY: "zammad-docker-compose"
DOCKER_IMAGES: "zammad zammad-elasticsearch zammad-postgresql"
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REPOSITORY: "zammad-docker-compose"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
steps:
- name: Extract REPO_USER from GITHUB_REPOSITORY ENV
run: echo "::set-env name=REPO_USER::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $1}')"
- name: Checkout code
uses: actions/checkout@master
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Build docker image
run: .github/docker-image-build.sh
24 changes: 24 additions & 0 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build-docker-image

on:
push:
branches: [develop]

jobs:
build-docker-image:
runs-on: ubuntu-latest
env:
DOCKER_GITHUB_REPOSITORY: "zammad-docker"
DOCKER_IMAGES: "zammad"
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REPOSITORY: "zammad"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
steps:
- name: Extract REPO_USER from GITHUB_REPOSITORY ENV
run: echo "::set-env name=REPO_USER::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $1}')"
- name: Checkout code
uses: actions/checkout@master
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Build docker image
run: .github/docker-image-build.sh
56 changes: 56 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ci

on:
pull_request

jobs:
lint-bash-scripts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Lint Bash scripts
uses: docker://koalaman/shellcheck-alpine:v0.7.0
with:
args: .github/lint-scripts.sh

ci:
runs-on: ubuntu-latest
needs: lint-bash-scripts
services:
mysql:
image: mysql:5
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 13306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
matrix:
dbs:
- mysql
- postgresql
env:
RAILS_ENV: test
ZAMMAD_DBS: ${{ matrix.dbs }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.5
- name: Increase MySQL max_allowed_packet to 1GB (workaround for unknown/missing service option)
run: |
sudo apt-get install -y mysql-client
mysql --host 127.0.0.1 --port 13306 -uroot -ppassword -e "SET GLOBAL max_allowed_packet=1073741824;"
- name: CI
run: .github/ci.sh
Loading

0 comments on commit 8c19277

Please sign in to comment.