aboutsummaryrefslogtreecommitdiff
path: root/tests/ci
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ci')
-rw-r--r--tests/ci/8716f424-fd94-4def-9e2e-687203bbf4ad/request.manifest1
-rw-r--r--tests/ci/README29
-rw-r--r--tests/ci/ci-dir.testscript8
-rw-r--r--tests/ci/ci-load.testscript172
-rw-r--r--tests/ci/data.testscript9
-rw-r--r--tests/ci/hello.tar.gzbin0 -> 102400 bytes
6 files changed, 184 insertions, 35 deletions
diff --git a/tests/ci/8716f424-fd94-4def-9e2e-687203bbf4ad/request.manifest b/tests/ci/8716f424-fd94-4def-9e2e-687203bbf4ad/request.manifest
index 3ef553a..229e5ed 100644
--- a/tests/ci/8716f424-fd94-4def-9e2e-687203bbf4ad/request.manifest
+++ b/tests/ci/8716f424-fd94-4def-9e2e-687203bbf4ad/request.manifest
@@ -1,7 +1,6 @@
: 1
id: 8716f424-fd94-4def-9e2e-687203bbf4ad
repository: https://git.build2.org/hello/hello.git#master
-package: hello
timestamp: 2018-09-01T08:38:55Z
client-ip: fe80::56e1:adff:fe83:82f5
user-agent: curl/7.59.0
diff --git a/tests/ci/README b/tests/ci/README
index 14defe5..94a87b6 100644
--- a/tests/ci/README
+++ b/tests/ci/README
@@ -1,11 +1,34 @@
Prepare the test data with the following instructions.
+Create the git repository:
+
+$ mkdir hello.git
+$ git -C hello.git/ init --bare
+
+Create the project:
+
+$ bdep new -t empty hello
+$ BDEP_AUTHOR_EMAIL=user@example.org bdep new --package -t lib libhello -d hello
+$ BDEP_AUTHOR_EMAIL=user@example.org bdep new --package -t exe hello -d hello
+
+Edit hello/libhello/manifest and hello/hello/manifest files setting version to
+0.1.0.
+
+$ git -C hello remote add origin "$(pwd)/hello.git"
+$ git -C hello add '*'
+$ git -C hello commit -m "Create"
+$ git -C hello push --set-upstream origin master
+
+$ tar cf hello.tar.gz hello.git/
+
+Move the archive into tests/ci/ directory.
+
Locally run brep server configured to use ci-dir handler.
$ curl \
--form-string repository=https://git.build2.org/hello/hello.git#master \
---form-string package=hello \
http://localhost/pkg?ci
-Replace the submission data directory in brep/tests/ci/ with the one produced
-with the above command, removing all files it contains except request.manifest.
+Replace the CI request data directory in tests/ci/ with the one produced by
+the above command removing all entries it contains except request.manifest
+file.
diff --git a/tests/ci/ci-dir.testscript b/tests/ci/ci-dir.testscript
index 8388616..f6ff9d3 100644
--- a/tests/ci/ci-dir.testscript
+++ b/tests/ci/ci-dir.testscript
@@ -17,6 +17,14 @@
$* $~/dir 2>>~%EOE% != 0
%\[.+\] \[brep:error\] \[ref dir\] \[brep-ci-dir\]: '.+dir' does not exist or is not a directory%
EOE
+
+ : slash-stripped
+ :
+ : Test that the trailing slash is stripped from the data directory path.
+ :
+ $* $~/dir/ 2>>~%EOE% != 0
+ %\[.+\] \[brep:error\] \[ref dir\] \[brep-ci-dir\]: '.+dir' does not exist or is not a directory%
+ EOE
}
: success
diff --git a/tests/ci/ci-load.testscript b/tests/ci/ci-load.testscript
index c574a32..ce8daf9 100644
--- a/tests/ci/ci-load.testscript
+++ b/tests/ci/ci-load.testscript
@@ -23,6 +23,14 @@
$* brep-load $~/dir 2>>~%EOE% != 0
%\[.+\] \[brep:error\] \[ref dir\] \[brep-ci-load\]: '.+dir' does not exist or is not a directory%
EOE
+
+ : slash-stripped
+ :
+ : Test that the trailing slash is stripped from the data directory path.
+ :
+ $* brep-load $~/dir/ 2>>~%EOE% != 0
+ %\[.+\] \[brep:error\] \[ref dir\] \[brep-ci-load\]: '.+dir' does not exist or is not a directory%
+ EOE
}
: success
@@ -48,12 +56,13 @@
: for-real
:
{
- # Create the loader script that validates the arguments passed and the
- # files produced by the handler.
+ # Create the loader script that validates the arguments passed and prints
+ # the loadtab, repositories manifest, and packages manifest files to
+ # stderr.
#
loader=$~/brep-load
- cat <<"EOI" >=$loader;
+ +cat <<"EOI" >=$loader
#!/usr/bin/env bash
if [ "\$#" != 7 -o \
"\$1" != "--db-host=localhost" -o \
@@ -62,38 +71,139 @@
"\$4" != "--shallow" -o \
"\$5" != "--tenant" -o \
-z "\$6" -o \
- "\$7" != "$data_dir/loadtab" -o \
- ! -f "$data_dir/cache/repositories.manifest" -o \
- ! -f "$data_dir/cache/packages.manifest" ]; then
- exit 1
- fi
- if ! diff "$data_dir/loadtab" - <<<"https://git.build2.org/hello/hello.git#master hello cache:cache"; then
+ "\$7" != "$data_dir/loadtab" ]; then
exit 1
fi
+ cat \
+ "$data_dir/loadtab" \
+ "$data_dir/cache/repositories.manifest" \
+ "$data_dir/cache/packages.manifest" >&2
EOI
- chmod 755 $loader;
-
- $clone_root_data;
-
- $* $loader --db-host=localhost --db-port=8432 $data_dir >>"EOO";
- : 1
- status: 200
- message: CI request is queued
- reference: $request_id
- EOO
-
- $clone_root_data;
-
- $* --result-url "http://example.com/" \
- $loader --db-host=localhost --db-port=8432 \
- $data_dir >>~"%EOO%"
- : 1
- status: 200
- %message: CI request is queued: http://example.com/@.+%
- %.
- reference: $request_id
- EOO
+ +chmod 755 $loader
+
+ : whole-repo
+ :
+ {
+ $clone_root_data;
+
+ $* $loader --db-host=localhost --db-port=8432 $data_dir >>"EOO" 2>>~"%EOE%"
+ : 1
+ status: 200
+ message: CI request is queued
+ reference: $request_id
+ EOO
+ $rep hello cache:cache
+ : 1
+ summary: hello project repository
+ : 1
+ name: libhello
+ version: 0.1.0
+ project: hello
+ summary: hello library
+ license: TODO
+ url: https://example.org/hello
+ email: user@example.org
+ %depends: \\* build2 .+%
+ %depends: \\* bpkg .+%
+ location: libhello
+ %fragment: .+%
+ :
+ name: hello
+ version: 0.1.0
+ summary: hello executable
+ license: TODO
+ url: https://example.org/hello
+ email: user@example.org
+ %depends: \\* build2 .+%
+ %depends: \\* bpkg .+%
+ location: hello
+ %fragment: .+%
+ EOE
+ }
+
+ : package
+ :
+ {
+ $clone_root_data;
+
+ cat <<EOI >+$data_dir/request.manifest;
+ package: hello
+ EOI
+
+ $* $loader --db-host=localhost --db-port=8432 $data_dir >>"EOO" 2>>~"%EOE%"
+ : 1
+ status: 200
+ message: CI request is queued
+ reference: $request_id
+ EOO
+ $rep hello cache:cache
+ : 1
+ summary: hello project repository
+ : 1
+ name: hello
+ version: 0.1.0
+ summary: hello executable
+ license: TODO
+ url: https://example.org/hello
+ email: user@example.org
+ %depends: \\* build2 .+%
+ %depends: \\* bpkg .+%
+ location: hello
+ %fragment: .+%
+ EOE
+ }
+
+ : package-version
+ :
+ {
+ $clone_root_data;
+
+ cat <<EOI >+$data_dir/request.manifest;
+ package: libhello/0.1.0
+ EOI
+
+ $* $loader --db-host=localhost --db-port=8432 $data_dir >>"EOO" 2>>~"%EOE%"
+ : 1
+ status: 200
+ message: CI request is queued
+ reference: $request_id
+ EOO
+ $rep hello cache:cache
+ : 1
+ summary: hello project repository
+ : 1
+ name: libhello
+ version: 0.1.0
+ project: hello
+ summary: hello library
+ license: TODO
+ url: https://example.org/hello
+ email: user@example.org
+ %depends: \\* build2 .+%
+ %depends: \\* bpkg .+%
+ location: libhello
+ %fragment: .+%
+ EOE
+ }
+
+ : result-url
+ :
+ {
+ $clone_root_data;
+
+ $* --result-url "http://example.com/" \
+ $loader --db-host=localhost --db-port=8432 \
+ $data_dir >>~"%EOO%" 2>>~%EOE%
+ : 1
+ status: 200
+ %message: CI request is queued: http://example.com/@.+%
+ %.
+ reference: $request_id
+ EOO
+ %.*:.*%+
+ EOE
+ }
}
}
diff --git a/tests/ci/data.testscript b/tests/ci/data.testscript
index 711c7b1..662a14c 100644
--- a/tests/ci/data.testscript
+++ b/tests/ci/data.testscript
@@ -17,10 +17,19 @@ data_dir = $regex.replace($path_search('*/request.manifest', $src_base), \
request_id = "$data_dir"
+# Prepare the repository.
+#
+rep="file:$~/hello.git#master"
++tar -C $~ -xf $src_base/hello.tar.gz &hello.git/***
+
# Copy the original CI request data directory to the root scope.
#
+cp -r $src_base/$data_dir ./
+# Fix-up the repository value in the request manifest.
+#
++sed -i -e "s%^\(repository:\) .+\$%\\1 $rep%" $data_dir/request.manifest
+
root_data_dir = $~/$data_dir
# The most commonly used submission data directory cloning command that copies
diff --git a/tests/ci/hello.tar.gz b/tests/ci/hello.tar.gz
new file mode 100644
index 0000000..d264888
--- /dev/null
+++ b/tests/ci/hello.tar.gz
Binary files differ