Skip to content

Commit 4cfa153

Browse files
committed
Added github actions
1 parent a0373b3 commit 4cfa153

File tree

7 files changed

+211
-1
lines changed

7 files changed

+211
-1
lines changed

.github/workflows/ruby.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test
2+
on:
3+
push:
4+
branches-ignore: [debian]
5+
6+
jobs:
7+
test:
8+
name: ${{ matrix.redmine }} on ${{ matrix.ruby }}
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
include:
14+
- ruby: "2.7"
15+
redmine: "4.2.1"
16+
- ruby: "2.6"
17+
redmine: "4.1.3"
18+
fail-fast: false
19+
20+
env:
21+
BUNDLE_JOBS: 4
22+
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
23+
BUNDLE_RETRY: 3
24+
BUNDLE_WITHOUT: development
25+
REDMINE_VERSION: ${{ matrix.redmine }}
26+
27+
steps:
28+
- uses: actions/checkout@master
29+
30+
- uses: ruby/setup-ruby@v1
31+
with:
32+
ruby-version: ${{ matrix.ruby }}
33+
34+
- name: setup cache
35+
uses: actions/cache@v1
36+
with:
37+
path: vendor
38+
key: v3-ruby-${{ matrix.ruby }}-redmine-${{ matrix.redmine }}
39+
40+
- name: install ruby dependencies
41+
run: bundle install
42+
43+
- name: setup redmine ${{ matrix.redmine }}
44+
run: ./redmine update
45+
46+
- name: run prepare tests
47+
run: bundle exec rake db:test:prepare
48+
49+
- name: run plugins tests
50+
run: bundle exec rake redmine:plugins:test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.bundle
2+
Gemfile.lock
3+
vendor

README.rdoc renamed to README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ Pluing development was sponsored by MEDEVIT (http://www.medevit.at)
2424

2525
Checkout a redmine version, clone this plugin under plugins/redmine_acess_filters
2626
and run
27-
bundle exec rake redmine:plugins:test NAME=redmine_acess_filter
27+
28+
export RAILS_ENV=test
29+
bundle install
30+
bundle exec rake redmine:plugins NAME=redmine_access_filters
31+
bundle exec rake db:test:prepare
32+
bundle exec rake redmine:plugins:test
33+
# run a single test
34+
bundle exec ruby plugins/redmine_access_filters/test/functional/access_filter_test.rb -n test_works_if_no_rules_exist

redmine

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
REDMINE_VERSION = ENV['REDMINE_VERSION'] = ENV['REDMINE_VERSION'] || ENV['VERSION'] || '4.1.3'
5+
REDMINE_PATH = ENV['REDMINE_PATH'] = File.expand_path("../vendor/redmine/#{REDMINE_VERSION}/", __FILE__)
6+
REDMINE_EXEC = ENV['REDMINE_EXEC'] = File.expand_path(__FILE__)
7+
PLUGIN_PATH = ENV['PLUGIN_PATH'] = File.expand_path(__dir__)
8+
9+
require 'pathname'
10+
11+
SCRIPT_PATH = Pathname.new(__FILE__).expand_path.parent.join('scripts')
12+
13+
def help
14+
<<-HELP.gsub(/^\s{4}/, '')
15+
Available commands:
16+
#{available_commands.join("\n ")}
17+
HELP
18+
end
19+
20+
def available_commands
21+
SCRIPT_PATH.children
22+
.select(&:file?)
23+
.select(&:executable?)
24+
.map(&:basename)
25+
.map(&:to_s)
26+
end
27+
28+
def handle_command(cmd, _argv)
29+
unless ARGV[0] =~ /\A(\w+)\z/
30+
warn "Invalid command: #{ARGV[0]}"
31+
warn help
32+
Kernel.exit 1
33+
end
34+
35+
command = SCRIPT_PATH.join(cmd.to_s)
36+
37+
if command.file? && command.executable?
38+
Kernel.exec command.to_s, *ARGV[1..-1]
39+
else
40+
warn "Unknown command: #{ARGV[0]}"
41+
warn help
42+
Kernel.exit 1
43+
end
44+
end
45+
46+
case ARGV[0]
47+
when '-h', '--help', nil
48+
$stdout.puts help
49+
when 'exec'
50+
Dir.chdir(REDMINE_PATH) { Kernel.exec(*ARGV[1..-1]) }
51+
else
52+
handle_command ARGV[0], ARGV[1..-1]
53+
end

scripts/install

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
[ -z "$PLUGIN_PATH" ] && exit 1
6+
[ -z "$REDMINE_EXEC" ] && exit 1
7+
[ -z "$REDMINE_PATH" ] && exit 1
8+
[ -z "$REDMINE_VERSION" ] && exit 1
9+
10+
mkdir -p "${REDMINE_PATH}"
11+
mkdir -p tmp log
12+
13+
case ${REDMINE_VERSION} in
14+
master)
15+
REDMINE_SOURCE="http://svn.redmine.org/redmine/trunk"
16+
;;
17+
18+
*)
19+
REDMINE_SOURCE="http://svn.redmine.org/redmine/tags/${REDMINE_VERSION}"
20+
;;
21+
esac
22+
23+
(set -x; svn export --quiet --force "${REDMINE_SOURCE}" "${REDMINE_PATH}")
24+
25+
echo "Symlink plugin, assets and specs..."
26+
27+
mkdir -p ${REDMINE_PATH}/public/plugin_assets
28+
29+
if [ ! -L "${REDMINE_PATH}/plugins/redmine_dashboard" ]; then
30+
ln -s "${PLUGIN_PATH}" "${REDMINE_PATH}/plugins/redmine_dashboard"
31+
fi
32+
33+
if [ ! -L "${REDMINE_PATH}/spec" ]; then
34+
ln -s "${PLUGIN_PATH}/spec" "${REDMINE_PATH}/spec"
35+
fi
36+
37+
if [ ! -L "${REDMINE_PATH}/test/fixtures/rdb" ]; then
38+
ln -s "${PLUGIN_PATH}/spec/fixtures" "${REDMINE_PATH}/test/fixtures/rdb"
39+
fi
40+
41+
if [ ! -L "${REDMINE_PATH}/public/plugin_assets/redmine_dashboard_linked" ]; then
42+
ln -s "${PLUGIN_PATH}/assets" "${REDMINE_PATH}/public/plugin_assets/redmine_dashboard_linked"
43+
fi
44+
45+
echo "Copy database configuration..."
46+
47+
(set -x; cp -v $PLUGIN_PATH/test/database.yml "$REDMINE_PATH"/config/ )
48+
49+
pushd "${REDMINE_PATH}"
50+
51+
sed -i -E '/selenium-webdriver|capybara/d' Gemfile
52+
cat << EOF >> Gemfile
53+
group :test do
54+
gem 'capybara', '~> 3.12'
55+
gem 'selenium-webdriver', '~> 3.141'
56+
end
57+
EOF
58+
59+
(set -x; bundle install --without rmagick --jobs=3 --retry=3 ${BUNDLE_OPTS})
60+
(set -x; bundle exec rake generate_secret_token db:create:all db:migrate redmine:plugins:migrate db:test:prepare)
61+
62+
popd

scripts/update

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
[ -z "$PLUGIN_PATH" ] && exit 1
6+
[ -z "$REDMINE_EXEC" ] && exit 1
7+
[ -z "$REDMINE_PATH" ] && exit 1
8+
[ -z "$REDMINE_VERSION" ] && exit 1
9+
10+
if [ ! -d "${REDMINE_PATH}" ]; then
11+
exec $REDMINE_EXEC install
12+
fi
13+
14+
pushd "${REDMINE_PATH}"
15+
16+
if [ "${REDMINE_VERSION}" == "master" ]; then
17+
(set -x; svn export --quiet --force "${REDMINE_SOURCE}" .)
18+
fi
19+
20+
(set -x; bundle update --jobs=3 --retry=3)
21+
pwd
22+
(set -x; bundle exec rake db:create:all db:migrate redmine:plugins:migrate db:test:prepare)

test/database.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Line indentation must be 2 spaces (no tabs).
2+
production:
3+
adapter: sqlite3
4+
database: db/redmine_production.sqlite3
5+
6+
development:
7+
adapter: sqlite3
8+
database: db/redmine_development.sqlite3
9+
10+
test:
11+
adapter: sqlite3
12+
database: db/redmine_test.sqlite3
13+

0 commit comments

Comments
 (0)