Actually add support for build statuses

main
Simon Quigley 4 days ago
parent 03fdd33084
commit a089918462

@ -935,30 +935,45 @@ bool PackageConf::can_check_source_upload() {
}
bool PackageConf::can_check_builds() {
std::lock_guard<std::mutex> lock(*task_mutex_);
// In this case, the source check should be first
if (can_check_source_upload()) return false;
int _total_task_count = total_task_count();
if (_total_task_count == 0) return false;
if (!(jobstatus_task_map_.size() == 5)) { return false; }
std::lock_guard<std::mutex> lock(*task_mutex_);
static const std::array<std::string, 5> statuses = { "pull", "tarball", "source_build", "upload", "source_check" };
int cur_status = 0;
std::int64_t cur_timestamp = 0;
bool return_status = false;
std::int64_t upload_timestamp = 0;
std::int64_t binary_check_timestamp = 0;
std::set<std::string> valid_successful_statuses = {"pull", "tarball", "source_build", "upload", "source_check"};
{
std::lock_guard<std::mutex> lock(*task_mutex_);
for (auto &kv : jobstatus_task_map_) {
auto &jobstatus = kv.first;
auto &task_ptr = kv.second;
if (jobstatus->name == statuses[cur_status] && task_ptr) {
if (task_ptr->finish_time >= cur_timestamp && task_ptr->successful) {
return_status = true;
cur_timestamp = task_ptr->finish_time;
cur_status++;
} else {
return_status = false;
break;
if (valid_successful_statuses.contains(jobstatus->name)) _total_task_count--;
if (jobstatus->name == "upload" && task_ptr && task_ptr->successful) {
upload_timestamp = task_ptr->finish_time;
continue;
}
if (jobstatus->name == "binary_check" && task_ptr) {
binary_check_timestamp = task_ptr->finish_time;
_total_task_count--;
continue;
}
}
}
return return_status && cur_status == 5;
bool all_req_tasks_present = _total_task_count == 0;
if (!all_req_tasks_present || (upload_timestamp == 0 && binary_check_timestamp == 0)) {
return false;
} else if (all_req_tasks_present && upload_timestamp != 0 && binary_check_timestamp == 0) {
return true;
} else if (all_req_tasks_present) {
return binary_check_timestamp <= upload_timestamp;
}
return false;
}
// End of PackageConf
// Start of GitCommit

@ -241,6 +241,43 @@ bool WebServer::start_server(quint16 port) {
}
});
process_binaries_thread_ = std::jthread(run_task_every, 10, [this, all_repos, proposed, lubuntuci, job_statuses] {
for (auto pkgconf : all_repos) {
if (!pkgconf->can_check_builds()) { continue; }
task_queue->enqueue(
job_statuses->at("binary_check"),
[this, pkgconf, proposed](std::shared_ptr<Log> log) mutable {
std::string package_version = pkgconf->upstream_version + "-0ubuntu0~ppa" + std::to_string(pkgconf->ppa_revision);
bool found_in_ppa = false;
source_package_publishing_history target_spph;
for (auto spph : proposed.getPublishedSources("", "", std::nullopt, true, true, "", pkgconf->package->name, "", package_version)) {
found_in_ppa = true;
target_spph = spph;
break;
}
bool all_builds_passed = true;
for (auto build : target_spph.getBuilds()) {
if (build.buildstate != "Successfully built") all_builds_passed = false;
log->append(std::format("Build of {} {} in {} for {} has a status of {}",
pkgconf->package->name, package_version, pkgconf->release->codename,
build.arch_tag, build.buildstate));
}
if (!found_in_ppa) {
throw std::runtime_error("Not found in the PPA.");
} else if (!all_builds_passed) {
throw std::runtime_error("Build(s) pending or failed, job is not successful.");
}
},
pkgconf
);
pkgconf->sync();
}
});
////////////////////////////////////////////////////////////////
// /unauthorized?base_url=<base_url>&redirect_to=<redirect_to>
////////////////////////////////////////////////////////////////

@ -45,6 +45,7 @@ private:
std::unique_ptr<TaskQueue> task_queue;
std::jthread expire_tokens_thread_;
std::jthread process_sources_thread_;
std::jthread process_binaries_thread_;
QMap<int, QDateTime> _in_progress_tokens;
QMap<QString, QDateTime> _active_tokens;

Loading…
Cancel
Save