[SCM] ci-tooling packaging branch, master, updated. e89eff2981466eefbf2a4ad239698253ff81f220
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Sun Jan 11 17:01:19 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=e89eff2
The following commit has been merged in the master branch:
commit e89eff2981466eefbf2a4ad239698253ff81f220
Author: Harald Sitter <sitter at kde.org>
Date: Sun Jan 11 18:01:14 2015 +0100
implement type-ness (e.g. unstable or stable) in projects
---
lib/projects.rb | 18 ++++++------
test/test-projects.rb | 80 ++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 74 insertions(+), 24 deletions(-)
diff --git a/lib/projects.rb b/lib/projects.rb
index 073dce2..ee10ed4 100644
--- a/lib/projects.rb
+++ b/lib/projects.rb
@@ -20,12 +20,12 @@ class Project
# Array of branch names that are series specific. May be empty if there are none.
attr_reader :series_branches
- # Boolean whether this project uses autopkgtest
+ # Bool whether this project uses autopkgtest
attr_reader :autopkgtest
# String of the SCM uri
attr_reader :packaging_scm
- def initialize(name, component, url_base='git.debian.org:/git/pkg-kde/')
+ def initialize(name, component, url_base='git.debian.org:/git/pkg-kde/', type:)
@name = name
@component = component
@upstream_scm = nil
@@ -34,7 +34,7 @@ class Project
@dependees = []
@series_branches = []
@autopkgtest = false
- @packaging_scm = "#{url_base}#{component}/#{name}"
+ @packaging_scm = "#{url_base}/#{component}/#{name}"
# FIXME: git dir needs to be set somewhere, somehow, somewhat, lol, kittens?
FileUtils.mkdir_p("git/#{component}") unless Dir.exist?("git/#{component}")
@@ -48,7 +48,7 @@ class Project
Dir.chdir(name) do
system("git clean -fd")
system("git reset --hard")
- system("git checkout kubuntu_unstable")
+ system("git checkout kubuntu_#{type}")
i = 0
while true and (i+=1) < 5
@@ -58,6 +58,7 @@ class Project
next unless File.exist?('debian/control')
c = DebianControl.new
+ # TODO: raise? return?
c.parse!
c.source['build-depends'].each do |dep|
@dependencies << dep.name
@@ -66,7 +67,7 @@ class Project
@provided_binaries << binary['package']
end
- branches = %x[git for-each-ref --format='%(refname)' refs/remotes/origin/kubuntu_unstable_\*].strip.lines
+ branches = %x[git for-each-ref --format='%(refname)' refs/remotes/origin/kubuntu_#{type}_\*].strip.lines
branches.each do |branch|
@series_branches << branch.gsub('refs/remotes/origin/', '')
end
@@ -89,10 +90,11 @@ class Project
end
class Projects < Array
- def initialize(allow_custom_ci: false)
+ def initialize(type: "unstable",
+ allow_custom_ci: false,
+ projects_file: File.expand_path(File.dirname(File.dirname(__FILE__))) + '/data/projects.json')
super()
- config_file_path = File.expand_path(File.dirname(File.dirname(__FILE__))) + '/data/projects.json'
- config = JSON::parse(File.read(config_file_path))
+ config = JSON::parse(File.read(projects_file))
# Get all repos inside a component.
config['all_repos'].each do |component|
diff --git a/test/test-projects.rb b/test/test-projects.rb
index 9f319c7..dfa7bdc 100644
--- a/test/test-projects.rb
+++ b/test/test-projects.rb
@@ -1,24 +1,72 @@
+require "fileutils"
require "test/unit"
+require "tmpdir"
require_relative "../lib/projects"
class ProjectTest < Test::Unit::TestCase
+ def setup
+ @testdir = File.expand_path(File.dirname(__FILE__))
+ @datadir = "#{@testdir}/data/projects"
+ end
+
+ def create_fake_git(name:, component:, branches:)
+ path = "#{component}/#{name}"
+
+ remotetmpdir = Dir.mktmpdir(self.class.to_s)
+ Dir.chdir(remotetmpdir) do
+ FileUtils.mkpath(path)
+ Dir.chdir(path) do
+ `git init --bare`
+ end
+
+ `git clone #{remotetmpdir}/tc/tn clone`
+ Dir.chdir("clone") do
+ FileUtils.cp_r("#{@datadir}/debian", ".")
+ `git add *`
+ `git commit -m 'commitmsg'`
+ branches.each { |branch| `git branch #{branch}` }
+ `git push --all origin`
+ end
+ FileUtils.rm_rf("clone")
+ end
+ return remotetmpdir
+ end
+
def test_init
- # FIXME: this should probably go into a fake git
- project = Project.new("kinfocenter", "plasma")
- assert_equal(project.name, "kinfocenter")
- assert_equal(project.component, "plasma")
- scm = project.upstream_scm
- assert_equal(scm.type, "git")
- assert_equal(scm.branch, "master")
- assert_equal(scm.url, "git://anongit.kde.org/kinfocenter")
- assert_equal(project.provided_binaries, %w(kinfocenter kinfocenter-dbg))
- # FIXME: cannot do this right now because so long...
- # assert_equal(project.dependencies, [])
- assert_equal(project.dependees, [])
- assert_equal(project.series_branches, [])
- assert_equal(project.autopkgtest, false)
- # FIXME: this is totally inconsistent with upstream_scm
- assert_equal(project.packaging_scm, "git.debian.org:/git/pkg-kde/plasma/kinfocenter")
+ name = "tn"
+ component = "tc"
+
+ %w(unstable stable).each do |stability|
+ begin
+ gitrepo = create_fake_git(name: name,
+ component: component,
+ branches: ["kubuntu_#{stability}", "kubuntu_#{stability}_yolo"])
+ assert_not_nil(gitrepo)
+ assert_not_equal(gitrepo, "")
+
+ tmpdir = Dir.mktmpdir(self.class.to_s)
+ Dir.chdir(tmpdir) do
+ project = Project.new(name, component, gitrepo, type: stability)
+ assert_equal(project.name, name)
+ assert_equal(project.component, component)
+ scm = project.upstream_scm
+ assert_equal(scm.type, "git")
+ assert_equal(scm.branch, "master")
+ assert_equal(scm.url, "git://anongit.kde.org/#{name}")
+ assert_equal(project.provided_binaries, %w(kinfocenter kinfocenter-dbg))
+ # FIXME: cannot do this right now because so long...
+ # assert_equal(project.dependencies, [])
+ assert_equal(project.dependees, [])
+ assert_equal(project.series_branches, ["kubuntu_#{stability}_yolo"])
+ assert_equal(project.autopkgtest, false)
+ # FIXME: this is totally inconsistent with upstream_scm
+ assert_equal(project.packaging_scm, "#{gitrepo}/#{component}/#{name}")
+ end
+ ensure
+ FileUtils.rm_rf(tmpdir) unless tmpdir.nil?
+ FileUtils.rm_rf(gitrepo) unless gitrepo.nil?
+ end
+ end
end
end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list