@webship.co/workspace-redmine 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +179 -2
- package/ai/agents/redmine-issue-worker.md +90 -0
- package/ai/agents/redmine-site-builder.md +106 -0
- package/ai/agents/redmine-tester.md +119 -0
- package/ai/commands/redmine-test.md +66 -0
- package/ai/prompts/redmine-build-and-test.md +28 -0
- package/ai/prompts/redmine-issue-to-branch.md +24 -0
- package/ai/skills/redmine-scenarios/SKILL.md +72 -0
- package/ai/skills/redmine-scenarios/examples/issue.feature +17 -0
- package/ai/skills/redmine-scenarios/examples/roles.feature +16 -0
- package/ai/skills/redmine-scenarios/examples/session.feature +24 -0
- package/commands/cmd-redmine-project.sh +31 -0
- package/commands/cmd-tools-redmine-cli.sh +24 -0
- package/config/plugin.redmine.settings.yml +29 -0
- package/config/settings.labels.yml +57 -0
- package/dist/src/index.d.ts +34 -0
- package/dist/src/index.js +60 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/tracker.d.ts +28 -0
- package/dist/src/lib/tracker.js +308 -0
- package/dist/src/lib/tracker.js.map +1 -0
- package/features/redmine-runtimes.feature +31 -0
- package/features/redmine.feature +53 -0
- package/package.json +118 -4
- package/scripts/args/arg-redmine-cli.sh +28 -0
- package/scripts/args/arg-redmine.sh +31 -0
- package/scripts/docker-compose.redmine.yaml +41 -0
- package/scripts/functions/fun-redmine.sh +576 -0
- package/scripts/redmine-serve.sh +13 -0
- package/scripts/redmine-site.rb +229 -0
- package/testing/site.feature +28 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The Webship Workspace's Redmine builder and tool, run with Redmine's own Rails runner in the site's container, as
|
|
4
|
+
# Redmine's user:
|
|
5
|
+
#
|
|
6
|
+
# bundle exec rails runner redmine-site.rb <verb>...
|
|
7
|
+
#
|
|
8
|
+
# defaults the first set-up of a new site, from the input (the base64 of a JSON object: admin_password, host,
|
|
9
|
+
# protocol): Redmine's default data in English (trackers, statuses, roles, workflows, priorities,
|
|
10
|
+
# activities), the REST API on, the host name and protocol of the links, and the administrator's password.
|
|
11
|
+
# accounts the accounts on the input (the base64 of a JSON list of login, mail, password, firstname, lastname,
|
|
12
|
+
# admin, role, action): made, or given back their name, password and status; with a role, a member of the
|
|
13
|
+
# sample project in it, without one a member of nothing there; with the action "lock", locked.
|
|
14
|
+
# content the sample content: the project "Webship site" with its issues, its version "Sprint 1" and a note, each
|
|
15
|
+
# made where it is missing.
|
|
16
|
+
# tidy what a test run that was stopped half way left: its issues ("Webship test …"), with their time.
|
|
17
|
+
# list the default accounts, and what the sample project holds.
|
|
18
|
+
# token the API key of the active account whose login is on the input, made anew (its earlier one revoked), as
|
|
19
|
+
# "TOKEN <value>" (for --connect, which writes it to the dashboard's settings; never shown).
|
|
20
|
+
#
|
|
21
|
+
# Nothing secret comes on its command line: passwords and logins travel on the input.
|
|
22
|
+
|
|
23
|
+
require 'base64'
|
|
24
|
+
require 'json'
|
|
25
|
+
|
|
26
|
+
PROJECT_IDENTIFIER = 'webship-site'
|
|
27
|
+
PROJECT_NAME = 'Webship site'
|
|
28
|
+
TEST_PREFIX = 'Webship test'
|
|
29
|
+
DEFAULT_LOGINS = %w[owner member reader stranger].freeze
|
|
30
|
+
|
|
31
|
+
def say(text)
|
|
32
|
+
puts text
|
|
33
|
+
$stdout.flush
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Kernel#warn says nothing when $VERBOSE is nil, as it is in a runner of the production environment.
|
|
37
|
+
def fail_with(text)
|
|
38
|
+
$stderr.puts text
|
|
39
|
+
$stderr.flush
|
|
40
|
+
exit 1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def input_json
|
|
44
|
+
raw = $stdin.read.to_s.strip
|
|
45
|
+
fail_with('This verb reads the base64 of a JSON value on its input.') if raw.empty?
|
|
46
|
+
JSON.parse(Base64.decode64(raw))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def defaults(options)
|
|
50
|
+
if Redmine::DefaultData::Loader.no_data?
|
|
51
|
+
Redmine::DefaultData::Loader.load('en')
|
|
52
|
+
say 'defaults: Redmine\'s default data loaded (trackers, statuses, roles, workflows, priorities, activities)'
|
|
53
|
+
end
|
|
54
|
+
Setting.rest_api_enabled = '1'
|
|
55
|
+
Setting.host_name = options['host'].to_s unless options['host'].to_s.empty?
|
|
56
|
+
Setting.protocol = options['protocol'].to_s unless options['protocol'].to_s.empty?
|
|
57
|
+
admin = User.find_by(login: 'admin')
|
|
58
|
+
if admin && !options['admin_password'].to_s.empty?
|
|
59
|
+
admin.password = options['admin_password']
|
|
60
|
+
admin.password_confirmation = options['admin_password']
|
|
61
|
+
admin.must_change_passwd = false
|
|
62
|
+
admin.save!
|
|
63
|
+
end
|
|
64
|
+
say "defaults: the REST API on, links to #{Setting.protocol}://#{Setting.host_name}"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# The sample project, made the first time, with the modules the step pack and the tracker use, and every tracker.
|
|
68
|
+
def ensure_project
|
|
69
|
+
project = Project.find_by(identifier: PROJECT_IDENTIFIER)
|
|
70
|
+
unless project
|
|
71
|
+
project = Project.new(name: PROJECT_NAME, identifier: PROJECT_IDENTIFIER, is_public: false,
|
|
72
|
+
description: 'The sample project of a Webship Workspace site: its issues, version and members are what the step pack and the tracker are tested on.')
|
|
73
|
+
project.enabled_module_names = %w[issue_tracking time_tracking news documents files wiki repository boards calendar gantt]
|
|
74
|
+
project.trackers = Tracker.all.to_a
|
|
75
|
+
fail_with("The project #{PROJECT_NAME} could not be made: #{project.errors.full_messages.join('; ')}") unless project.save
|
|
76
|
+
say "project: #{PROJECT_NAME} (#{PROJECT_IDENTIFIER}) made"
|
|
77
|
+
end
|
|
78
|
+
project
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def role_named(name)
|
|
82
|
+
Role.givable.find_by(name:) || fail_with("No role #{name} on the site.")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# The account's membership of the sample project: in the role, or none.
|
|
86
|
+
def membership(project, user, role_name)
|
|
87
|
+
member = Member.find_by(project_id: project.id, user_id: user.id)
|
|
88
|
+
if role_name.to_s.empty?
|
|
89
|
+
if member
|
|
90
|
+
member.destroy
|
|
91
|
+
say " #{user.login}: no longer a member of #{PROJECT_NAME}"
|
|
92
|
+
end
|
|
93
|
+
return
|
|
94
|
+
end
|
|
95
|
+
role = role_named(role_name)
|
|
96
|
+
member ||= Member.new(project:, user:)
|
|
97
|
+
member.role_ids = [role.id]
|
|
98
|
+
member.save!
|
|
99
|
+
say " #{user.login}: #{role.name} of #{PROJECT_NAME}"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def accounts(rows)
|
|
103
|
+
project = rows.any? { |r| !r['role'].to_s.empty? } ? ensure_project : Project.find_by(identifier: PROJECT_IDENTIFIER)
|
|
104
|
+
rows.each do |r|
|
|
105
|
+
login = r['login'].to_s
|
|
106
|
+
fail_with('An account row has no login.') if login.empty?
|
|
107
|
+
user = User.find_by(login:)
|
|
108
|
+
if r['action'] == 'lock'
|
|
109
|
+
if user.nil?
|
|
110
|
+
say " #{login}: no such account"
|
|
111
|
+
elsif user.admin?
|
|
112
|
+
say " #{login}: an administrator, left as it is"
|
|
113
|
+
else
|
|
114
|
+
user.lock!
|
|
115
|
+
say " #{login}: locked"
|
|
116
|
+
end
|
|
117
|
+
next
|
|
118
|
+
end
|
|
119
|
+
user ||= User.new
|
|
120
|
+
user.login = login
|
|
121
|
+
user.mail = r['mail'].to_s
|
|
122
|
+
user.firstname = r['firstname'].to_s.empty? ? login.capitalize : r['firstname']
|
|
123
|
+
user.lastname = r['lastname'].to_s.empty? ? 'Test' : r['lastname']
|
|
124
|
+
user.admin = true if r['admin']
|
|
125
|
+
user.status = User::STATUS_ACTIVE
|
|
126
|
+
user.language = 'en'
|
|
127
|
+
user.must_change_passwd = false
|
|
128
|
+
user.password = r['password']
|
|
129
|
+
user.password_confirmation = r['password']
|
|
130
|
+
fail_with("The account #{login} could not be saved: #{user.errors.full_messages.join('; ')}") unless user.save
|
|
131
|
+
say " #{login}: #{user.admin? ? 'administrator' : 'account'} ready (#{user.mail})"
|
|
132
|
+
membership(project, user, r['role']) if project && r.key?('role') && !r['admin']
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def make_issue(project, author, tracker, subject, body, assignee: nil, version: nil, status: nil)
|
|
137
|
+
existing = Issue.find_by(project_id: project.id, subject:)
|
|
138
|
+
return [existing, false] if existing
|
|
139
|
+
|
|
140
|
+
issue = Issue.new(project:, tracker:, author:, subject:, description: body,
|
|
141
|
+
priority: IssuePriority.default || IssuePriority.first, status: status || tracker.default_status)
|
|
142
|
+
issue.assigned_to = assignee if assignee
|
|
143
|
+
issue.fixed_version = version if version
|
|
144
|
+
fail_with("The issue \"#{subject}\" could not be made: #{issue.errors.full_messages.join('; ')}") unless issue.save
|
|
145
|
+
[issue, true]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def content
|
|
149
|
+
project = ensure_project
|
|
150
|
+
owner, member, stranger = %w[owner member stranger].map { |l| User.find_by(login: l) }
|
|
151
|
+
fail_with('The default accounts are not on the site: add them first (--add-users).') unless owner && member && stranger
|
|
152
|
+
|
|
153
|
+
version = Version.find_by(project_id: project.id, name: 'Sprint 1') ||
|
|
154
|
+
Version.create!(project:, name: 'Sprint 1', status: 'open', sharing: 'none', effective_date: Date.current + 11)
|
|
155
|
+
bug = Tracker.find_by(name: 'Bug') || Tracker.first
|
|
156
|
+
feature = Tracker.find_by(name: 'Feature') || Tracker.first
|
|
157
|
+
|
|
158
|
+
progress = IssueStatus.find_by(name: 'In Progress')
|
|
159
|
+
greeting, made = make_issue(project, owner, bug, 'The greeting script says Helo instead of Hello', <<~MD, assignee: member, version:, status: progress)
|
|
160
|
+
### Problem/Motivation
|
|
161
|
+
|
|
162
|
+
`bash greeting.sh World` prints `Helo, World!`.
|
|
163
|
+
|
|
164
|
+
### Proposed resolution
|
|
165
|
+
|
|
166
|
+
Print `Hello, World!`, and keep the usage line as it is.
|
|
167
|
+
MD
|
|
168
|
+
if made
|
|
169
|
+
# Read again first: saving the issue updated it in the database (its place in the tree), and its lock version too.
|
|
170
|
+
greeting.reload.init_journal(owner, 'The script is in the project\'s repository: `greeting.sh`.')
|
|
171
|
+
greeting.save!
|
|
172
|
+
end
|
|
173
|
+
make_issue(project, member, bug, 'The usage page spells greeting as greting', <<~MD)
|
|
174
|
+
### Problem/Motivation
|
|
175
|
+
|
|
176
|
+
The usage line of `greeting.sh` says "greting".
|
|
177
|
+
|
|
178
|
+
### Proposed resolution
|
|
179
|
+
|
|
180
|
+
Spell it "greeting".
|
|
181
|
+
MD
|
|
182
|
+
# Opened by an account with no membership: the tracker treats it as from outside the project.
|
|
183
|
+
make_issue(project, stranger, feature, 'An issue opened by someone outside the project', <<~MD)
|
|
184
|
+
Please also print the date after the greeting.
|
|
185
|
+
MD
|
|
186
|
+
say "content: #{PROJECT_NAME} holds #{Issue.where(project_id: project.id).count} issues, #{version.name} (#{version.status})"
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def tidy
|
|
190
|
+
left = Issue.where('subject LIKE ?', "#{TEST_PREFIX}%").to_a
|
|
191
|
+
left.each(&:destroy)
|
|
192
|
+
say "tidy: #{left.size} issue(s) of a stopped test run removed"
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def list
|
|
196
|
+
project = Project.find_by(identifier: PROJECT_IDENTIFIER)
|
|
197
|
+
say 'Accounts:'
|
|
198
|
+
User.where(login: DEFAULT_LOGINS).or(User.where(admin: true)).where(type: 'User').order(:id).each do |u|
|
|
199
|
+
role = project && Member.find_by(project_id: project.id, user_id: u.id)&.roles&.map(&:name)&.join(', ')
|
|
200
|
+
status = { User::STATUS_ACTIVE => 'active', User::STATUS_REGISTERED => 'registered', User::STATUS_LOCKED => 'locked' }[u.status] || u.status.to_s
|
|
201
|
+
say format(' %-12s %-28s %-10s %s', u.login, u.mail, status, u.admin? ? 'administrator' : (role.to_s.empty? ? 'no membership' : role))
|
|
202
|
+
end
|
|
203
|
+
return say("No project #{PROJECT_NAME} (#{PROJECT_IDENTIFIER}) yet: --sample-content adds it.") unless project
|
|
204
|
+
|
|
205
|
+
issues = Issue.where(project_id: project.id)
|
|
206
|
+
say "#{PROJECT_NAME} (#{PROJECT_IDENTIFIER}): #{issues.count} issues (#{issues.open.count} open), " \
|
|
207
|
+
"#{Version.where(project_id: project.id).count} version(s), #{TimeEntry.where(project_id: project.id).count} time entries"
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def token(login)
|
|
211
|
+
user = User.active.find_by(login:) || fail_with("No active account #{login} on the site.")
|
|
212
|
+
Token.where(user_id: user.id, action: 'api').delete_all
|
|
213
|
+
user.reload
|
|
214
|
+
puts "TOKEN #{user.api_key}"
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
verbs = ARGV.dup
|
|
218
|
+
fail_with('A verb, please: defaults, accounts, content, tidy, list or token.') if verbs.empty?
|
|
219
|
+
verbs.each do |verb|
|
|
220
|
+
case verb
|
|
221
|
+
when 'defaults' then defaults(input_json)
|
|
222
|
+
when 'accounts' then accounts(input_json)
|
|
223
|
+
when 'content' then content
|
|
224
|
+
when 'tidy' then tidy
|
|
225
|
+
when 'list' then list
|
|
226
|
+
when 'token' then token($stdin.gets.to_s.strip)
|
|
227
|
+
else fail_with("Not a verb: #{verb} (defaults, accounts, content, tidy, list, token).")
|
|
228
|
+
end
|
|
229
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@site
|
|
2
|
+
Feature: The issues of the site
|
|
3
|
+
A first feature of a Redmine site of the Webship Workspace, placed by the testing setup: a member logs in, reads the
|
|
4
|
+
sample project's issues and version, and works an issue of its own, which goes after the scenario. It passes on a
|
|
5
|
+
site built with --install --add-users --sample-content; add your own features beside it.
|
|
6
|
+
|
|
7
|
+
Scenario: A member reads the sample project
|
|
8
|
+
Given I am a logged in user with the "member" user
|
|
9
|
+
When I open the issues of the project "webship-site"
|
|
10
|
+
Then the issue list should show "The greeting script says Helo instead of Hello"
|
|
11
|
+
When I open the version "Sprint 1" of the project "webship-site"
|
|
12
|
+
Then the version should be "open"
|
|
13
|
+
And the version should list the issue "The greeting script says Helo instead of Hello"
|
|
14
|
+
|
|
15
|
+
Scenario: A member works an issue of its own
|
|
16
|
+
Given there is an issue "Webship test site" in the project "webship-site"
|
|
17
|
+
And I am a logged in user with the "member" user
|
|
18
|
+
When I open the issue "Webship test site"
|
|
19
|
+
And I set the status of the issue to "In Progress"
|
|
20
|
+
And I add the note "Checked on the test site" to the issue
|
|
21
|
+
And I log "0.5" hours on the issue
|
|
22
|
+
Then the issue should show the note "Checked on the test site" by "Member Test"
|
|
23
|
+
And the time spent on the issue should be "0:30 h"
|
|
24
|
+
|
|
25
|
+
@js-off
|
|
26
|
+
Scenario: An account with no membership is refused the project
|
|
27
|
+
Given I am a logged in user with the "stranger" user
|
|
28
|
+
Then I should be refused the project "webship-site"
|