From 9823c578a50a4d7ffae18fadee8e305ab64e2fbc Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Tue, 1 Dec 2020 07:49:38 +0100 Subject: [PATCH] Switching from travis to github actions for testing --- .../workflows/{rubocop.yml => linters.yml} | 21 ++- .github/workflows/tests.yml | 132 +++++++++++++++--- .slim-lint.yml | 37 +++++ .travis.yml | 47 ------- CHANGELOG.md | 5 + README.md | 2 +- app/models/messenger.rb | 5 +- config/routes.rb | 11 +- init.rb | 2 +- lib/redmine_messenger/version.rb | 3 + test/support/Gemfile.local | 3 - test/support/additional_environment.rb | 4 - test/support/configuration.yml | 6 + test/support/database-mysql-travis.yml | 8 -- test/support/database-mysql.yml | 26 ++++ test/support/database-postgres.yml | 23 +++ test/support/database-postgresql-travis.yml | 8 -- 17 files changed, 240 insertions(+), 103 deletions(-) rename .github/workflows/{rubocop.yml => linters.yml} (65%) delete mode 100644 .travis.yml create mode 100644 lib/redmine_messenger/version.rb delete mode 100644 test/support/Gemfile.local delete mode 100644 test/support/additional_environment.rb create mode 100644 test/support/configuration.yml delete mode 100644 test/support/database-mysql-travis.yml create mode 100644 test/support/database-mysql.yml create mode 100644 test/support/database-postgres.yml delete mode 100644 test/support/database-postgresql-travis.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/linters.yml similarity index 65% rename from .github/workflows/rubocop.yml rename to .github/workflows/linters.yml index df0a55a..7fa9200 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/linters.yml @@ -1,10 +1,12 @@ -name: Run RuboCop - -on: [push] +name: Run Linters +on: + push: + pull_request: + schedule: + - cron: '30 5 * * *' jobs: - build: - + test: runs-on: ubuntu-latest steps: @@ -19,10 +21,12 @@ jobs: run: | echo "">> Gemfile echo "group :test do">> Gemfile + echo " gem 'pandoc-ruby', require: false" >> Gemfile echo " gem 'rubocop', require: false" >> Gemfile echo " gem 'rubocop-performance', require: false" >> Gemfile echo " gem 'rubocop-rails', require: false" >> Gemfile - echo "end">> Gemfile + echo " gem 'slim_lint', require: false" >> Gemfile + echo "end" >> Gemfile - name: Setup gems run: | @@ -32,3 +36,8 @@ jobs: - name: Run RuboCop run: | bundle exec rubocop -S + + - name: Run Slim-Lint + run: | + bundle exec slim-lint app/views + if: always() diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1cc68b1..7f4e661 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Run Tests +name: Tests on: push: pull_request: @@ -7,25 +7,125 @@ on: jobs: test: + name: ${{ matrix.redmine }} ${{ matrix.db }} ruby-${{ matrix.ruby }} runs-on: ubuntu-latest strategy: matrix: - redmine: - - v4.0 - - v4.1 - - trunk - ruby: - - v2.4 - - v2.6 - database: - - sqlite3 - - postgres + ruby: ['2.6', '2.4'] + redmine: ['4.1-stable', 'master'] + db: ['postgres', 'mysql'] + fail-fast: false + + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + mysql: + image: mysql:5.7 + env: + MYSQL_USER: root + MYSQL_PASSWORD: '' + MYSQL_ALLOW_EMPTY_PASSWORD: yes + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 steps: - - name: Redmine plugin test - uses: two-pack/redmine-plugin-test-action@v2 + - name: Verify MySQL connection from host + run: | + mysql --host 127.0.0.1 --port 3306 -uroot -e "SHOW DATABASES" + if: matrix.db == 'mysql' + + - name: Checkout Redmine + uses: actions/checkout@v2 with: - plugin_name: redmine_messenger - redmine_version: ${{ matrix.redmine }} - ruby_version: ${{ matrix.ruby }} + repository: redmine/redmine + ref: ${{ matrix.redmine }} + path: redmine + + - name: Checkout redmine_messenger + uses: actions/checkout@v2 + with: + repository: AlphaNodes/redmine_messenger + path: redmine/plugins/redmine_messenger + + - name: Update package archives + run: sudo apt-get update --yes --quiet + + - name: Install package dependencies + run: > + sudo apt-get install --yes --quiet + build-essential + cmake + libicu-dev + libpq-dev + libmysqlclient-dev + + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + architecture: 'x64' + + - name: Setup Cache + uses: actions/cache@v1 + with: + path: vendor + key: v1-ruby-${{ matrix.ruby }}-redmine-${{ matrix.redmine }} + + - name: Setup Bundler + run: | + gem install bundler -v '~> 1.0' + bundle config path "$(pwd)/vendor/bundle" + + - name: Prepare Redmine source + working-directory: redmine + run: | + sed -i '/rubocop/d' Gemfile + rm -f .rubocop* + cp plugins/redmine_messenger/test/support/database-${{ matrix.db }}.yml config/database.yml + cp plugins/redmine_messenger/test/support/configuration.yml config/configuration.yml + + - name: Install Ruby dependencies + working-directory: redmine + run: | + bundle install --jobs=4 --retry=3 --without development + + - name: Run Redmine rake tasks + env: + RAILS_ENV: test + working-directory: redmine + run: | + bundle exec rake generate_secret_token + bundle exec rake db:create db:migrate redmine:plugins:migrate + bundle exec rake db:test:prepare + + - name: Run tests + env: + RAILS_ENV: test + REDMINE_VERSION: ${{ matrix.redmine }} + working-directory: redmine + run: bundle exec rake redmine:plugins:test NAME=redmine_messenger RUBYOPT="-W0" + + - name: Run uninstall test + env: + RAILS_ENV: test + REDMINE_VERSION: ${{ matrix.redmine }} + working-directory: redmine + run: bundle exec rake redmine:plugins:migrate NAME=redmine_messenger VERSION=0 diff --git a/.slim-lint.yml b/.slim-lint.yml index e770df4..54689e6 100644 --- a/.slim-lint.yml +++ b/.slim-lint.yml @@ -1,3 +1,40 @@ linters: LineLength: max: 140 + RuboCop: + ignored_cops: + - Layout/ArgumentAlignment + - Layout/ArrayAlignment + - Layout/BlockEndNewline + - Layout/EmptyLineAfterGuardClause + - Layout/HashAlignment + - Layout/IndentationConsistency + - Layout/IndentationWidth + - Layout/IndentFirstArgument + - Layout/IndentFirstArrayElement + - Layout/IndentFirstHashElement + - Layout/MultilineArrayBraceLayout + - Layout/MultilineAssignmentLayout + - Layout/MultilineBlockLayout + - Layout/MultilineHashBraceLayout + - Layout/MultilineMethodCallBraceLayout + - Layout/MultilineMethodCallIndentation + - Layout/MultilineMethodDefinitionBraceLayout + - Layout/MultilineOperationIndentation + - Layout/TrailingBlankLines + - Layout/TrailingEmptyLines + - Layout/TrailingWhitespace + - Lint/BlockAlignment + - Lint/EndAlignment + - Lint/Void + - Metrics/BlockLength + - Metrics/BlockNesting + - Metrics/LineLength + - Naming/FileName + - Rails/OutputSafety + - Style/ConditionalAssignment + - Style/FrozenStringLiteralComment + - Style/IdenticalConditionalBranches + - Style/IfUnlessModifier + - Style/Next + - Style/WhileUntilModifier diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 46108a8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -language: ruby -os: linux -dist: xenial - -rvm: - - 2.6.6 - - 2.5.8 - - 2.4.10 - -services: - - mysql - - postgresql - -env: - - REDMINE_VER=4.0-stable DB=postgresql - - REDMINE_VER=master DB=postgresql - - REDMINE_VER=4.0-stable DB=mysql - - REDMINE_VER=master DB=mysql - -notifications: - webhooks: - urls: - secure: "lwJzu9BU7AVhHnROzEA6agagwsqVAaTzgtvwTlw4CwSUv0ypNXNi9kjJUvOgSit3BnkSccC9xYlYNOYw5OOmsmjyUDU4/LUVqd0DRQjW3FXU9EFFPGQq9srJikHOHobfnutxGwMYFE4ftLI08PzsL7bYEg39Ps3pwwWsiIKnKKI0DPmdQH5PzC63jF/EByrLZsfqGHOirgXDnxmwgmrQ14vOpp3lHjgNgx9wNALpSgAztKeK1Wd8KayLYXweu+LQx9IwJfLqvk6hhWW15vjkIhvK7ooYSGXx+Hlwg3jyFSyX5jButUT4vwlWdJeAoNO/sWpdKXv4AifGXYsbcF/LMHCaaVgwBm/pe/YlK2LrqFlpm7MFuqyO1w4AnIA7rC8wZp/dUU5bJITZgN3sTAbLyTIbF8cbMfbDy3IWP8Oub7K/0ATUD7vNBVuyxfdGG61xOv/RDQhzrGwUArJ/xJfdU77MZkQUnaGb0vcwmRLIxyPdZWPz9ntzCbBxFblPWApCw+CWOeM3OuR6tdVqSVuZx3aG87TTzW+S9lLe8PJ5HYgA6+rPkc04zolJMftnFVlUl3LQIKvV2QkPSnr9bcePR5YSoJJKLBVofUsg/btVkQ1OxhWn53Td/nQp7u8qosmyQjCjMiP6Po1e9Enr89FY8Yxkw2dQba5sumQRbB39bj0=" - on_success: change - on_failure: always - -before_install: - - export PLUGIN_NAME=redmine_messenger - - export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git - - export REDMINE_PATH=$HOME/redmine - - export BUNDLE_GEMFILE=$REDMINE_PATH/Gemfile - - export RAILS_ENV=test - - git clone $REDMINE_GIT_REPO $REDMINE_PATH - - cd $REDMINE_PATH - - if [[ "$REDMINE_VER" != "master" ]]; then git checkout -b $REDMINE_VER origin/$REDMINE_VER; fi - - if [[ "$REDMINE_VER" != "master" ]]; then cp $TRAVIS_BUILD_DIR/test/support/Gemfile.local $REDMINE_PATH; fi - - ln -s $TRAVIS_BUILD_DIR $REDMINE_PATH/plugins/$PLUGIN_NAME - - cp $TRAVIS_BUILD_DIR/test/support/additional_environment.rb $REDMINE_PATH/config/ - - cp $TRAVIS_BUILD_DIR/test/support/database-$DB-travis.yml $REDMINE_PATH/config/database.yml - -before_script: - - bundle exec rake db:create db:migrate redmine:plugins:migrate - -script: - - if [[ "$REDMINE_VER" != "master" ]] && [[ "$DB" == "postgresql" ]]; then rubocop plugins/$PLUGIN_NAME; fi - - bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0" - - bundle exec rake redmine:plugins:migrate NAME=$PLUGIN_NAME VERSION=0 diff --git a/CHANGELOG.md b/CHANGELOG.md index dcdbfc6..7d7c967 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +1.0.8 +----- + +- Drop testing with travis - we use github actions + 1.0.7 ----- - Added feature to send messages directly to users to be notified - thanks to @Ujifman diff --git a/README.md b/README.md index e299671..deb6b38 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Messenger plugin for Redmine This plugin posts updates to issues in your Redmine installation to [Slack](https://slack.com/), [Rocket.Chat](https://rocket.chat/), [Discord](https://discordapp.com/) or [Mattermost](https://about.mattermost.com/) channel. -[![Rate at redmine.org](https://img.shields.io/badge/rate%20at-redmine.org-blue.svg?style=fla)](https://www.redmine.org/plugins/redmine_messenger) [![Build Status](https://travis-ci.org/AlphaNodes/redmine_messenger.svg?branch=master)](https://travis-ci.org/AlphaNodes/redmine_messenger) ![Run RuboCop](https://github.com/AlphaNodes/redmine_messenger/workflows/Run%20RuboCop/badge.svg) ![Run Tests](https://github.com/AlphaNodes/redmine_messenger/workflows/Run%20Tests/badge.svg) +[![Rate at redmine.org](https://img.shields.io/badge/rate%20at-redmine.org-blue.svg?style=fla)](https://www.redmine.org/plugins/redmine_messenger) [![Run Tests](https://github.com/AlphaNodes/redmine_messenger/workflows/Tests/badge.svg))](https://github.com/AlphaNodes/redmine_messenger/actions?query=workflow%3A"Run+Tests) [![Run Linters](https://github.com/AlphaNodes/redmine_messenger/workflows/Run%20Linters/badge.svg)](https://github.com/AlphaNodes/redmine_messenger/actions?query=workflow%3A%22Run+Linters%22) Features -------- diff --git a/app/models/messenger.rb b/app/models/messenger.rb index 5c5f721..cce9402 100644 --- a/app/models/messenger.rb +++ b/app/models/messenger.rb @@ -199,9 +199,10 @@ class Messenger end else key = detail.prop_key.to_s.sub('_id', '') - title = if key == 'parent' + title = case key + when 'parent' I18n.t "field_#{key}_issue" - elsif key == 'copied_from' + when 'copied_from' I18n.t "label_#{key}" else I18n.t "field_#{key}" diff --git a/config/routes.rb b/config/routes.rb index fc41ecd..4d63236 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,5 @@ -# Plugin's routes -# See: http://guides.rubyonrails.org/routing.html - -# Don't create routes for repositories resources with only: [] -# do not override Redmine's routes. -resources :projects, only: [] do - resource :messenger_setting, only: %i[show update] +Rails.application.routes.draw do + resources :projects, only: [] do + resource :messenger_setting, only: %i[show update] + end end diff --git a/init.rb b/init.rb index a29d2d3..7912a17 100644 --- a/init.rb +++ b/init.rb @@ -6,7 +6,7 @@ Redmine::Plugin.register :redmine_messenger do url 'https://github.com/alphanodes/redmine_messenger' author_url 'https://alphanodes.com/' description 'Messenger integration for Slack, Discord, Rocketchat and Mattermost support' - version '1.0.7' + version RedmineMessenger::VERSION requires_redmine version_or_higher: '4.0.0' diff --git a/lib/redmine_messenger/version.rb b/lib/redmine_messenger/version.rb new file mode 100644 index 0000000..ef65ad6 --- /dev/null +++ b/lib/redmine_messenger/version.rb @@ -0,0 +1,3 @@ +module RedmineMessenger + VERSION = '1.0.8-master'.freeze +end diff --git a/test/support/Gemfile.local b/test/support/Gemfile.local deleted file mode 100644 index aad214b..0000000 --- a/test/support/Gemfile.local +++ /dev/null @@ -1,3 +0,0 @@ -gem 'rubocop', require: false -gem 'rubocop-performance', require: false -gem 'rubocop-rails', require: false diff --git a/test/support/additional_environment.rb b/test/support/additional_environment.rb deleted file mode 100644 index 0b0cde6..0000000 --- a/test/support/additional_environment.rb +++ /dev/null @@ -1,4 +0,0 @@ -# for travis debugging -# config.logger = Logger.new(STDOUT) -# config.logger.level = Logger::INFO -# config.log_level = :info diff --git a/test/support/configuration.yml b/test/support/configuration.yml new file mode 100644 index 0000000..28ca087 --- /dev/null +++ b/test/support/configuration.yml @@ -0,0 +1,6 @@ +# = Redmine configuration file + +# default configuration options for all environments +default: + sudo_mode: false + sudo_mode_timeout: 1 diff --git a/test/support/database-mysql-travis.yml b/test/support/database-mysql-travis.yml deleted file mode 100644 index 2acc077..0000000 --- a/test/support/database-mysql-travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -test: - adapter: mysql2 - database: travis_ci_test - host: localhost - username: root - password: - pool: 5 - encoding: utf8mb4 diff --git a/test/support/database-mysql.yml b/test/support/database-mysql.yml new file mode 100644 index 0000000..160f66c --- /dev/null +++ b/test/support/database-mysql.yml @@ -0,0 +1,26 @@ +production: + adapter: mysql2 + database: redmine + host: 127.0.0.1 + port: 3306 + username: root + password: + encoding: utf8mb4 + +development: + adapter: mysql2 + database: redmine + port: 3306 + host: 127.0.0.1 + username: root + password: + encoding: utf8mb4 + +test: + adapter: mysql2 + database: redmine + port: 3306 + host: 127.0.0.1 + username: root + password: + encoding: utf8mb4 diff --git a/test/support/database-postgres.yml b/test/support/database-postgres.yml new file mode 100644 index 0000000..97802de --- /dev/null +++ b/test/support/database-postgres.yml @@ -0,0 +1,23 @@ +production: + adapter: postgresql + host: localhost + database: redmine + username: postgres + password: postgres + encoding: utf8 + +development: + adapter: postgresql + host: localhost + database: redmine + username: postgres + password: postgres + encoding: utf8 + +test: + adapter: postgresql + host: localhost + database: redmine + username: postgres + password: postgres + encoding: utf8 diff --git a/test/support/database-postgresql-travis.yml b/test/support/database-postgresql-travis.yml deleted file mode 100644 index a118b62..0000000 --- a/test/support/database-postgresql-travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -test: - adapter: postgresql - encoding: unicode - pool: 5 - database: travis_ci_test - user: postgres - -