chore: publish IntegraCI build modules 732ec6c83925
This commit is contained in:
1 parent
7a84930dea
commit
5f8a24d014
133 files changed
+18990
-2
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package verdict
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
// Liquibase prints one UPDATE SUMMARY per changelog it ran; "Run:" is the
|
||||
// number of changesets that summary applied.
|
||||
liquibaseRun = regexp.MustCompile(`(?m)^Run:\s+(\d+)\s*$`)
|
||||
// Flyway prints one line for the whole run.
|
||||
flywayApplied = regexp.MustCompile(`Successfully applied (\d+) migrations?`)
|
||||
)
|
||||
|
||||
// AppliedCount reads how many migrations an apply ran from the tool's own
|
||||
// summary. Each tool reports it differently, and a marker that fits one tool
|
||||
// counts nothing (or the wrong thing) in another: until 2026-09-27 this module
|
||||
// reported 0 for every Liquibase run and 1 for every Flyway run of any size.
|
||||
// An output without the tool's summary counts 0.
|
||||
func AppliedCount(tool, out string) int {
|
||||
count := 0
|
||||
switch tool {
|
||||
case "liquibase":
|
||||
for _, m := range liquibaseRun.FindAllStringSubmatch(out, -1) {
|
||||
n, _ := strconv.Atoi(m[1])
|
||||
count += n
|
||||
}
|
||||
case "flyway":
|
||||
for _, m := range flywayApplied.FindAllStringSubmatch(out, -1) {
|
||||
n, _ := strconv.Atoi(m[1])
|
||||
count += n
|
||||
}
|
||||
case "atlas":
|
||||
// One "-- migrating version <v>" line per file it applied.
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
if strings.HasPrefix(strings.TrimSpace(line), "-- migrating version ") {
|
||||
count++
|
||||
}
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
Reference in new issue
Block a user