[SCM] ci-tooling packaging branch, master, updated. d136fcce5d4d58c0238cdae0b72fb60090fd051e
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Thu Oct 15 13:41:05 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=7940daa
The following commit has been merged in the master branch:
commit 7940daa97278f4f5fab979723a809e13dcdcfef3
Author: Harald Sitter <sitter at kde.org>
Date: Thu Oct 15 11:54:32 2015 +0200
new tarfetcher classes URL and Watch to isolate tarball retrieval
---
lib/ci/tar_fetcher.rb | 45 ++++++++++++++++++
.../test_run/packaging/debian | 1 +
test/data/test_ci_tar_fetcher/test_fetch.yml | 44 ++++++++++++++++++
test/data/test_ci_tar_fetcher/test_fetch_orig.yml | 44 ++++++++++++++++++
.../test_watch_fetch}/debian/changelog | 0
.../test_watch_fetch}/debian/compat | 0
.../test_watch_fetch}/debian/control | 0
.../test_watch_fetch}/debian/rules | 0
.../test_watch_fetch}/debian/source/format | 0
.../test_watch_fetch}/debian/watch | 0
test/test_ci_tar_fetcher.rb | 53 ++++++++++++++++++++++
11 files changed, 187 insertions(+)
diff --git a/lib/ci/tar_fetcher.rb b/lib/ci/tar_fetcher.rb
new file mode 100644
index 0000000..48a4091
--- /dev/null
+++ b/lib/ci/tar_fetcher.rb
@@ -0,0 +1,45 @@
+require 'open-uri'
+
+require_relative 'tarball'
+
+module CI
+ class WatchTarFetcher
+ def initialize(watchfile)
+ unless File.basename(watchfile) == 'watch'
+ fail "path not a watch file #{watchfile}"
+ end
+ debiandir = File.dirname(File.absolute_path(watchfile))
+ unless File.basename(debiandir) == 'debian'
+ fail "path not a debian dir #{debiandir}"
+ end
+ @dir = File.dirname(debiandir)
+ end
+
+ def fetch(destdir)
+ Dir.chdir(@dir) do
+ system('uscan',
+ '--report-status',
+ '--force-download',
+ '--download-current-version',
+ "--destdir=#{destdir}")
+ end
+ # FIXME: return tarball
+ end
+ end
+
+ class URLTarFetcher
+ def initialize(url)
+ @uri = URI.parse(url)
+ end
+
+ def fetch(destdir)
+ filename = File.basename(@uri.path)
+ target = File.join(destdir, filename)
+ File.write(target, open(@uri).read)
+ Tarball.new(target)
+ end
+ end
+
+ # TODO fetch from a repo's deb-src?
+ class RepoTarFetcher; end
+end
diff --git a/test/data/test_ci_orig_source_builder/test_run/packaging/debian b/test/data/test_ci_orig_source_builder/test_run/packaging/debian
new file mode 120000
index 0000000..9f96486
--- /dev/null
+++ b/test/data/test_ci_orig_source_builder/test_run/packaging/debian
@@ -0,0 +1 @@
+../../../test_ci_tar_fetcher/test_watch_fetch/debian
\ No newline at end of file
diff --git a/test/data/test_ci_tar_fetcher/test_fetch.yml b/test/data/test_ci_tar_fetcher/test_fetch.yml
new file mode 100644
index 0000000..541bb2e
--- /dev/null
+++ b/test/data/test_ci_tar_fetcher/test_fetch.yml
@@ -0,0 +1,44 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://people.ubuntu.com/~apachelogger/.static/testu-1.0.tar.xz
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ User-Agent:
+ - Ruby
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Date:
+ - Thu, 15 Oct 2015 09:26:41 GMT
+ Server:
+ - Apache/2.2.22 (Ubuntu)
+ Last-Modified:
+ - Thu, 15 Oct 2015 08:18:24 GMT
+ Etag:
+ - '"9c8339-a8-52220529ef400"'
+ Accept-Ranges:
+ - bytes
+ Content-Length:
+ - '168'
+ Content-Type:
+ - application/x-tar
+ body:
+ encoding: ASCII-8BIT
+ string: !binary |-
+ /Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4Cf/AGZdADoZSs4gy/DAYrgNf3R0
+ bBAjL2HxhxIEwzzFax8cZh2NARLZrDpb6KOBD93j5NFDuCu6bDyTXMvo27tL
+ twesux291KizGlN4gUK+CXv//jz4evTfMJts6/ddQp6atO1F5tCbPiZ7AAAA
+ AJ3+0sjUXcMjAAGCAYBQAAA10KgsscRn+wIAAAAABFla
+ http_version:
+ recorded_at: Thu, 15 Oct 2015 09:26:41 GMT
+recorded_with: VCR 2.9.3
diff --git a/test/data/test_ci_tar_fetcher/test_fetch_orig.yml b/test/data/test_ci_tar_fetcher/test_fetch_orig.yml
new file mode 100644
index 0000000..3172a16
--- /dev/null
+++ b/test/data/test_ci_tar_fetcher/test_fetch_orig.yml
@@ -0,0 +1,44 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://people.ubuntu.com/~apachelogger/.static/testu_1.0.orig.tar.xz
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ User-Agent:
+ - Ruby
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Date:
+ - Thu, 15 Oct 2015 09:28:23 GMT
+ Server:
+ - Apache/2.2.22 (Ubuntu)
+ Last-Modified:
+ - Thu, 15 Oct 2015 08:18:24 GMT
+ Etag:
+ - '"9c833a-a8-52220529ef400"'
+ Accept-Ranges:
+ - bytes
+ Content-Length:
+ - '168'
+ Content-Type:
+ - application/x-tar
+ body:
+ encoding: ASCII-8BIT
+ string: !binary |-
+ /Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4Cf/AGZdADoZSs4gy/DAYrgNf3R0
+ bBAjL2HxhxIEwzzFax8cZh2NARLZrDpb6KOBD93j5NFDuCu6bDyTXMvo27tL
+ twesux291KizGlN4gUK+CXv//jz4evTfMJts6/ddQp6atO1F5tCbPiZ7AAAA
+ AJ3+0sjUXcMjAAGCAYBQAAA10KgsscRn+wIAAAAABFla
+ http_version:
+ recorded_at: Thu, 15 Oct 2015 09:28:23 GMT
+recorded_with: VCR 2.9.3
diff --git a/test/data/test_ci_orig_source_builder/test_run/packaging/debian/changelog b/test/data/test_ci_tar_fetcher/test_watch_fetch/debian/changelog
similarity index 100%
rename from test/data/test_ci_orig_source_builder/test_run/packaging/debian/changelog
rename to test/data/test_ci_tar_fetcher/test_watch_fetch/debian/changelog
diff --git a/test/data/test_ci_orig_source_builder/test_run/packaging/debian/compat b/test/data/test_ci_tar_fetcher/test_watch_fetch/debian/compat
similarity index 100%
rename from test/data/test_ci_orig_source_builder/test_run/packaging/debian/compat
rename to test/data/test_ci_tar_fetcher/test_watch_fetch/debian/compat
diff --git a/test/data/test_ci_orig_source_builder/test_run/packaging/debian/control b/test/data/test_ci_tar_fetcher/test_watch_fetch/debian/control
similarity index 100%
rename from test/data/test_ci_orig_source_builder/test_run/packaging/debian/control
rename to test/data/test_ci_tar_fetcher/test_watch_fetch/debian/control
diff --git a/test/data/test_ci_orig_source_builder/test_run/packaging/debian/rules b/test/data/test_ci_tar_fetcher/test_watch_fetch/debian/rules
similarity index 100%
rename from test/data/test_ci_orig_source_builder/test_run/packaging/debian/rules
rename to test/data/test_ci_tar_fetcher/test_watch_fetch/debian/rules
diff --git a/test/data/test_ci_orig_source_builder/test_run/packaging/debian/source/format b/test/data/test_ci_tar_fetcher/test_watch_fetch/debian/source/format
similarity index 100%
rename from test/data/test_ci_orig_source_builder/test_run/packaging/debian/source/format
rename to test/data/test_ci_tar_fetcher/test_watch_fetch/debian/source/format
diff --git a/test/data/test_ci_orig_source_builder/test_run/packaging/debian/watch b/test/data/test_ci_tar_fetcher/test_watch_fetch/debian/watch
similarity index 100%
rename from test/data/test_ci_orig_source_builder/test_run/packaging/debian/watch
rename to test/data/test_ci_tar_fetcher/test_watch_fetch/debian/watch
diff --git a/test/test_ci_tar_fetcher.rb b/test/test_ci_tar_fetcher.rb
new file mode 100644
index 0000000..a0ba43f
--- /dev/null
+++ b/test/test_ci_tar_fetcher.rb
@@ -0,0 +1,53 @@
+require 'vcr'
+
+require_relative 'lib/testcase'
+
+require_relative '../lib/ci/tar_fetcher'
+
+module CI
+ class TarFetcherTest < TestCase
+ def setup
+ VCR.configure do |config|
+ config.cassette_library_dir = @datadir
+ config.hook_into :webmock
+ config.default_cassette_options = {
+ match_requests_on: [:method, :uri, :body]
+ }
+ end
+ end
+
+ def test_fetch
+ VCR.use_cassette(__method__) do
+ f = URLTarFetcher.new('http://people.ubuntu.com/~apachelogger/.static/testu-1.0.tar.xz')
+ t = f.fetch(Dir.pwd)
+ assert(t.is_a?(Tarball))
+ assert_path_exist('testu-1.0.tar.xz')
+ assert_false(t.orig?)
+ assert_equal('testu_1.0.orig.tar.xz', File.basename(t.origify.path))
+ end
+ end
+
+ def test_fetch_orig
+ VCR.use_cassette(__method__) do
+ f = URLTarFetcher.new('http://people.ubuntu.com/~apachelogger/.static/testu_1.0.orig.tar.xz')
+ t = f.fetch(Dir.pwd)
+ assert(t.orig?)
+ end
+ end
+
+ # TODO: maybe split
+ def test_watch_fetch
+ assert_raise RuntimeError do
+ WatchTarFetcher.new('/a/b/c')
+ # Not a watch
+ end
+ assert_raise RuntimeError do
+ WatchTarFetcher.new('/a/b/watch')
+ # Not a debian dir
+ end
+
+ f = WatchTarFetcher.new(data('debian/watch'))
+ f.fetch(Dir.pwd)
+ end
+ end
+end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list