Fix adding last package of current batch already to staging repository
This commit is contained in:
parent
833550197f
commit
a205ffae38
|
@ -527,6 +527,7 @@ private:
|
||||||
bool m_skipBatchesAfterFailure;
|
bool m_skipBatchesAfterFailure;
|
||||||
bool m_hasFailuresInPreviousBatches;
|
bool m_hasFailuresInPreviousBatches;
|
||||||
std::atomic_bool m_enableStagingInNextBatch;
|
std::atomic_bool m_enableStagingInNextBatch;
|
||||||
|
std::atomic_bool m_enableStagingInThisBatch;
|
||||||
std::atomic_bool m_stagingEnabled;
|
std::atomic_bool m_stagingEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ BatchProcessingSession::BatchProcessingSession(const std::unordered_set<string_v
|
||||||
, m_skipBatchesAfterFailure(skipBatchesAfterFailure)
|
, m_skipBatchesAfterFailure(skipBatchesAfterFailure)
|
||||||
, m_hasFailuresInPreviousBatches(false)
|
, m_hasFailuresInPreviousBatches(false)
|
||||||
, m_enableStagingInNextBatch(false)
|
, m_enableStagingInNextBatch(false)
|
||||||
|
, m_enableStagingInThisBatch(false)
|
||||||
, m_stagingEnabled(false)
|
, m_stagingEnabled(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -98,6 +99,9 @@ bool BatchProcessingSession::isValid() const
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns whether staging is now active after a previous call to enableStagingInNextBatch().
|
* \brief Returns whether staging is now active after a previous call to enableStagingInNextBatch().
|
||||||
|
* \remarks
|
||||||
|
* This function's return value relates to the package returned by getCurrentPackageNameIfValidAndRelevantAndSelectNext()
|
||||||
|
* despite that function selecting the next package.
|
||||||
*/
|
*/
|
||||||
bool BatchProcessingSession::isStagingEnabled() const
|
bool BatchProcessingSession::isStagingEnabled() const
|
||||||
{
|
{
|
||||||
|
@ -128,6 +132,7 @@ void BatchProcessingSession::selectNextPackage()
|
||||||
{
|
{
|
||||||
if (++m_packageIterator != m_packageEnd) {
|
if (++m_packageIterator != m_packageEnd) {
|
||||||
m_firstPackageInBatch = false;
|
m_firstPackageInBatch = false;
|
||||||
|
m_stagingEnabled = m_stagingEnabled || m_enableStagingInThisBatch;
|
||||||
return; // select the next package within the current batch
|
return; // select the next package within the current batch
|
||||||
}
|
}
|
||||||
if ((m_hasFailuresInPreviousBatches = !allResponses().empty()) && m_skipBatchesAfterFailure) {
|
if ((m_hasFailuresInPreviousBatches = !allResponses().empty()) && m_skipBatchesAfterFailure) {
|
||||||
|
@ -140,7 +145,7 @@ void BatchProcessingSession::selectNextPackage()
|
||||||
m_packageIterator = m_batchIterator->begin();
|
m_packageIterator = m_batchIterator->begin();
|
||||||
m_packageEnd = m_batchIterator->end();
|
m_packageEnd = m_batchIterator->end();
|
||||||
m_firstPackageInBatch = true;
|
m_firstPackageInBatch = true;
|
||||||
m_stagingEnabled = m_stagingEnabled || m_enableStagingInNextBatch;
|
m_enableStagingInThisBatch.store(m_enableStagingInNextBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
pkgname = bar
|
||||||
|
pkgver = 2-1
|
||||||
|
pkgdesc = another fake package for testing
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
pkgname = foo
|
||||||
|
pkgver = 1-1
|
||||||
|
pkgdesc = fake package for testing
|
Binary file not shown.
|
@ -429,13 +429,19 @@ static void ensureEmptyDir(const std::filesystem::path &path)
|
||||||
static void createPackageDirs(bool empty = true)
|
static void createPackageDirs(bool empty = true)
|
||||||
{
|
{
|
||||||
constexpr auto buildDir = "building/build-data/conduct-build-test/"sv;
|
constexpr auto buildDir = "building/build-data/conduct-build-test/"sv;
|
||||||
for (const auto pkg : { "foo"sv, "bar"sv, "baz"sv }) {
|
for (const auto pkg : { "foo-1-1"sv, "bar-2-1"sv, "baz-3-1"sv }) {
|
||||||
ensureEmptyDir(argsToString(buildDir, pkg, "/src"sv));
|
const auto pkgName = pkg.substr(0, 3);
|
||||||
ensureEmptyDir(argsToString(buildDir, pkg, "/pkg"sv));
|
ensureEmptyDir(argsToString(buildDir, pkgName, "/src"sv));
|
||||||
|
ensureEmptyDir(argsToString(buildDir, pkgName, "/pkg"sv));
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
writeFile(argsToString(buildDir, pkg, "/src/PKGBUILD"sv), pkg);
|
const auto relativeFakePackagePath = argsToString(buildDir, pkgName, "/src/"sv, pkg, "-x86_64.pkg.tar.zst"sv);
|
||||||
writeFile(argsToString(buildDir, pkg, "/src/"sv, pkg, "-1-1.src.tar.gz"sv), pkg);
|
try {
|
||||||
writeFile(argsToString(buildDir, pkg, "/src/"sv, pkg, "-1-1-x86_64.pkg.tar.zst"sv), pkg);
|
std::filesystem::copy_file(testFilePath(relativeFakePackagePath), relativeFakePackagePath);
|
||||||
|
} catch (const std::runtime_error &) {
|
||||||
|
writeFile(relativeFakePackagePath, pkg);
|
||||||
|
}
|
||||||
|
writeFile(argsToString(buildDir, pkgName, "/src/PKGBUILD"sv), pkg);
|
||||||
|
writeFile(argsToString(buildDir, pkgName, "/src/"sv, pkg, ".src.tar.gz"sv), pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,15 +650,14 @@ void BuildActionsTests::testConductingBuild()
|
||||||
createPackageDirs(false);
|
createPackageDirs(false);
|
||||||
|
|
||||||
// conduct build with staging and multiple batches
|
// conduct build with staging and multiple batches
|
||||||
// FIXME: verify behavior of packages other than boost
|
|
||||||
{
|
{
|
||||||
writeFile(progressFile.native(), progressData); // reset "build-progress.json" so the packages are re-considered
|
writeFile(progressFile.native(), progressData); // reset "build-progress.json" so the packages are re-considered
|
||||||
m_buildAction->packageNames.clear(); // don't build only "boost"
|
m_buildAction->packageNames.clear(); // don't build only "boost"
|
||||||
runBuildAction("conduct build with staging");
|
runBuildAction("conduct build with staging");
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||||
"staging needed: failure (as most build results are just dummies here)", BuildActionResult::Failure, m_buildAction->result);
|
"staging needed: failure as build result of baz is no valid archive", BuildActionResult::Failure, m_buildAction->result);
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||||
"staging needed: no result data present", "failed to build packages: foo, bar, baz"s, std::get<std::string>(m_buildAction->resultData));
|
"staging needed: failed packages listed", "failed to build packages: baz"s, std::get<std::string>(m_buildAction->resultData));
|
||||||
internalData = internalBuildAction<ConductBuild>();
|
internalData = internalBuildAction<ConductBuild>();
|
||||||
const auto &rebuildList = internalData->m_buildProgress.rebuildList;
|
const auto &rebuildList = internalData->m_buildProgress.rebuildList;
|
||||||
const auto rebuildInfoForMisc = rebuildList.find("misc");
|
const auto rebuildInfoForMisc = rebuildList.find("misc");
|
||||||
|
@ -671,16 +676,24 @@ void BuildActionsTests::testConductingBuild()
|
||||||
readFile("building/build-data/conduct-build-test/boost/pkg/repo-add.log"));
|
readFile("building/build-data/conduct-build-test/boost/pkg/repo-add.log"));
|
||||||
|
|
||||||
// check whether package have been added to staging repo
|
// check whether package have been added to staging repo
|
||||||
CPPUNIT_ASSERT_MESSAGE(
|
CPPUNIT_ASSERT_MESSAGE("staging needed: boost package added to staging repo (0)",
|
||||||
"staging needed: package added to repo (0)", std::filesystem::is_regular_file("repos/boost-staging/os/src/boost-1.73.0-1.src.tar.gz"));
|
std::filesystem::is_regular_file("repos/boost-staging/os/src/boost-1.73.0-1.src.tar.gz"));
|
||||||
CPPUNIT_ASSERT_MESSAGE("staging needed: package added to repo (1)",
|
CPPUNIT_ASSERT_MESSAGE("staging needed: boost package added to staging repo (1)",
|
||||||
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-1.73.0-1-x86_64.pkg.tar.zst"));
|
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-1.73.0-1-x86_64.pkg.tar.zst"));
|
||||||
CPPUNIT_ASSERT_MESSAGE("staging needed: package added to repo (2)",
|
CPPUNIT_ASSERT_MESSAGE("staging needed: boost package added to staging repo (2)",
|
||||||
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-libs-1.73.0-1-x86_64.pkg.tar.zst"));
|
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-libs-1.73.0-1-x86_64.pkg.tar.zst"));
|
||||||
CPPUNIT_ASSERT_MESSAGE("staging needed: signature added to repo (0)",
|
CPPUNIT_ASSERT_MESSAGE("staging needed: boost signature added to staging repo (0)",
|
||||||
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-1.73.0-1-x86_64.pkg.tar.zst.sig"));
|
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-1.73.0-1-x86_64.pkg.tar.zst.sig"));
|
||||||
CPPUNIT_ASSERT_MESSAGE("staging needed: signature added to repo (1)",
|
CPPUNIT_ASSERT_MESSAGE("staging needed: boost signature added to staging repo (1)",
|
||||||
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-libs-1.73.0-1-x86_64.pkg.tar.zst.sig"));
|
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-libs-1.73.0-1-x86_64.pkg.tar.zst.sig"));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("staging needed: foo package from first batch still added to normal repo (0)",
|
||||||
|
std::filesystem::is_regular_file("repos/boost/os/src/foo-1-1.src.tar.gz"));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("staging needed: foo package from first batch still added to normal repo (1)",
|
||||||
|
std::filesystem::is_regular_file("repos/boost/os/x86_64/foo-1-1-x86_64.pkg.tar.zst"));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("staging needed: bar package from next batch added to staging repo as well (0)",
|
||||||
|
std::filesystem::is_regular_file("repos/boost-staging/os/src/bar-2-1.src.tar.gz"));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("staging needed: bar package from next batch added to staging repo as well (1)",
|
||||||
|
std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/bar-2-1-x86_64.pkg.tar.zst"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// define expected errors for subsequent tests
|
// define expected errors for subsequent tests
|
||||||
|
|
Loading…
Reference in New Issue