Skip to content

Commit

Permalink
Custom case for CI in main, print statements surpressed when in CI to…
Browse files Browse the repository at this point in the history
… make logs and errors more readable
  • Loading branch information
joachimbbp committed Mar 11, 2024
1 parent d72d4b4 commit 559ccc1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
Binary file modified .DS_Store
Binary file not shown.
11 changes: 5 additions & 6 deletions .github/workflows/goBuildMac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ jobs:
- name: Install vips
run: brew install vips
- name: Change Directory
run: |
cd src/main
go run main.go database
go run main.go resize
go run main.go video
go build
run: cd src/main
- name: Build Test
run: go build
- name: Custom Continuous Integration Tests
run: go CI_testing
18 changes: 9 additions & 9 deletions src/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,18 @@ func main() {
sprite.Database,
util.SpriteInput,
util.DatabaseFolderPath,
false,
)

case "printdb":
util.PrintColorDatabase("/Users/joachimpfefferkorn/Documents/GitHub/spritefire/ignore/database/sprite_color_db")

case "resize":
spriteResIndices := []int{5} //hard coded at just 5 for CI for no
fmt.Println("Resizing Sprites to resolutions:")
for _, index := range spriteResIndices {
fmt.Println(util.SpriteSizes[index])
}

util.TimeIt(
"resizing",
sprite.Resize,
util.SpriteInput,
util.SpriteSizes,
spriteResIndices,
false,
)

case "video":
Expand All @@ -65,6 +60,11 @@ func main() {
util.DatabasePath,
batchResIndices,
)

case "CI_testing":
fmt.Println("Testing for github actions")
sprite.Database(util.SpriteInput, util.DatabaseFolderPath, true)
sprite.Resize(util.SpriteInput, util.SpriteSizes, true)
/*raylib functions use a window and thus cannot be run with github actions
Thus this only tests if the database will run*/
}
}
8 changes: 5 additions & 3 deletions src/sprite/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sprite

import (
"encoding/gob"
"fmt"
"log"
"os"
"path/filepath"
Expand All @@ -14,7 +15,7 @@ import (

//TODO: multithread in goroutines

func Database(spriteFolder string, outputFolder string) {
func Database(spriteFolder string, outputFolder string, ci bool) {
util.CreateIfNotExist(outputFolder)

spriteColorDatabase := make(map[string]util.Rgb)
Expand All @@ -23,18 +24,19 @@ func Database(spriteFolder string, outputFolder string) {
if err != nil {
log.Fatal(err)
}

for _, entry := range sprites {
if !entry.IsDir() {
if filepath.Ext(entry.Name()) != ".png" {
continue
}
filePath := filepath.Join(spriteFolder, entry.Name())
spriteColorDatabase[entry.Name()] = averageColor(filePath)
/*
if !ci {
fmt.Println("\nDatabase Creation adding:")
fmt.Println("Sprite:\n", entry.Name())
fmt.Println("average color:\n", spriteColorDatabase[entry.Name()])
*/ //commented out as it's unwieldy in debugging CI
}

}
}
Expand Down
10 changes: 4 additions & 6 deletions src/sprite/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import (

//TODO run in parallel with goroutines or (better yet) raylib

func Resize(spriteFolder string, resizedFolder string, spriteResIndices []int) {
func Resize(spriteFolder string, resizedFolder string, ci bool) {
util.CreateIfNotExist(resizedFolder)

for _, index := range spriteResIndices {
resolution := int(util.SpriteSizes[index])

for _, resolution := range util.ResizeResolutions {
sprites, readDirErr := os.ReadDir(spriteFolder)
if readDirErr != nil {
log.Fatal(readDirErr)
Expand All @@ -31,11 +29,11 @@ func Resize(spriteFolder string, resizedFolder string, spriteResIndices []int) {
}

for _, sprite := range sprites {
/*
if !ci {
fmt.Println("\nCreating Resized Sprite")
fmt.Println("Resolution:\n", resolution)
fmt.Println("Sprite:\n", sprite)
*/ //Commenting out as it's unweildy in debugging CI
}

spritePath := filepath.Join(spriteFolder, sprite.Name())

Expand Down

0 comments on commit 559ccc1

Please sign in to comment.