From ea1bff6c549b2185ee9a00cf7135941760ee51e2 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Thu, 5 Mar 2020 19:43:50 +0100 Subject: [PATCH] Follow up - 0798e7d47ed2505ea43dccdb9c1ef867d700f720 - moved from circle ci to github actions. Migrated CircleCI tests to GitHub Actions for testing Pull Requests. --- .github/ci.sh | 25 +++++++++++++++---------- .github/workflows/ci.yaml | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/.github/ci.sh b/.github/ci.sh index f008bb8d7..10306b3df 100755 --- a/.github/ci.sh +++ b/.github/ci.sh @@ -6,33 +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 +# 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 [ "${ZAMMAD_DBS}" == "postgresql" ]; then DB_ADAPTER="postgresql" + DB_USERNAME="postgres" + DB_PASSWORD="postgres" + DB_PORT="5432" INSTALL_OPTION="mysql" 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 rubocop +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 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 11cff71f4..f8d0b4f31 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,7 @@ name: ci -on: - pull_request: +on: + pull_request jobs: lint-bash-scripts: @@ -16,16 +16,41 @@ jobs: ci: runs-on: ubuntu-latest - needs: lint-scripts + 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: + env: + RAILS_ENV: test ZAMMAD_DBS: ${{ matrix.dbs }} steps: - name: Checkout uses: actions/checkout@v1 - - name: CI + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.5.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