From 7b0cb142ff0f55907150b6853a3522fa9ad91d38 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 10 Apr 2021 09:43:52 +0900 Subject: [PATCH 01/18] Add redmine 4.2-stable, ruby2.7. Remove ruby 2.3 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 379b668..b56618e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: ruby rvm: -- 2.3 - 2.4 - 2.5 - 2.6 +- 2.7 env: -- REDMINE_VER=4.1-stable +- REDMINE_VER=4.2-stable - REDMINE_VER=master script: - export TESTSPACE=`pwd`/testspace From db232d8eb0ccd3f635c75f629ccb1684d591d01e Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 10 Apr 2021 09:52:09 +0900 Subject: [PATCH 02/18] Drop ruby 2.4 in Redmine master --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index b56618e..9ed92ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,10 @@ rvm: env: - REDMINE_VER=4.2-stable - REDMINE_VER=master +matrix: + exclude: + - rvm: 2.4 + env: REDMINE_VER=master script: - export TESTSPACE=`pwd`/testspace - export NAME_OF_PLUGIN=redmine_logs From 99f8c159eff30387818ff20d3b03319a274eaf04 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 10 Apr 2021 09:58:23 +0900 Subject: [PATCH 03/18] Add ruby 3.0 in Redmine master --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9ed92ff..29f3f24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ rvm: - 2.5 - 2.6 - 2.7 +- 3.0 env: - REDMINE_VER=4.2-stable - REDMINE_VER=master @@ -11,6 +12,8 @@ matrix: exclude: - rvm: 2.4 env: REDMINE_VER=master + - rvm: 3.0 + env: REDMINE_VER=4.2-stable script: - export TESTSPACE=`pwd`/testspace - export NAME_OF_PLUGIN=redmine_logs From a47797ae15bcf7d269347654c612704841fbd9fa Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Fri, 10 Sep 2021 23:07:56 +0900 Subject: [PATCH 04/18] Github Actions --- .github/workflows/build.yml | 64 ++++++++++++++++++++++++++++++ Gemfile_for_test | 2 +- build-scripts/build.sh | 20 ++++++++++ build-scripts/database.yml | 43 +++++++++++++++++++++ build-scripts/env.sh | 5 +++ build-scripts/install.sh | 77 +++++++++++++++++++++++++++++++++++++ test/test_helper.rb | 9 ++++- 7 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 build-scripts/build.sh create mode 100644 build-scripts/database.yml create mode 100644 build-scripts/env.sh create mode 100644 build-scripts/install.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b341c7a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,64 @@ +name: build +on: [push] +env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + db: [sqlite3, mysql, postgres] + ruby_version: [2.4, 2.5, 2.6, 2.7, 3.0] + redmine_version: [4.1-stable, 4.2-stable, master] + exclude: + - ruby_version: 2.4 + redmine_version: master + - ruby_version: 2.7 + redmine_version: 4.1-stable + - ruby_version: 3.0 + redmine_version: 4.1-stable + - ruby_version: 3.0 + redmine_version: 4.2-stable + services: + mysql: + image: mysql:5.7 + options: --health-cmd "mysqladmin ping -h localhost" --health-interval 20s --health-timeout 10s --health-retries 10 + env: + MYSQL_ROOT_PASSWORD: dbpassword + postgres: + image: postgres + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: dbpassword + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + container: + image: ruby:${{ matrix.ruby_version }} + env: + DB: ${{ matrix.db }} + DB_USERNAME: root + DB_PASSWORD: dbpassword + DB_HOST: ${{ matrix.db }} + REDMINE_VER: ${{ matrix.redmine_version }} + steps: + - uses: actions/checkout@v2 + - name: Install + run: bash -x ./build-scripts/install.sh + - name: Build + run: bash -x ./build-scripts/build.sh + - name: Coveralls GitHub Action + if: ${{ matrix.redmine_version == 'master' && matrix.db == 'mysql' }} + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.0.2 + if: failure() + env: + SLACK_CHANNEL: plugin-logs + SLACK_TITLE: Test Failure + SLACK_COLOR: danger + diff --git a/Gemfile_for_test b/Gemfile_for_test index e1ee3b1..6318fd2 100644 --- a/Gemfile_for_test +++ b/Gemfile_for_test @@ -2,5 +2,5 @@ source :rubygems group :test do gem "simplecov-rcov" - gem 'coveralls', :require => false + gem 'simplecov-lcov' end \ No newline at end of file diff --git a/build-scripts/build.sh b/build-scripts/build.sh new file mode 100644 index 0000000..fc9fd21 --- /dev/null +++ b/build-scripts/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +cd `dirname $0` +. env.sh +cd .. + +if [ "$NAME_OF_PLUGIN" == "" ] +then + export NAME_OF_PLUGIN=`basename $PATH_TO_PLUGIN` +fi + +cd $PATH_TO_REDMINE + + +# run tests +# bundle exec rake TEST=test/unit/role_test.rb +bundle exec rake redmine:plugins:test NAME=$NAME_OF_PLUGIN + diff --git a/build-scripts/database.yml b/build-scripts/database.yml new file mode 100644 index 0000000..9017a3f --- /dev/null +++ b/build-scripts/database.yml @@ -0,0 +1,43 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +sqlite3: &sqlite3 + adapter: sqlite3 + pool: 5 + timeout: 5000 + database: db/redmine.sqlite3 + +mysql: &mysql + adapter: mysql2 + encoding: utf8 + database: <%= ENV['DB_NAME'] || 'redmine' %> + username: <%= ENV['DB_USERNAME'] %> + password: <%= ENV['DB_PASSWORD'] %> + host: <%= ENV['DB_HOST'] %> + port: <%= ENV['DB_PORT'] || 3306 %> + +postgres: &postgres + adapter: postgresql + encoding: utf8 + database: <%= ENV['DB_NAME'] || 'redmine' %> + username: <%= ENV['DB_USERNAME'] %> + password: <%= ENV['DB_PASSWORD'] %> + host: <%= ENV['DB_HOST'] %> + port: <%= ENV['DB_PORT'] || 5432 %> + +development: + <<: *<%= ENV['DB'] || 'sqlite3' %> + +# 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: + <<: *<%= ENV['DB'] || 'sqlite3' %> + +production: + <<: *<%= ENV['DB'] || 'sqlite3' %> + + diff --git a/build-scripts/env.sh b/build-scripts/env.sh new file mode 100644 index 0000000..3ba4f48 --- /dev/null +++ b/build-scripts/env.sh @@ -0,0 +1,5 @@ +export TRAVISDIR=`pwd` +export PATH_TO_PLUGIN=`dirname ${TRAVISDIR}` +export TESTSPACE=$PATH_TO_PLUGIN/testspace +export PATH_TO_REDMINE=$TESTSPACE/redmine +export RAILS_ENV=test \ No newline at end of file diff --git a/build-scripts/install.sh b/build-scripts/install.sh new file mode 100644 index 0000000..ee0f0a7 --- /dev/null +++ b/build-scripts/install.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +set -e + +cd `dirname $0` +. env.sh +SCRIPTDIR=$(pwd) +cd .. + +if [[ ! "$TESTSPACE" = /* ]] || + [[ ! "$PATH_TO_REDMINE" = /* ]] || + [[ ! "$PATH_TO_PLUGIN" = /* ]]; +then + echo "You should set"\ + " TESTSPACE, PATH_TO_REDMINE,"\ + " PATH_TO_PLUGIN"\ + " environment variables" + echo "You set:"\ + "$TESTSPACE"\ + "$PATH_TO_REDMINE"\ + "$PATH_TO_PLUGIN" + exit 1; +fi + +if [ "$REDMINE_VER" = "" ] +then + export REDMINE_VER=master +fi + +if [ "$NAME_OF_PLUGIN" == "" ] +then + export NAME_OF_PLUGIN=`basename $PATH_TO_PLUGIN` +fi + +mkdir -p $TESTSPACE + +export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git +export REDMINE_GIT_TAG=$REDMINE_VER +export BUNDLE_GEMFILE=$PATH_TO_REDMINE/Gemfile + +if [ -f Gemfile_for_test ] +then + cp Gemfile_for_test Gemfile +fi + +# checkout redmine +git clone $REDMINE_GIT_REPO $PATH_TO_REDMINE +if [ -d test/fixtures ] +then + cp test/fixtures/* ${PATH_TO_REDMINE}/test/fixtures/ +fi + +cd $PATH_TO_REDMINE +if [ ! "$REDMINE_GIT_TAG" = "master" ]; +then + git checkout -b $REDMINE_GIT_TAG origin/$REDMINE_GIT_TAG +fi + +# create a link to the backlogs plugin +ln -sf $PATH_TO_PLUGIN plugins/$NAME_OF_PLUGIN + + +cp "$SCRIPTDIR/database.yml" config/database.yml + + + +# install gems +bundle install + +# run redmine database migrations +bundle exec rake db:create +bundle exec rake db:migrate + +# run plugin database migrations +bundle exec rake redmine:plugins:migrate + + diff --git a/test/test_helper.rb b/test/test_helper.rb index 22cad4f..dcd9d4e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,15 @@ require 'simplecov' require 'simplecov-rcov' -require 'coveralls' +require 'simplecov-lcov' + +SimpleCov::Formatter::LcovFormatter.config do |config| + config.report_with_single_file = true + config.single_report_path = File.expand_path(File.dirname(__FILE__) + '/../coverage/lcov.info') +end SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::RcovFormatter, - Coveralls::SimpleCov::Formatter + SimpleCov::Formatter::LcovFormatter ] SimpleCov.start do From 210782d065d1ba83a506998f9d0cc5bca8086f50 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Fri, 10 Sep 2021 23:15:46 +0900 Subject: [PATCH 05/18] Github Actions --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d7ac116 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +[![build](https://github.com/haru/redmine_logs/actions/workflows/build.yml/badge.svg)](https://github.com/haru/redmine_logs/actions/workflows/build.yml) +[![Maintainability](https://api.codeclimate.com/v1/badges/3fb10c5b2245dd4647e5/maintainability)](https://codeclimate.com/github/haru/redmine_logs/maintainability) +[![Coverage Status](https://coveralls.io/repos/github/haru/redmine_logs/badge.svg?branch=master)](https://coveralls.io/github/haru/redmine_logs?branch=master) + +# Redmine Logs Plugin + +This is a plugin for Redmine which lets you download log files of Redmine from administration page. + +http://www.r-labs.org/projects/logs + +## Plugin installation + +1. Copy the plugin directory into the plugins directory. + +That's all. + From 710bb7fb6ba83e23fbf5be27bc187e6096ab8f88 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 11 Sep 2021 15:11:15 +0900 Subject: [PATCH 06/18] Codecov --- .github/workflows/build.yml | 6 +----- Gemfile_for_test | 3 +-- test/test_helper.rb | 13 +++---------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b341c7a..5998347 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,7 @@ name: build on: [push] env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} jobs: build: runs-on: ubuntu-latest @@ -49,11 +50,6 @@ jobs: run: bash -x ./build-scripts/install.sh - name: Build run: bash -x ./build-scripts/build.sh - - name: Coveralls GitHub Action - if: ${{ matrix.redmine_version == 'master' && matrix.db == 'mysql' }} - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.0.2 if: failure() diff --git a/Gemfile_for_test b/Gemfile_for_test index 6318fd2..a294126 100644 --- a/Gemfile_for_test +++ b/Gemfile_for_test @@ -1,6 +1,5 @@ source :rubygems group :test do - gem "simplecov-rcov" - gem 'simplecov-lcov' + gem 'codecov', :require => false end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index dcd9d4e..3acba50 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,17 +1,10 @@ require 'simplecov' -require 'simplecov-rcov' -require 'simplecov-lcov' -SimpleCov::Formatter::LcovFormatter.config do |config| - config.report_with_single_file = true - config.single_report_path = File.expand_path(File.dirname(__FILE__) + '/../coverage/lcov.info') +if ENV['CODECOV_TOKEN'] + require 'codecov' + SimpleCov.formatter = SimpleCov::Formatter::Codecov end -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ - SimpleCov::Formatter::RcovFormatter, - SimpleCov::Formatter::LcovFormatter -] - SimpleCov.start do root File.expand_path(File.dirname(__FILE__) + '/..') add_filter "/test/" From 4a3bc9a1e11b62e848d1382a6396e5606e8ff60e Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 11 Sep 2021 15:20:10 +0900 Subject: [PATCH 07/18] Codecov --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d7ac116..53a5b81 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![build](https://github.com/haru/redmine_logs/actions/workflows/build.yml/badge.svg)](https://github.com/haru/redmine_logs/actions/workflows/build.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/3fb10c5b2245dd4647e5/maintainability)](https://codeclimate.com/github/haru/redmine_logs/maintainability) -[![Coverage Status](https://coveralls.io/repos/github/haru/redmine_logs/badge.svg?branch=master)](https://coveralls.io/github/haru/redmine_logs?branch=master) +[![codecov](https://codecov.io/gh/haru/redmine_logs/branch/develop/graph/badge.svg?token=SKAL5GLHIX)](https://codecov.io/gh/haru/redmine_logs) # Redmine Logs Plugin From a46286d735088f7d7fc0e5ccb02c627e6de6aba8 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 11 Sep 2021 15:40:55 +0900 Subject: [PATCH 08/18] Codecov config --- build-scripts/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-scripts/install.sh b/build-scripts/install.sh index ee0f0a7..d988580 100644 --- a/build-scripts/install.sh +++ b/build-scripts/install.sh @@ -58,6 +58,7 @@ fi # create a link to the backlogs plugin ln -sf $PATH_TO_PLUGIN plugins/$NAME_OF_PLUGIN +ln -sf plugins/$NAME_OF_PLUGIN/coverage ./coverage cp "$SCRIPTDIR/database.yml" config/database.yml From 90bcd660ecca9acbefd648584cb81f827cd266ac Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 11 Sep 2021 16:40:35 +0900 Subject: [PATCH 09/18] Codecov config --- .github/workflows/build.yml | 3 +++ Gemfile_for_test | 3 ++- build-scripts/cleanup.sh | 9 +++++++++ build-scripts/install.sh | 2 -- test/test_helper.rb | 15 ++++++++++++--- 5 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 build-scripts/cleanup.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5998347..068d909 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,9 @@ jobs: run: bash -x ./build-scripts/install.sh - name: Build run: bash -x ./build-scripts/build.sh + - name: Clean + run: bash -x ./build-scripts/celanup.sh + - uses: codecov/codecov-action@v2 - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.0.2 if: failure() diff --git a/Gemfile_for_test b/Gemfile_for_test index a294126..877d79f 100644 --- a/Gemfile_for_test +++ b/Gemfile_for_test @@ -1,5 +1,6 @@ source :rubygems group :test do - gem 'codecov', :require => false + gem "simplecov-rcov" + gem "simplecov-lcov" end \ No newline at end of file diff --git a/build-scripts/cleanup.sh b/build-scripts/cleanup.sh new file mode 100644 index 0000000..d3426ae --- /dev/null +++ b/build-scripts/cleanup.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +cd `dirname $0` +. env.sh +cd .. + +rm -rf $TESTSPACE \ No newline at end of file diff --git a/build-scripts/install.sh b/build-scripts/install.sh index d988580..64b7af4 100644 --- a/build-scripts/install.sh +++ b/build-scripts/install.sh @@ -58,8 +58,6 @@ fi # create a link to the backlogs plugin ln -sf $PATH_TO_PLUGIN plugins/$NAME_OF_PLUGIN -ln -sf plugins/$NAME_OF_PLUGIN/coverage ./coverage - cp "$SCRIPTDIR/database.yml" config/database.yml diff --git a/test/test_helper.rb b/test/test_helper.rb index 3acba50..1718e50 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,19 @@ require 'simplecov' +require 'simplecov-rcov' +require 'simplecov-lcov' -if ENV['CODECOV_TOKEN'] - require 'codecov' - SimpleCov.formatter = SimpleCov::Formatter::Codecov + +SimpleCov::Formatter::LcovFormatter.config do |config| + config.report_with_single_file = true + config.single_report_path = File.expand_path(File.dirname(__FILE__) + '/../coverage/lcov.info') end +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::RcovFormatter, + SimpleCov::Formatter::LcovFormatter + # Coveralls::SimpleCov::Formatter +] + SimpleCov.start do root File.expand_path(File.dirname(__FILE__) + '/..') add_filter "/test/" From 32177431ee400fc4f729d932ff62cc817c17fc38 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 11 Sep 2021 16:45:15 +0900 Subject: [PATCH 10/18] Codecov config --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 068d909..0d6df73 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: - name: Build run: bash -x ./build-scripts/build.sh - name: Clean - run: bash -x ./build-scripts/celanup.sh + run: bash -x ./build-scripts/cleanup.sh - uses: codecov/codecov-action@v2 - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.0.2 From b913005f002e9f1a9526a57cab6d2ec052c05bbe Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sun, 12 Sep 2021 15:28:46 +0900 Subject: [PATCH 11/18] Add triger for pull request. Add HTML coverage report. --- .github/workflows/build.yml | 2 +- test/test_helper.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d6df73..93bf2ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: build -on: [push] +on: [push, pull_request] env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/test/test_helper.rb b/test/test_helper.rb index 1718e50..147f18f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,7 +10,8 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::RcovFormatter, - SimpleCov::Formatter::LcovFormatter + SimpleCov::Formatter::LcovFormatter, + SimpleCov::Formatter::HTMLFormatter # Coveralls::SimpleCov::Formatter ] From 4c45c24c6a4bdbd934f2c83a73e168365ee58ba8 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 26 Feb 2022 16:39:13 +0900 Subject: [PATCH 12/18] Add .devcontainer --- .devcontainer/Dockerfile | 46 +++++++++++++++++ .devcontainer/create-db-user.sql | 2 + .devcontainer/database.yml | 57 ++++++++++++++++++++++ .devcontainer/devcontainer.json | 64 ++++++++++++++++++++++++ .devcontainer/docker-compose.yml | 58 ++++++++++++++++++++++ .devcontainer/launch.json | 84 ++++++++++++++++++++++++++++++++ .devcontainer/post-create.sh | 29 +++++++++++ 7 files changed, 340 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/create-db-user.sql create mode 100644 .devcontainer/database.yml create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 .devcontainer/launch.json create mode 100644 .devcontainer/post-create.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..4efffeb --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,46 @@ +# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster +ARG VARIANT=2-bullseye +FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT} + +# Install Rails +RUN gem install rails webdrivers + +# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service +# The value is a comma-separated list of allowed domains +ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev" + +# [Choice] Node.js version: lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="lts/*" +RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1" + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install additional gems. +# RUN gem install + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 + +RUN apt-get update +RUN apt-get install -y imagemagick + +WORKDIR /usr/local +ARG REDMINE_VERSION=master +RUN git clone https://github.com/redmine/redmine.git -b ${REDMINE_VERSION} +WORKDIR /usr/local/redmine +COPY .devcontainer/database.yml /usr/local/redmine/config/database.yml + +RUN rm -rf .git +RUN echo "gem 'ruby-debug-ide'" >> Gemfile +RUN echo "gem 'debase'" >> Gemfile +RUN echo "gem 'rufo'" >> Gemfile +ENV DB=sqlite3 +RUN bundle install +RUN bundle exec rake db:migrate +RUN bundle exec rake db:migrate RAILS_ENV=test +COPY .devcontainer/launch.json /usr/local/redmine/.vscode/launch.json +RUN chown -R vscode . + +COPY .devcontainer/post-create.sh /post-create.sh \ No newline at end of file diff --git a/.devcontainer/create-db-user.sql b/.devcontainer/create-db-user.sql new file mode 100644 index 0000000..291dfc4 --- /dev/null +++ b/.devcontainer/create-db-user.sql @@ -0,0 +1,2 @@ +CREATE USER vscode CREATEDB; +CREATE DATABASE vscode WITH OWNER vscode; diff --git a/.devcontainer/database.yml b/.devcontainer/database.yml new file mode 100644 index 0000000..5107702 --- /dev/null +++ b/.devcontainer/database.yml @@ -0,0 +1,57 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +sqlite3: &sqlite3 + adapter: sqlite3 + pool: 5 + timeout: 5000 + database: db/redmine.sqlite3 + +sqlite3_test: &sqlite3_test + <<: *<%= 'sqlite3' %> + database: db/redmine.sqlite3_test + +mysql: &mysql + adapter: mysql2 + encoding: utf8 + database: <%= ENV['DB_NAME'] || 'redmine' %> + username: <%= ENV['DB_USERNAME'] || 'root' %> + password: <%= ENV['DB_PASSWORD'] || 'root' %> + host: <%= ENV['DB_HOST'] || 'mysql' %> + port: <%= ENV['DB_PORT'] || 3306 %> + +mysql_test: &mysql_test + <<: *<%= 'mysql' %> + database: redmine_test + +postgres: &postgres + adapter: postgresql + encoding: utf8 + database: <%= ENV['DB_NAME'] || 'redmine' %> + username: <%= ENV['DB_USERNAME'] || 'postgres' %> + password: <%= ENV['DB_PASSWORD'] || 'postgres' %> + host: <%= ENV['DB_HOST'] || 'postgres' %> + port: <%= ENV['DB_PORT'] || 5432 %> + +postgres_test: &postgres_test + <<: *<%= 'postgres' %> + database: redmine_test + + +development: + <<: *<%= ENV['DB'] || 'sqlite3' %> + + +# 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: + <<: *<%= "#{ENV['DB']}_test" || 'sqlite3_test' %> + + +production: + <<: *<%= ENV['DB'] || 'sqlite3' %> + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..fa994ff --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,64 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/ruby-rails-postgres +// Update the VARIANT arg in docker-compose.yml to pick a Ruby version +{ + "name": "Ruby on Rails & Postgres", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + + "workspaceFolder": "/usr/local/redmine", + + // Set *default* container specific settings.json values on container create. + "settings": { + "sqltools.connections": [ + { + "name": "Rails Development Database", + "driver": "PostgreSQL", + "previewLimit": 50, + "server": "localhost", + "port": 5432, + + // update this to match config/database.yml + "database": "app_development", + "username": "vscode" + }, + { + "name": "Rails Test Database", + "driver": "PostgreSQL", + "previewLimit": 50, + "server": "localhost", + "port": 5432, + + // update this to match config/database.yml + "database": "app_test", + "username": "vscode" + } + ] + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "rebornix.Ruby", + "mtxr.sqltools", + "mtxr.sqltools-driver-pg", + "craigmaslowski.erb", + "hridoy.rails-snippets", + "misogi.ruby-rubocop", + "jnbt.vscode-rufo", + "donjayamanne.git-extension-pack" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [3000, 5432], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "sh -x /post-create.sh", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + // "git": "latest" + } + + +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..495879d --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,58 @@ +version: '3' + +services: + app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + args: + # Update 'VARIANT' to pick a version of Ruby: 3, 3.0, 2, 2.7, 2.6 + # Append -bullseye or -buster to pin to an OS version. + # Use -bullseye variants on local arm64/Apple Silicon. + VARIANT: "2.7" + # Optional Node.js version to install + NODE_VERSION: "lts/*" + REDMINE_VERSION: "4.2-stable" + + volumes: + - ..:/usr/local/redmine/plugins/redmine_logs:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + # network_mode: service:postgres + # Uncomment the next line to use a non-root user for all processes. + # user: vscode + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + postgres: + image: postgres:latest + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + - ./create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql + environment: + POSTGRES_USER: postgres + POSTGRES_DB: redmine + POSTGRES_PASSWORD: postgres + # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + mysql: + image: mysql:latest + restart: unless-stopped + volumes: + - mysql-data:/var/lib/mysql + # network_mode: service:postgres + command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: redmine + MYSQL_DB: redmine + MYSQL_PASSWORD: remine +volumes: + postgres-data: null + mysql-data: null diff --git a/.devcontainer/launch.json b/.devcontainer/launch.json new file mode 100644 index 0000000..793c4e9 --- /dev/null +++ b/.devcontainer/launch.json @@ -0,0 +1,84 @@ +{ + "version": "0.2.0", + "configurations": [ + + + { + "name": "Rails server", + "type": "Ruby", + "request": "launch", + "program": "${workspaceRoot}/bin/rails", + "useBundler": true, + "args": [ + "server" + ] + }, + { + "name": "Rails server(postgres)", + "type": "Ruby", + "request": "launch", + "program": "${workspaceRoot}/bin/rails", + "useBundler": true, + "args": [ + "server" + ], + "env":{ + "DB": "postgres" + } + }, + { + "name": "Rails server(mysql)", + "type": "Ruby", + "request": "launch", + "program": "${workspaceRoot}/bin/rails", + "useBundler": true, + "args": [ + "server" + ], + "env":{ + "DB": "mysql" + } + }, + { + "name": "Plugin Test", + "type": "Ruby", + "request": "launch", + "program": "${workspaceRoot}/bin/rake", + "useBundler": true, + "args": [ + "redmine:plugins:test" + ], + "env":{ + "RAILS_ENV": "test" + } + }, + { + "name": "Plugin Test(postgres)", + "type": "Ruby", + "request": "launch", + "program": "${workspaceRoot}/bin/rake", + "useBundler": true, + "args": [ + "redmine:plugins:test" + ], + "env":{ + "RAILS_ENV": "test", + "DB": "postgres" + } + }, + { + "name": "Plugin Test(mysql)", + "type": "Ruby", + "request": "launch", + "program": "${workspaceRoot}/bin/rake", + "useBundler": true, + "args": [ + "redmine:plugins:test" + ], + "env":{ + "RAILS_ENV": "test", + "DB": "mysql" + } + } + ] +} \ No newline at end of file diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 0000000..42ccf95 --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,29 @@ +#!/bin/sh +cd /usr/local/redmine +PLUGIN_NAME=redmine_logs + +cp plugins/${PLUGIN_NAME}/Gemfile_for_test plugins/${PLUGIN_NAME}/Gemfile +bundle install +bundle exec rake redmine:plugins:migrate +bundle exec rake redmine:plugins:migrate RAILS_ENV=test + +initdb() { + bundle exec rake db:create + bundle exec rake db:migrate + bundle exec rake redmine:plugins:migrate + + bundle exec rake db:drop RAILS_ENV=test + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:migrate RAILS_ENV=test + bundle exec rake redmine:plugins:migrate RAILS_ENV=test +} + +initdb + +export DB=postgres + +initdb + +export DB=mysql + +initdb \ No newline at end of file From 40a5af932bd2a9dc39857143e25ae8c67633c6fc Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 26 Feb 2022 16:51:02 +0900 Subject: [PATCH 13/18] Rails6 --- .devcontainer/docker-compose.yml | 2 +- app/controllers/logs_controller.rb | 2 +- init.rb | 1 + lib/{ => redmine_logs}/log_file.rb | 0 4 files changed, 3 insertions(+), 2 deletions(-) rename lib/{ => redmine_logs}/log_file.rb (100%) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 495879d..e6e0e17 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -12,7 +12,7 @@ services: VARIANT: "2.7" # Optional Node.js version to install NODE_VERSION: "lts/*" - REDMINE_VERSION: "4.2-stable" + REDMINE_VERSION: "master" volumes: - ..:/usr/local/redmine/plugins/redmine_logs:cached diff --git a/app/controllers/logs_controller.rb b/app/controllers/logs_controller.rb index ce71561..655a5bd 100644 --- a/app/controllers/logs_controller.rb +++ b/app/controllers/logs_controller.rb @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'log_file' +require 'redmine_logs/log_file' class LogsController < ApplicationController unloadable layout 'admin' diff --git a/init.rb b/init.rb index 54fcc16..52eb8e5 100644 --- a/init.rb +++ b/init.rb @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib" require 'redmine' require 'admin_menu_hooks' diff --git a/lib/log_file.rb b/lib/redmine_logs/log_file.rb similarity index 100% rename from lib/log_file.rb rename to lib/redmine_logs/log_file.rb From a32e331b77719030b9391f1dbebdd4d451b98512 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 26 Feb 2022 16:52:02 +0900 Subject: [PATCH 14/18] Add ruby 3.1 test --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93bf2ae..f6be5af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: db: [sqlite3, mysql, postgres] - ruby_version: [2.4, 2.5, 2.6, 2.7, 3.0] + ruby_version: [2.4, 2.5, 2.6, 2.7, 3.0, 3.1] redmine_version: [4.1-stable, 4.2-stable, master] exclude: - ruby_version: 2.4 @@ -20,6 +20,10 @@ jobs: redmine_version: 4.1-stable - ruby_version: 3.0 redmine_version: 4.2-stable + - ruby_version: 3.1 + redmine_version: 4.1-stable + - ruby_version: 3.1 + redmine_version: 4.2-stable services: mysql: image: mysql:5.7 From 2c181cd420b8376e13ec247ab8d1824e342a9ca5 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 26 Feb 2022 16:57:03 +0900 Subject: [PATCH 15/18] Add release script --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0dfe05f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: build_archive +on: + push: + branches-ignore: + - '**' + tags: + - '**' +env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} +jobs: + archive: + runs-on: ubuntu-latest + steps: + - name: Set version + id: version + run: | + REPOSITORY=$(echo ${{ github.repository }} | sed -e "s#.*/##") + VERSION=$(echo ${{ github.ref }} | sed -e "s#refs/tags/##g") + echo ::set-output name=version::$VERSION + echo ::set-output name=filename::$REPOSITORY-$VERSION + echo ::set-output name=plugin::$REPOSITORY + - uses: actions/checkout@v2 + - name: Archive + run: | + cd ..; zip -r ${{ steps.version.outputs.filename }}.zip ${{ steps.version.outputs.plugin }}/ -x "*.git*"; mv ${{ steps.version.outputs.filename }}.zip ${{ steps.version.outputs.plugin }}/ + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.version }} + release_name: ${{ steps.version.outputs.version }} + body: '' + draft: false + prerelease: true + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ steps.version.outputs.filename }}.zip + asset_name: ${{ steps.version.outputs.filename }}.zip + asset_content_type: application/zip \ No newline at end of file From 58ab5190aadfb912c513a5ccc92886217a6fa87c Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 26 Feb 2022 17:01:27 +0900 Subject: [PATCH 16/18] remove illegal version matrix for tests --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6be5af..2714631 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,10 @@ jobs: exclude: - ruby_version: 2.4 redmine_version: master + - ruby_version: 2.5 + redmine_version: master + - ruby_version: 2.6 + redmine_version: master - ruby_version: 2.7 redmine_version: 4.1-stable - ruby_version: 3.0 From cf8e554e47fa7d4f840133c5924a1079cd811a21 Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Tue, 29 Mar 2022 22:08:00 +0900 Subject: [PATCH 17/18] Add Redmine 5 test environment --- .devcontainer/docker-compose.yml | 4 ++-- .github/workflows/build.yml | 8 +++----- build-scripts/install.sh | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index e6e0e17..8537d3a 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -9,10 +9,10 @@ services: # Update 'VARIANT' to pick a version of Ruby: 3, 3.0, 2, 2.7, 2.6 # Append -bullseye or -buster to pin to an OS version. # Use -bullseye variants on local arm64/Apple Silicon. - VARIANT: "2.7" + VARIANT: "3.0" # Optional Node.js version to install NODE_VERSION: "lts/*" - REDMINE_VERSION: "master" + REDMINE_VERSION: "5.0-stable" volumes: - ..:/usr/local/redmine/plugins/redmine_logs:cached diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2714631..047c33d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,14 +10,12 @@ jobs: matrix: db: [sqlite3, mysql, postgres] ruby_version: [2.4, 2.5, 2.6, 2.7, 3.0, 3.1] - redmine_version: [4.1-stable, 4.2-stable, master] + redmine_version: [4.1-stable, 4.2-stable, 5.0-stable, master] exclude: - ruby_version: 2.4 redmine_version: master - - ruby_version: 2.5 - redmine_version: master - - ruby_version: 2.6 - redmine_version: master + - ruby_version: 2.4 + redmine_version: 5.0-stable - ruby_version: 2.7 redmine_version: 4.1-stable - ruby_version: 3.0 diff --git a/build-scripts/install.sh b/build-scripts/install.sh index 64b7af4..71afc09 100644 --- a/build-scripts/install.sh +++ b/build-scripts/install.sh @@ -34,7 +34,7 @@ fi mkdir -p $TESTSPACE -export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git +export REDMINE_GIT_REPO=https://github.com/redmine/redmine.git export REDMINE_GIT_TAG=$REDMINE_VER export BUNDLE_GEMFILE=$PATH_TO_REDMINE/Gemfile From f5598db1080f58ee6c4443f3c26650b006ab582a Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Tue, 29 Mar 2022 22:34:47 +0900 Subject: [PATCH 18/18] Change version to 0.3.0 --- init.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.rb b/init.rb index 52eb8e5..7f534bd 100644 --- a/init.rb +++ b/init.rb @@ -1,5 +1,5 @@ # Logs plugin for Redmine -# Copyright (C) 2010-2017 Haruyuki Iida +# Copyright (C) 2010-2022 Haruyuki Iida # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -24,7 +24,7 @@ author_url 'http://twitter.com/haru_iida' url "http://www.r-labs.org/projects/logs" if respond_to?(:url) description 'This is a Logs plugin for Redmine' - version '0.2.0' + version '0.3.0' requires_redmine :version_or_higher => '3.0.0' menu :admin_menu, 'icon redmine-logs', { :controller => 'logs', :action => 'index'}, :caption => :logs