Skip to content

Commit

Permalink
make sure to build docs in ci builds (fixes #4269)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed May 24, 2024
1 parent 39d1ac7 commit 81831b0
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 53 deletions.
71 changes: 46 additions & 25 deletions do/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,46 +104,63 @@ func detectVersions() {
logf("sumatraVersion: '%s'\n", sumatraVersion)
}

var (
nSkipped = 0
nDirsDeleted = 0
nFilesDeleted = 0
)

func clearDirPreserveSettings(path string) {
entries2, err := os.ReadDir(path)
must(err)
for _, e2 := range entries2 {
name := e2.Name()
path2 := filepath.Join(path, name)
// delete everything except those files
excluded := (name == "sumatrapdfcache") || (name == "SumatraPDF-settings.txt") || strings.Contains(name, "asan")
if excluded {
nSkipped++
continue
}
if e2.IsDir() {
os.RemoveAll(path2)
nDirsDeleted++
} else {
os.Remove(path2)
nFilesDeleted++
}
}
}

// remove all files and directories under out/ except settings files
func cleanPreserveSettings() {
entries, err := os.ReadDir("out")
if err != nil {
// assuming 'out' doesn't exist, which is fine
return
}
nSkipped := 0
nDirsDeleted := 0
nFilesDeleted := 0
nSkipped = 0
nDirsDeleted = 0
nFilesDeleted = 0
for _, e := range entries {
path := filepath.Join("out", e.Name())
if !e.IsDir() {
os.Remove(path)
continue
}
entries2, err := os.ReadDir(path)
must(err)
for _, e2 := range entries2 {
name := e2.Name()
path2 := filepath.Join(path, name)
// delete everything except those files
excluded := (name == "sumatrapdfcache") || (name == "SumatraPDF-settings.txt") || strings.Contains(name, "asan_dynamic")
if excluded {
nSkipped++
continue
}
if e2.IsDir() {
os.RemoveAll(path2)
nDirsDeleted++
} else {
os.Remove(path2)
nFilesDeleted++
}
}
clearDirPreserveSettings(path)
}
logf("clean: skipped %d files, deleted %d dirs and %d files\n", nSkipped, nDirsDeleted, nFilesDeleted)
}

func cleanReleaseBuilds() {
clearDirPreserveSettings(rel32Dir)
clearDirPreserveSettings(rel64Dir)
clearDirPreserveSettings(relArm64Dir)
clearDirPreserveSettings(finalPreRelDir)
}

func removeReleaseBuilds() {
os.RemoveAll(rel32Dir)
os.RemoveAll(rel64Dir)
os.RemoveAll(relArm64Dir)
Expand Down Expand Up @@ -463,14 +480,16 @@ func buildCi() {
gev := getGitHubEventType()
switch gev {
case githubEventPush:
cleanReleaseBuilds()
removeReleaseBuilds()
genHTMLDocsForApp()
// I'm typically building 64-bit so in ci build 32-bit
// and build all projects, to find regressions in code
// I'm not regularly building while developing
buildPreRelease(kPlatformIntel32, true)
case githubEventTypeCodeQL:
// code ql is just a regular build, I assume intercepted by
// by their tooling
// buildSmoke() runs genHTMLDocsForApp() so no need to do it here
buildSmoke()
default:
panic("unkown value from getGitHubEventType()")
Expand Down Expand Up @@ -510,6 +529,7 @@ func buildPreRelease(platform string, all bool) {
func buildRelease() {
// make sure we can sign the executables, early exit if missing
detectSigntoolPath()
genHTMLDocsForApp()

ver := getVerForBuildType(buildTypeRel)
s := fmt.Sprintf("buidling release version %s", ver)
Expand All @@ -518,7 +538,7 @@ func buildRelease() {
verifyBuildNotInStorageMust(newMinioR2Client(), buildTypeRel)
verifyBuildNotInStorageMust(newMinioBackblazeClient(), buildTypeRel)

cleanReleaseBuilds()
removeReleaseBuilds()
setBuildConfigRelease()
defer revertBuildConfig()

Expand Down Expand Up @@ -550,7 +570,8 @@ func buildRelease() {
func buildSmoke() {
detectSigntoolPath()
defer makePrintDuration("smoke build")()
cleanReleaseBuilds()
removeReleaseBuilds()
genHTMLDocsForApp()

lzsa := absPathMust(filepath.Join("bin", "MakeLZSA.exe"))
panicIf(!fileExists(lzsa), "file '%s' doesn't exist", lzsa)
Expand Down
55 changes: 27 additions & 28 deletions do/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,45 +219,45 @@ func main() {

// ad-hoc flags to be set manually (to show less options)
var (
flgGenTranslationsInfoCpp = false
flgCppCheck = false
flgCppCheckAll = false
flgBuildLzsa = false
flgClangTidy = false
flgClangTidyFix = false
flgPrintBuildNo = false
flgBuildLzsa = false
flgCppCheck = false
flgCppCheckAll = false
flgFindLargestFilesByExt = false
flgGenTranslationsInfoCpp = false
flgPrintBuildNo = false
)

var (
flgRegenPremake bool
flgUpload bool
flgCIBuild bool
flgCIDailyBuild bool
flgUploadCiBuild bool
flgBuildLogview bool
flgBuildNo int
flgBuildPreRelease bool
flgBuildRelease bool
flgWc bool
flgTransDownload bool
flgClean bool
flgBuildSmoke bool
flgCheckAccessKeys bool
flgTriggerCodeQL bool
flgCIBuild bool
flgCIDailyBuild bool
flgClangFormat bool
flgClean bool
flgDiff bool
flgGenSettings bool
flgUpdateVer string
flgDrMem bool
flgLogView bool
flgRunTests bool
flgSmoke bool
flgFileUpload string
flgFilesList bool
flgExtractUtils bool
flgBuildLogview bool
flgBuildNo int
flgUpdateGoDeps bool
flgFilesList bool
flgFileUpload string
flgGenDocs bool
flgGenSettings bool
flgGenWebsiteDocs bool
flgLogView bool
flgRegenPremake bool
flgRunTests bool
flgTransDownload bool
flgTriggerCodeQL bool
flgUpdateGoDeps bool
flgUpdateVer string
flgUpload bool
flgUploadCiBuild bool
flgWc bool
)

{
Expand All @@ -267,7 +267,7 @@ func main() {
flag.BoolVar(&flgCIBuild, "ci", false, "run CI steps")
flag.BoolVar(&flgCIDailyBuild, "ci-daily", false, "run CI daily steps")
flag.BoolVar(&flgUploadCiBuild, "ci-upload", false, "upload the result of ci build to s3 and do spaces")
flag.BoolVar(&flgSmoke, "smoke", false, "run smoke build (installer for 64bit release)")
flag.BoolVar(&flgBuildSmoke, "build-smoke", false, "run smoke build (installer for 64bit release)")
flag.BoolVar(&flgBuildPreRelease, "build-pre-rel", false, "build pre-release")
flag.BoolVar(&flgBuildRelease, "build-release", false, "build release")
//flag.BoolVar(&flgBuildLzsa, "build-lzsa", false, "build MakeLZSA.exe")
Expand Down Expand Up @@ -465,7 +465,7 @@ func main() {
return
}

if flgSmoke {
if flgBuildSmoke {
buildSmoke()
return
}
Expand All @@ -492,7 +492,6 @@ func main() {
}

if flgCIBuild {
genHTMLDocsForApp()
buildCi()
if opts.upload {
uploadToStorage(buildTypePreRel)
Expand All @@ -503,7 +502,6 @@ func main() {
}

if flgBuildRelease {
genHTMLDocsForApp()
buildRelease()
if opts.upload {
uploadToStorage(buildTypeRel)
Expand All @@ -514,6 +512,7 @@ func main() {
}

// this one is typically for me to build locally, so build all projects
// to build less use -build-smoke
if flgBuildPreRelease {
cleanReleaseBuilds()
genHTMLDocsForApp()
Expand Down

0 comments on commit 81831b0

Please sign in to comment.