Skip to content

Commit 8a49291

Browse files
authored
* Fixes Open-Systems-Pharmacology#13 update coverage: * Fixes Open-Systems-Pharmacology#13 update coverage:
1 parent 93ce2ee commit 8a49291

File tree

6 files changed

+126
-6
lines changed

6 files changed

+126
-6
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,43 @@
22

33
Collection of rake tasks used during build.
44

5+
## nuget_push
6+
7+
The task `list_nuget_packages` is used to list of Open Systems Pharmacology packages that are not updated in nuget.org. That is useful in the case where nuget developers are pushing packages to the Appveyor feed and a stable version of all the packages should be copied to nuget and the packages should not be rebuilt.
8+
9+
### Usage:
10+
11+
```
12+
rake list_nuget_packages[<path to the packages folder>]
13+
```
14+
15+
### Examples
16+
17+
```
18+
rake list_nuget_packages[C:/projects/PK-Sim]
19+
rake list_nuget_packages[C:/projects/MoBi]
20+
rake list_nuget_packages[C:/projects/OSPSUite.Core]
21+
```
22+
23+
This will go over all `csproj` in the folder and find nupkg files to consider updating on Nuget.org.
24+
25+
The nupkg files will be scanned for the nuspec. If the nuspec file indicates that the owner is Open-Systems-Pharmacology, then the version and id will be read and the comparable package will be found on nuget.org.
26+
27+
If the version for that package id is not found, then the script will list the nupkg file to be pushed to nuget.org
28+
29+
Required gems are
30+
31+
- rubyzip
32+
- xml-simple
33+
534
## Code of conduct
35+
636
Everyone interacting in the Open Systems Pharmacology community (codebases, issue trackers, chat rooms, mailing lists etc...) is expected to follow the Open Systems Pharmacology [code of conduct](https://github.com/Open-Systems-Pharmacology/Suite/blob/master/CODE_OF_CONDUCT.md).
737

838
## Contribution
39+
940
We encourage contribution to the Open Systems Pharmacology community. Before getting started please read the [contribution guidelines](https://github.com/Open-Systems-Pharmacology/Suite/blob/master/CONTRIBUTING.md). If you are contributing code, please be familiar with the [coding standard](https://github.com/Open-Systems-Pharmacology/Suite/blob/master/CODING_STANDARDS.md).
1041

1142
## License
43+
1244
build-scripts is released under the [GPLv2 License](LICENSE).

copy-dependencies.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# => copy_native_dll
99
# => end
1010

11-
def copy_depdencies(source_dir, target_dir, &block)
11+
def copy_dependencies(source_dir, target_dir, &block)
1212
dependecyManager = DependencyManager.new(source_dir, target_dir)
1313
dependecyManager.instance_eval(&block)
1414
dependecyManager.perform_file_copy
@@ -48,7 +48,7 @@ def copy_files(subfolder, file_extensions)
4848
def perform_file_copy
4949
retrieve_target_dir do |target_dir|
5050
FileUtils.mkdir_p target_dir
51-
copy_depdencies_to target_dir
51+
copy_dependencies_to target_dir
5252
end
5353
end
5454

@@ -67,7 +67,7 @@ def method_missing(method_name, *args)
6767

6868
private
6969

70-
def copy_depdencies_to(target_dir)
70+
def copy_dependencies_to(target_dir)
7171
dependencies.each do |dep|
7272
Dir.glob(dep).each do |f|
7373
puts "Copying #{f} to #{target_dir}".green

coverage.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def self.cover(filter_array, targetProjects)
66
openCover = Dir.glob("packages/OpenCover.*/tools/OpenCover.Console.exe").first
77
targetArgs = testProjects.join(" ")
88

9-
Utils.run_cmd(openCover, ["-register:user", "-target:nunit3-console.exe", "-targetargs:#{targetArgs}", "-output:OpenCover.xml", "-filter:#{filter_array.join(" ")}", "-excludebyfile:*.Designer.cs"])
9+
Utils.run_cmd(openCover, ["-register:path64", "-target:nunit3-console.exe", "-targetargs:#{targetArgs}", "-output:OpenCover.xml", "-filter:#{filter_array.join(" ")}", "-excludebyfile:*.Designer.cs"])
1010
Utils.run_cmd("codecov", ["-f", "OpenCover.xml"])
1111
end
12-
end
12+
end

nuget_push.rb

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
require 'zip'
2+
require 'xmlsimple'
3+
require 'open-uri'
4+
5+
def print_all_packages_to_upload_from(directory)
6+
packages = all_open_pharma_packages(directory)
7+
8+
packages.each do |id, package|
9+
if(!nuget_has_version(package))
10+
push_to_nuget(package)
11+
end
12+
end
13+
end
14+
15+
16+
def all_open_pharma_packages(directory)
17+
projects = Dir.glob(File.join(directory, "**", "*.csproj"));
18+
19+
packages = {};
20+
projects.each do |path|
21+
project = Project.new path
22+
project.packages.each do |package|
23+
package_id = package.id
24+
if(packages.key?(package_id))
25+
existing_version = packages[package_id].version;
26+
if(existing_version!=package.version)
27+
raise "Different version found for package #{package_id}: (#{existing_version} vs #{package.version})"
28+
end
29+
else
30+
packages[package_id] = package
31+
end
32+
end
33+
end
34+
35+
return packages;
36+
end
37+
38+
def nuget_has_version(package)
39+
begin
40+
file = open("https://www.nuget.org/packages/#{package.id}")
41+
contents = file.read
42+
contents.include? package.version
43+
rescue
44+
false
45+
end
46+
end
47+
48+
def push_to_nuget(package)
49+
#todo make this execute
50+
# puts "nuget push #{package.id} -apikey somekey -Source https://www.nuget.org/api/v2/package"
51+
puts "Package to update: #{package.id} with version #{package.version}"
52+
end
53+
54+
class Project
55+
attr_reader :packages
56+
57+
def initialize(path)
58+
@path = path
59+
@packages = []
60+
project_xml = XmlSimple.xml_in(path)
61+
project_xml["ItemGroup"].each do |item_group|
62+
pagckage_ref = item_group["PackageReference"];
63+
next if !pagckage_ref
64+
65+
pagckage_ref.each do |package|
66+
id = package["Include"]
67+
next if !id.start_with?("OSPSuite")
68+
packages.push Package.new(id, package["Version"])
69+
end
70+
end
71+
end
72+
end
73+
74+
class Package
75+
def initialize(id, version)
76+
@version = version
77+
@id = id
78+
end
79+
80+
attr_reader :id
81+
82+
attr_reader :version
83+
end

rakefile.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require_relative 'nuget_push'
2+
3+
task :list_nuget_packages, [:directory] do |cmd, args|
4+
print_all_packages_to_upload_from args.directory
5+
end

smartxls.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def self.update_smart_xls(source_dir, smart_xls_package, sx_version)
66
unzip_dir = File.dirname(smart_xls_package)
77
command_line = %W[e #{smart_xls_package} -o#{unzip_dir}]
88
Utils.run_cmd('7z', command_line)
9-
copy_depdencies unzip_dir, source_dir do
9+
copy_dependencies unzip_dir, source_dir do
1010
copy_file 'SX.dll'
1111
end
1212

0 commit comments

Comments
 (0)