From 8fa2d80fa4cad0ed017e1e55556766d3f6d327a8 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Tue, 17 Dec 2024 18:38:33 -0600 Subject: [PATCH] Don't hard-fail on a failed stage - this is rather normal --- cpp/build-packages.cpp | 120 ++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 63 deletions(-) diff --git a/cpp/build-packages.cpp b/cpp/build-packages.cpp index 75b901f..62edc73 100644 --- a/cpp/build-packages.cpp +++ b/cpp/build-packages.cpp @@ -974,84 +974,78 @@ int main(int argc, char** argv) { } // Stage 2: Build all packages in parallel - if(!has_failures) { - log_info("Starting Stage 2: Building all packages."); - std::vector> build_futures; - for(auto &pkg : packages) { - build_futures.emplace_back(std::async(std::launch::async, build_package_stage_wrapper, std::ref(pkg), releases)); - } + log_info("Starting Stage 2: Building all packages."); + std::vector> build_futures; + for(auto &pkg : packages) { + build_futures.emplace_back(std::async(std::launch::async, build_package_stage_wrapper, std::ref(pkg), releases)); + } - for(auto &fut : build_futures) { - try { - fut.get(); - log_info("Package built successfully."); - } catch(std::exception &e) { - log_error(std::string("Build task generated an exception: ") + e.what()); - // Failure already recorded inside build_package_stage_wrapper - } + for(auto &fut : build_futures) { + try { + fut.get(); + log_info("Package built successfully."); + } catch(std::exception &e) { + log_error(std::string("Build task generated an exception: ") + e.what()); + // Failure already recorded inside build_package_stage_wrapper } - log_info("Completed Stage 2: All packages built."); - - // Check for failures after Stage 2 - { - std::lock_guard lock(failures_mutex); - if(!failed_packages.empty()) { - log_error("Failures detected after Stage 2: Building packages."); - has_failures = true; - } + } + log_info("Completed Stage 2: All packages built."); + + // Check for failures after Stage 2 + { + std::lock_guard lock(failures_mutex); + if(!failed_packages.empty()) { + log_error("Failures detected after Stage 2: Building packages."); + has_failures = true; } } // Stage 3: Dput upload all packages in parallel - if(!has_failures) { - log_info("Starting Stage 3: Uploading all packages with dput."); - std::vector> upload_futures; - for(auto &pkg : packages) { - upload_futures.emplace_back(std::async(std::launch::async, upload_package_stage, std::ref(pkg), skip_dput)); - } + log_info("Starting Stage 3: Uploading all packages with dput."); + std::vector> upload_futures; + for(auto &pkg : packages) { + upload_futures.emplace_back(std::async(std::launch::async, upload_package_stage, std::ref(pkg), skip_dput)); + } - for(auto &fut : upload_futures) { - try { - fut.get(); - log_info("Package uploaded successfully."); - } catch(std::exception &e) { - log_error(std::string("Upload task generated an exception: ") + e.what()); - // Failure already recorded inside upload_package_stage - } + for(auto &fut : upload_futures) { + try { + fut.get(); + log_info("Package uploaded successfully."); + } catch(std::exception &e) { + log_error(std::string("Upload task generated an exception: ") + e.what()); + // Failure already recorded inside upload_package_stage } - log_info("Completed Stage 3: All packages uploaded."); - - // Check for failures after Stage 3 - { - std::lock_guard lock(failures_mutex); - if(!failed_packages.empty()) { - log_error("Failures detected after Stage 3: Uploading packages."); - has_failures = true; - } + } + log_info("Completed Stage 3: All packages uploaded."); + + // Check for failures after Stage 3 + { + std::lock_guard lock(failures_mutex); + if(!failed_packages.empty()) { + log_error("Failures detected after Stage 3: Uploading packages."); + has_failures = true; } } // Stage 4: Run Lintian on all packages in parallel - if(!has_failures) { - log_info("Starting Stage 4: Running Lintian on all packages."); - std::vector> lintian_futures; - for(auto &pkg : packages) { - lintian_futures.emplace_back(std::async(std::launch::async, run_lintian_stage, std::ref(pkg))); - } + log_info("Starting Stage 4: Running Lintian on all packages."); + std::vector> lintian_futures; + for(auto &pkg : packages) { + lintian_futures.emplace_back(std::async(std::launch::async, run_lintian_stage, std::ref(pkg))); + } - for(auto &fut : lintian_futures) { - try { - fut.get(); - log_info("Lintian run successfully."); - } catch(std::exception &e) { - log_error(std::string("Lintian task generated an exception: ") + e.what()); - // Record the failure - std::lock_guard lock_fail(failures_mutex); - failed_packages["Lintian"] = "Exception during Lintian run: " + std::string(e.what()); - } + for(auto &fut : lintian_futures) { + try { + fut.get(); + log_info("Lintian run successfully."); + } catch(std::exception &e) { + log_error(std::string("Lintian task generated an exception: ") + e.what()); + // Record the failure + std::lock_guard lock_fail(failures_mutex); + failed_packages["Lintian"] = "Exception during Lintian run: " + std::string(e.what()); } - log_info("Completed Stage 4: All Lintian runs completed."); } + log_info("Completed Stage 4: All Lintian runs completed."); // Proceed to summary and cleanup summary(skip_cleanup);