aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-04-01 21:50:16 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-04-06 18:42:14 +0300
commitf11d8c32c01ab1ac13268484b9e85732176a47d9 (patch)
tree960473ad9016458dde5f8a092b9715c77888aaac /libbrep
parentca708a3f172e2f0ffab8638087b3e478de06b996 (diff)
Add support for test-exclude task manifest value
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/build-extra.sql71
-rw-r--r--libbrep/build-package.hxx27
-rw-r--r--libbrep/build.hxx2
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/common.cxx26
-rw-r--r--libbrep/common.hxx32
-rw-r--r--libbrep/package.cxx21
-rw-r--r--libbrep/package.hxx41
-rw-r--r--libbrep/package.xml6
9 files changed, 201 insertions, 27 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index 9ecbcb1..b466382 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -10,6 +10,12 @@ DROP FOREIGN TABLE IF EXISTS build_package_constraints;
DROP FOREIGN TABLE IF EXISTS build_package_builds;
+DROP FOREIGN TABLE IF EXISTS build_package_benchmarks;
+
+DROP FOREIGN TABLE IF EXISTS build_package_examples;
+
+DROP FOREIGN TABLE IF EXISTS build_package_tests;
+
DROP FOREIGN TABLE IF EXISTS build_package;
DROP FOREIGN TABLE IF EXISTS build_repository;
@@ -18,7 +24,6 @@ DROP FOREIGN TABLE IF EXISTS build_tenant;
-- The foreign table for build_tenant object.
--
---
CREATE FOREIGN TABLE build_tenant (
id TEXT NOT NULL,
archived BOOLEAN NOT NULL)
@@ -26,7 +31,6 @@ SERVER package_server OPTIONS (table_name 'tenant');
-- The foreign table for build_repository object.
--
---
CREATE FOREIGN TABLE build_repository (
tenant TEXT NOT NULL,
canonical_name TEXT NOT NULL,
@@ -37,7 +41,6 @@ SERVER package_server OPTIONS (table_name 'repository');
-- The foreign table for build_package object.
--
---
CREATE FOREIGN TABLE build_package (
tenant TEXT NOT NULL,
name CITEXT NOT NULL,
@@ -52,9 +55,68 @@ CREATE FOREIGN TABLE build_package (
buildable BOOLEAN NOT NULL)
SERVER package_server OPTIONS (table_name 'package');
--- The foreign table for the build_package object builds member (that is of a
+-- The foreign table for the build_package object tests member (that is of a
-- container type).
--
+CREATE FOREIGN TABLE build_package_tests (
+ tenant TEXT NOT NULL,
+ name CITEXT NOT NULL,
+ version_epoch INTEGER NOT NULL,
+ version_canonical_upstream TEXT NOT NULL,
+ version_canonical_release TEXT NOT NULL COLLATE "C",
+ version_revision INTEGER NOT NULL,
+ index BIGINT NOT NULL,
+ dep_name CITEXT NOT NULL,
+ dep_package_tenant TEXT NULL,
+ dep_package_name CITEXT NULL,
+ dep_package_version_epoch INTEGER NULL,
+ dep_package_version_canonical_upstream TEXT NULL,
+ dep_package_version_canonical_release TEXT NULL COLLATE "C",
+ dep_package_version_revision INTEGER NULL)
+SERVER package_server OPTIONS (table_name 'package_tests');
+
+-- The foreign table for the build_package object examples member (that is of a
+-- container type).
+--
+CREATE FOREIGN TABLE build_package_examples (
+ tenant TEXT NOT NULL,
+ name CITEXT NOT NULL,
+ version_epoch INTEGER NOT NULL,
+ version_canonical_upstream TEXT NOT NULL,
+ version_canonical_release TEXT NOT NULL COLLATE "C",
+ version_revision INTEGER NOT NULL,
+ index BIGINT NOT NULL,
+ dep_name CITEXT NOT NULL,
+ dep_package_tenant TEXT NULL,
+ dep_package_name CITEXT NULL,
+ dep_package_version_epoch INTEGER NULL,
+ dep_package_version_canonical_upstream TEXT NULL,
+ dep_package_version_canonical_release TEXT NULL COLLATE "C",
+ dep_package_version_revision INTEGER NULL)
+SERVER package_server OPTIONS (table_name 'package_examples');
+
+-- The foreign table for the build_package object benchmarks member (that is
+-- of a container type).
+--
+CREATE FOREIGN TABLE build_package_benchmarks (
+ tenant TEXT NOT NULL,
+ name CITEXT NOT NULL,
+ version_epoch INTEGER NOT NULL,
+ version_canonical_upstream TEXT NOT NULL,
+ version_canonical_release TEXT NOT NULL COLLATE "C",
+ version_revision INTEGER NOT NULL,
+ index BIGINT NOT NULL,
+ dep_name CITEXT NOT NULL,
+ dep_package_tenant TEXT NULL,
+ dep_package_name CITEXT NULL,
+ dep_package_version_epoch INTEGER NULL,
+ dep_package_version_canonical_upstream TEXT NULL,
+ dep_package_version_canonical_release TEXT NULL COLLATE "C",
+ dep_package_version_revision INTEGER NULL)
+SERVER package_server OPTIONS (table_name 'package_benchmarks');
+
+-- The foreign table for the build_package object builds member (that is of a
+-- container type).
--
CREATE FOREIGN TABLE build_package_builds (
tenant TEXT NOT NULL,
@@ -71,7 +133,6 @@ SERVER package_server OPTIONS (table_name 'package_builds');
-- The foreign table for the build_package object constraints member (that is
-- of a container type).
--
---
CREATE FOREIGN TABLE build_package_constraints (
tenant TEXT NOT NULL,
name CITEXT NOT NULL,
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 702f937..228c5c0 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -68,6 +68,19 @@ namespace brep
build_repository (): canonical_name (id.canonical_name) {}
};
+ // Forward declarations.
+ //
+ class build_package;
+
+ // Build package test dependency.
+ //
+ #pragma db value
+ struct build_dependency
+ {
+ package_name name;
+ lazy_shared_ptr<build_package> package;
+ };
+
// Foreign object that is mapped to a subset of the package object.
//
#pragma db object table("build_package") pointer(shared_ptr) readonly session
@@ -76,6 +89,14 @@ namespace brep
public:
package_id id;
upstream_version version;
+
+ // Mapped to the package object tests, examples, and benchmarks members
+ // using the PostgreSQL foreign table mechanism.
+ //
+ small_vector<build_dependency, 1> tests;
+ small_vector<build_dependency, 1> examples;
+ small_vector<build_dependency, 1> benchmarks;
+
lazy_shared_ptr<build_repository> internal_repository;
bool buildable;
@@ -89,10 +110,16 @@ namespace brep
//
build_constraints constraints;
+ bool
+ internal () const noexcept {return internal_repository != nullptr;}
+
// Database mapping.
//
#pragma db member(id) id column("")
#pragma db member(version) set(this.version.init (this.id.version, (?)))
+ #pragma db member(tests) id_column("") value_column("dep_")
+ #pragma db member(examples) id_column("") value_column("dep_")
+ #pragma db member(benchmarks) id_column("") value_column("dep_")
#pragma db member(builds) id_column("") value_column("")
#pragma db member(constraints) id_column("") value_column("")
diff --git a/libbrep/build.hxx b/libbrep/build.hxx
index 83b30a8..a883fa0 100644
--- a/libbrep/build.hxx
+++ b/libbrep/build.hxx
@@ -25,7 +25,7 @@
//
#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 9
-#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 10, closed)
+#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 11, closed)
// We have to keep these mappings at the global scope instead of inside
// the brep namespace because they need to be also effective in the
diff --git a/libbrep/build.xml b/libbrep/build.xml
index bf8920b..f4ba6cb 100644
--- a/libbrep/build.xml
+++ b/libbrep/build.xml
@@ -1,4 +1,6 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="11"/>
+
<changeset version="10">
<alter-table name="build">
<add-column name="completion_timestamp" type="BIGINT" null="false" default="0"/>
diff --git a/libbrep/common.cxx b/libbrep/common.cxx
index 2e9ff34..8964e0a 100644
--- a/libbrep/common.cxx
+++ b/libbrep/common.cxx
@@ -6,4 +6,30 @@
namespace brep
{
const version wildcard_version (0, "0", nullopt, nullopt, 0);
+
+ // unbuildable_reason
+ //
+ string
+ to_string (unbuildable_reason r)
+ {
+ switch (r)
+ {
+ case unbuildable_reason::stub: return "stub";
+ case unbuildable_reason::test: return "test";
+ case unbuildable_reason::external: return "external";
+ case unbuildable_reason::unbuildable: return "unbuildable";
+ }
+
+ return string (); // Should never reach.
+ }
+
+ unbuildable_reason
+ to_unbuildable_reason (const string& r)
+ {
+ if (r == "stub") return unbuildable_reason::stub;
+ else if (r == "test") return unbuildable_reason::test;
+ else if (r == "external") return unbuildable_reason::external;
+ else if (r == "unbuildable") return unbuildable_reason::unbuildable;
+ else throw invalid_argument ("invalid unbuildable reason '" + r + "'");
+ }
}
diff --git a/libbrep/common.hxx b/libbrep/common.hxx
index b7fc2da..73353c7 100644
--- a/libbrep/common.hxx
+++ b/libbrep/common.hxx
@@ -323,6 +323,38 @@ namespace brep
#pragma db value(build_constraint) definition
+ // The primary reason why a package is unbuildable by the build bot
+ // controller service.
+ //
+ enum class unbuildable_reason: std::uint8_t
+ {
+ stub, // A stub, otherwise
+ test, // A separate test (built as part of primary), otherwise
+ external, // From an external repository, otherwise
+ unbuildable // From an internal unbuildable repository.
+ };
+
+ string
+ to_string (unbuildable_reason);
+
+ unbuildable_reason
+ to_unbuildable_reason (const string&); // May throw invalid_argument.
+
+ inline ostream&
+ operator<< (ostream& os, unbuildable_reason r) {return os << to_string (r);}
+
+ using optional_unbuildable_reason = optional<unbuildable_reason>;
+
+ #pragma db map type(unbuildable_reason) as(string) \
+ to(to_string (?)) \
+ from(brep::to_unbuildable_reason (?))
+
+ #pragma db map type(optional_unbuildable_reason) as(brep::optional_string) \
+ to((?) ? to_string (*(?)) : brep::optional_string ()) \
+ from((?) \
+ ? brep::to_unbuildable_reason (*(?)) \
+ : brep::optional_unbuildable_reason ()) \
+
// Version comparison operators.
//
// They allow comparing objects that have epoch, canonical_upstream,
diff --git a/libbrep/package.cxx b/libbrep/package.cxx
index ec8e74a..1b7c4f6 100644
--- a/libbrep/package.cxx
+++ b/libbrep/package.cxx
@@ -110,25 +110,38 @@ namespace brep
examples (move (es)),
benchmarks (move (bms)),
builds (move (bs)),
- build_constraints (!stub () ? move (bc) : build_constraints_type ()),
+ build_constraints (move (bc)),
internal_repository (move (rp)),
location (move (lc)),
fragment (move (fr)),
- sha256sum (move (sh)),
- buildable (!stub () && internal_repository->buildable)
+ sha256sum (move (sh))
{
+ if (stub ())
+ unbuildable_reason = unbuildable_reason::stub;
+ else if (!internal_repository->buildable)
+ unbuildable_reason = unbuildable_reason::unbuildable;
+
+ buildable = !unbuildable_reason;
+
assert (internal_repository->internal);
}
package::
package (package_name nm,
version_type vr,
+ build_class_exprs bs,
+ build_constraints_type bc,
shared_ptr<repository_type> rp)
: id (rp->tenant, move (nm), vr),
tenant (id.tenant),
name (id.name),
version (move (vr)),
- buildable (false)
+ builds (move (bs)),
+ build_constraints (move (bc)),
+ buildable (false),
+ unbuildable_reason (stub ()
+ ? unbuildable_reason::stub
+ : unbuildable_reason::external)
{
assert (!rp->internal);
other_repositories.emplace_back (move (rp));
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 07bd2a0..59ee589 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -20,7 +20,7 @@
//
#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 17
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 17, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 18, closed)
namespace brep
{
@@ -362,8 +362,7 @@ namespace brep
using requirements_type = brep::requirements;
using build_constraints_type = brep::build_constraints;
- // Create internal package object. Note that for stubs the build
- // constraints are meaningless, and so not saved.
+ // Create internal package object.
//
package (package_name,
version_type,
@@ -400,12 +399,22 @@ namespace brep
// Create external package object.
//
- // External repository packages can appear on the WEB interface only in
- // dependency list in the form of a link to the corresponding WEB page.
- // The only package information required to compose such a link is the
- // package name, version, and repository location.
+ // External package can appear on the WEB interface only in dependency
+ // list in the form of a link to the corresponding WEB page. The only
+ // package information required to compose such a link is the package name,
+ // version, and repository location.
//
- package (package_name name, version_type, shared_ptr<repository_type>);
+ // External package can also be a separate test for some primary package
+ // (and belong to a complement but yet external repository), and so we may
+ // need its build class expressions and constraints to decide if to build
+ // it together with the primary package or not (see test-exclude task
+ // manifest value for details).
+ //
+ package (package_name name,
+ version_type,
+ build_class_exprs,
+ build_constraints_type,
+ shared_ptr<repository_type>);
bool
internal () const noexcept {return internal_repository != nullptr;}
@@ -451,9 +460,9 @@ namespace brep
optional<email_type> build_error_email;
dependencies_type dependencies;
requirements_type requirements;
- small_vector<dependency, 1> tests;
- small_vector<dependency, 1> examples;
- small_vector<dependency, 1> benchmarks;
+ small_vector<dependency, 1> tests; // Note: foreign-mapped in build.
+ small_vector<dependency, 1> examples; // Note: foreign-mapped in build.
+ small_vector<dependency, 1> benchmarks; // Note: foreign-mapped in build.
build_class_exprs builds; // Note: foreign-mapped in build.
build_constraints_type build_constraints; // Note: foreign-mapped in build.
@@ -478,16 +487,14 @@ namespace brep
vector<lazy_shared_ptr<repository_type>> other_repositories;
- // Whether the package is buildable by the build bot controller service.
- // Can only be true for non-stubs that belong to at least one buildable
- // (internal) repository.
+ // Whether the package is buildable by the build bot controller service
+ // and the reason if it's not.
//
// While we could potentially calculate this flag on the fly, that would
// complicate the database queries significantly.
//
- // Note: foreign-mapped in build.
- //
- bool buildable;
+ bool buildable; // Note: foreign-mapped in build.
+ optional<brep::unbuildable_reason> unbuildable_reason;
// Database mapping.
//
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 785ae0f..12ae36e 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,4 +1,10 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
+ <changeset version="18">
+ <alter-table name="package">
+ <add-column name="unbuildable_reason" type="TEXT" null="true"/>
+ </alter-table>
+ </changeset>
+
<model version="17">
<table name="tenant" kind="object">
<column name="id" type="TEXT" null="false"/>