Merge pull request #12 from minrk/generate-issues

final version of generate-issues
This commit is contained in:
Michael Kohlhase 2015-09-10 06:33:53 +02:00
commit 351746cb68

View File

@ -20,9 +20,10 @@ require 'netrc'
START_DATE = Date::new(2015, 9, 1) # start date of the project
HOMEPAGE = "http://opendreamkit.org"
PROPOSAL_URL = "https://github.com/OpenDreamKit/OpenDreamKit/tree/master/Proposal/proposal-www.pdf"
PROPOSAL_URL = "https://github.com/OpenDreamKit/OpenDreamKit/raw/master/Proposal/proposal-www.pdf"
PROJECT = "OpenDreamKit"
REPO = "minrk/odktest"
REPO = "OpenDreamKit/OpenDreamKit"
TARGET = "final" # or 'proposal'
# throttle github creation requests to 5 Hz to avoid getting flagged for abuse
THROTTLE_SECONDS = 5
@ -30,7 +31,7 @@ THROTTLE_SECONDS = 5
NATURES = {
'R' => 'Report',
'DEM' => 'Demonstrator',
'DEC' => 'Websites, patents filing, press & media actions, videos, etc.',
'DEC' => 'Websites, Media, etc.',
'OTHER' => 'Other',
}
@ -63,6 +64,10 @@ SITES.each_pair do |key, name|
REVERSE_SITES[name] = key
end
# Some sites would prefer alternative abbreviations
REVERSE_SITES['University of St Andrews'] = 'USTAN'
REVERSE_SITES['Université de Versailles Saint-Quentin'] = 'UVSQ'
#------------------- Parsing proposal.pdata ---------------------
def split_line(line)
@ -125,10 +130,11 @@ end
def load_pdata(proposal_dir)
pdata = File.join(proposal_dir, 'proposal.pdata')
deliv_data = File.join(proposal_dir, 'proposal.deliverables')
pdata = File.join(proposal_dir, "#{TARGET}.pdata")
deliv_data = File.join(proposal_dir, "#{TARGET}.deliverables")
workpackages = {} # mapping of workpackage id => wp info
deliverables = {}
File.readlines(pdata).each do |line|
key, *args = split_line line
@ -171,6 +177,14 @@ def load_pdata(proposal_dir)
tasks[name] = {}
end
tasks[name][key] = value
when 'deliv'
name, key, value = args
value = transform_value(key, value)
if not deliverables.include? name
deliverables[name] = {}
end
deliverables[name][key] = value
else
# DEBUG:
@ -178,14 +192,18 @@ def load_pdata(proposal_dir)
end
end
# get deliverable data from proposal.deliverables
# get deliverable data, workpackage id from proposal.deliverables
File.readlines(deliv_data).each do |line|
args = split_line line
name = args[3]
if deliverables.include? name
deliverable = deliverables[name]
else
deliverable = {}
end
month = args[0].to_i
wpid = scrub_tex(args[7])
deliverable = {
deliverable = (deliverables[name] or {}).merge({
"month" => month,
# deliverables[deliv_id]['month'] = month
# due date is last day of the given month, so subtract one day
"due_date" => (START_DATE >> month) - 1,
"label" => scrub_tex(args[2]),
@ -194,9 +212,13 @@ def load_pdata(proposal_dir)
"nature" => transform_value('nature', args[5]),
"title" => scrub_tex(args[6]),
"lead" => SITES[scrub_tex(args[8])],
}
})
wpid = scrub_tex(args[7])
wp = workpackages.values.find {|wp| wp['label'] == wpid}
wp['deliverables'].push(deliverable)
end
workpackages.values.each do |wp|
wp['deliverables'].sort_by! {|d| d['label']}
end
@ -256,29 +278,27 @@ end
README_TPL = <<-END
# %{title}
Lead institution: %{lead}
Lead Institution: %{lead}
See page %{page} of the [proposal](#{PROPOSAL_URL}) for the full description.
END
TASK_TPL = <<-END
Work Package %{wptitle}
- **%{wplabel}:** [%{wptitle}](https://github.com/#{REPO}/tree/master/%{wplabel})
- **Lead Institution:** %{lead}
- **Partners:** %{partners}
- **Work phases:** %{wphases}
Lead Institution: %{lead}
Partners: %{partners}
Work phases: %{wphases}
See page %{page} of the [proposal](#{PROPOSAL_URL}) for the full description.
END
DELIV_TPL = <<-END
Work Package %{wptitle}
- **%{wplabel}:** [%{wptitle}](https://github.com/#{REPO}/tree/master/%{wplabel})
- **Lead Institution:** %{lead}
- **Due:** %{date} (month %{month})
- **Nature:** %{nature}
Lead Institution: %{lead}
Due: %{date} (month %{month})
Nature: %{nature}
See page %{page} of the [proposal](#{PROPOSAL_URL}) for the full description.
END
DELIV_MILESTONE_TPL = "# %{title}\n\n#{DELIV_TPL}"
@ -290,8 +310,10 @@ def make_task_issue(github, repo, task, workpackage, options)
issue = issues.find { |i| i.title.start_with?(task['label'] + ':') }
if issue.nil?
body = TASK_TPL % {
wptitle: "#{workpackage['label']}: #{workpackage['title']}",
wplabel: workpackage['label'],
wptitle: workpackage['title'],
lead: task['lead'],
page: task['page'],
wphases: task['wphases'],
partners: (task['partners'] or ['None']).join(', ')
}
@ -320,11 +342,13 @@ def make_deliverable_issue(github, repo, deliverable, workpackage, options)
issue = issues.find { |i| i.title.start_with?(deliverable['label'] + ':') }
if issue.nil?
body = DELIV_TPL % {
wptitle: "#{workpackage['label']}: #{workpackage['title']}",
wplabel: workpackage['label'],
wptitle: workpackage['title'],
lead: deliverable['lead'],
date: deliverable['due_date'],
month: deliverable['month'],
nature: deliverable['nature'],
page: deliverable['page'],
}
puts "\n\nMaking Issue on #{repo}: #{title}"
puts body
@ -351,12 +375,14 @@ def make_deliverable_milestone(github, repo, deliverable, workpackage)
if milestone.nil?
puts "Making milestone on #{repo}: #{title}"
body = DELIV_MILESTONE_TPL % {
wptitle: "#{workpackage['label']}: #{workpackage['title']}",
wplabel: workpackage['label'],
wptitle: workpackage['title'],
title: deliverable['title'],
lead: deliverable['lead'],
date: deliverable['due_date'],
month: deliverable['month'],
nature: deliverable['nature'],
page: deliverable['page'],
}
milestone = github.create_milestone(repo, title,