Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ cancerppir_elapsed_label <- function(
)
}

##############################################################################
cancerppir_log_has_completion_marker <- function(log_lines) {
log_lines <- as.character(log_lines)
log_lines <- log_lines[!is.na(log_lines)]

if (!length(log_lines)) {
return(FALSE)
}

any(
grepl(
paste0(
"^\\[CancerPPIr\\]",
"(?: \\[\\+[0-9]+:[0-9]{2}:[0-9]{2}\\])?",
" Done\\.$"
),
log_lines,
perl = TRUE
)
)
}

##############################################################################
msg <- function(...) {
message(
Expand Down
9 changes: 8 additions & 1 deletion docs/reference/contracts/release-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

The release qualification is the single production qualification gate for a
CancerPPIr release candidate. It runs repository preflight checks, one complete
unit-test suite, and one seven-case production regression.
unit-test suite, and one seven-case production regression. Before any tests or
production cases start, all seven inputs must pass the strict scientific input
contract.

## Command

Expand Down Expand Up @@ -46,6 +48,10 @@ The qualification requires all static release, documentation, publication
readiness, reproducible-environment, repository-quality, and CLI checks to pass
before the seven-case run begins.

The input-contract preflight validates all seven files together and fails before
unit tests or case execution if any file is incomplete, malformed, ambiguous, or
contains duplicate gene symbols.

## Release evidence

The output root contains:
Expand All @@ -54,6 +60,7 @@ The output root contains:
- `release_case_summary.csv`
- `release_validation.csv`
- `release_preflight_validation.csv`
- `release_input_contract.log`
- `release_unit_tests.log`
- `release_multicase.log`

Expand Down
67 changes: 67 additions & 0 deletions scripts/run_release_qualification.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ required_project_files <- file.path(
c(
"R/load_all.R",
"scripts/run_unit_tests.R",
"scripts/validate_input_contract.R",
"scripts/validate_multicase_outputs.R",
"scripts/validate_release_contract.R",
"scripts/validate_documentation_contract.R",
Expand Down Expand Up @@ -401,6 +402,11 @@ unit_test_log_temporary <- tempfile(
fileext = ".log"
)

input_contract_log_temporary <- tempfile(
pattern = "release_input_contract_",
fileext = ".log"
)

multicase_log_temporary <- tempfile(
pattern = "release_multicase_",
fileext = ".log"
Expand All @@ -409,13 +415,61 @@ multicase_log_temporary <- tempfile(
on.exit(
unlink(
c(
input_contract_log_temporary,
unit_test_log_temporary,
multicase_log_temporary
)
),
add = TRUE
)

message(
"[CancerPPIr release] Validating the strict input contract for all seven cases."
)

input_contract_arguments <- c(
shQuote(
file.path(
project_root,
"scripts",
"validate_input_contract.R"
)
),
vapply(
file.path(input_root, case_map$input_file),
shQuote,
FUN.VALUE = character(1)
)
)

input_contract_status <- system2(
command = rscript_command,
args = input_contract_arguments,
stdout = input_contract_log_temporary,
stderr = input_contract_log_temporary,
wait = TRUE
)

if (
is.null(input_contract_status) ||
is.na(input_contract_status) ||
input_contract_status != 0L
) {
stop(
paste0(
"Seven-case input-contract preflight failed with exit status ",
input_contract_status,
".\n\nLog tail:\n",
tail_log(input_contract_log_temporary)
),
call. = FALSE
)
}

message(
"[CancerPPIr release] Seven-case input-contract preflight: PASS."
)

if (run_tests) {
message(
"[CancerPPIr release] Running the complete unit-test suite once."
Expand Down Expand Up @@ -695,6 +749,17 @@ output_root <- normalizePath(
mustWork = TRUE
)

invisible(
file.copy(
input_contract_log_temporary,
file.path(
output_root,
"release_input_contract.log"
),
overwrite = TRUE
)
)

invisible(
file.copy(
unit_test_log_temporary,
Expand Down Expand Up @@ -1381,6 +1446,7 @@ rownames(case_summary) <- NULL

summary_table <- data.frame(
metric = c(
"input_contract",
"unit_tests",
"static_release_checks",
"documentation_checks",
Expand All @@ -1390,6 +1456,7 @@ summary_table <- data.frame(
"execution_mode"
),
value = c(
"PASS",
if (run_tests) "PASS" else "SKIPPED",
as.character(
nrow(static_validation)
Expand Down
8 changes: 2 additions & 6 deletions scripts/validate_multicase_technical_exports.R
Original file line number Diff line number Diff line change
Expand Up @@ -1127,12 +1127,8 @@ for (case_index in seq_len(
encoding = "UTF-8"
)

pipeline_done <- any(
grepl(
"[CancerPPIr] Done.",
log_lines,
fixed = TRUE
)
pipeline_done <- cancerppir_log_has_completion_marker(
log_lines
)

internal_validation <- expected_evidence$validation
Expand Down
41 changes: 41 additions & 0 deletions tests/testthat/test-release-edge-cases.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,47 @@ testthat::test_that(
}
)

testthat::test_that(
"release qualification validates inputs before tests or cases",
{
project_root <- Sys.getenv("CANCERPPIR_PROJECT_ROOT")
testthat::expect_true(nzchar(project_root))

release_text <- paste(
readLines(
file.path(
project_root,
"scripts",
"run_release_qualification.R"
),
warn = FALSE,
encoding = "UTF-8"
),
collapse = "\n"
)

input_position <- regexpr(
"Validating the strict input contract for all seven cases.",
release_text,
fixed = TRUE
)[[1L]]

unit_position <- regexpr(
"Running the complete unit-test suite once.",
release_text,
fixed = TRUE
)[[1L]]

testthat::expect_gt(input_position, 0L)
testthat::expect_gt(unit_position, input_position)
testthat::expect_match(
release_text,
"validate_input_contract.R",
fixed = TRUE
)
}
)

testthat::test_that(
"release edge case: zero p-values remain finite and parser-safe in GraphML",
{
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ testthat::test_that("ranking and text helpers retain qualified behavior", {
testthat::expect_identical("value" %||% "fallback", "value")
})

testthat::test_that("pipeline completion markers support legacy and timed logs", {
testthat::expect_true(
cancerppir_log_has_completion_marker("[CancerPPIr] Done.")
)

testthat::expect_true(
cancerppir_log_has_completion_marker(
"[CancerPPIr] [+00:03:15] Done."
)
)

testthat::expect_false(
cancerppir_log_has_completion_marker(
"[CancerPPIr] [+00:03:15] Not done."
)
)
})

testthat::test_that("candidate score requires five complete finite components", {
degree <- c(1, 2, 4)
betweenness <- c(0.1, 0.2, 0.5)
Expand Down
Loading