diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0f82e2e..589ef27 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,7 +32,7 @@ jobs: exit 0 else echo "Changes found in .go or .lua files. Running tests." - go test ./cmd/internal/tester -json > TestResults-${{ matrix.go-version }}.json + EOE_TESTER_WORKING_DIR=$(pwd) go test ./cmd/internal/tester -json > TestResults-${{ matrix.go-version }}.json fi ' - name: Upload Go test results diff --git a/cmd/internal/tester/main_test.go b/cmd/internal/tester/main_test.go index 8f4c520..1d4270d 100644 --- a/cmd/internal/tester/main_test.go +++ b/cmd/internal/tester/main_test.go @@ -20,6 +20,17 @@ func TestGame(t *testing.T) { return len(item) > 0 }) + // Change working dir if EOE_TESTER_WORKING_DIR is set. This is needed for the CI pipeline, + // because the working dir is not the root of the project but we need to load the resources + // from the root of the project. + if len(os.Getenv("EOE_TESTER_WORKING_DIR")) > 0 { + err := os.Chdir(os.Getenv("EOE_TESTER_WORKING_DIR")) + if err != nil { + t.Errorf("Error while changing working dir: %s", err.Error()) + return + } + } + session := game.NewSession(game.WithMods(mods)) resources := session.GetResources()