Skip to content

Commit 10670fa

Browse files
authored
Clean up action cache files left behind by tests (#3976)
1 parent 369363e commit 10670fa

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

pkg/cli/compile_integration_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ func TestMain(m *testing.M) {
6666
os.RemoveAll(filepath.Dir(globalBinaryPath))
6767
}
6868

69+
// Clean up any action cache files created during tests
70+
// Tests may create .github/aw/actions-lock.json in the pkg/cli directory
71+
actionCacheDir := filepath.Join(wd, ".github")
72+
if _, err := os.Stat(actionCacheDir); err == nil {
73+
_ = os.RemoveAll(actionCacheDir)
74+
}
75+
6976
os.Exit(code)
7077
}
7178

pkg/cli/test_main_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//go:build !integration
2+
3+
package cli
4+
5+
import (
6+
"os"
7+
"path/filepath"
8+
"testing"
9+
)
10+
11+
// TestMain provides setup and teardown for unit tests in the cli package
12+
// Note: Integration tests have their own TestMain in compile_integration_test.go
13+
func TestMain(m *testing.M) {
14+
// Get current working directory before tests run
15+
wd, err := os.Getwd()
16+
if err != nil {
17+
panic("Failed to get current working directory: " + err.Error())
18+
}
19+
20+
// Run all tests
21+
code := m.Run()
22+
23+
// Clean up any action cache files created during tests
24+
// Tests may create .github/aw/actions-lock.json in the pkg/cli directory
25+
actionCacheDir := filepath.Join(wd, ".github")
26+
if _, err := os.Stat(actionCacheDir); err == nil {
27+
_ = os.RemoveAll(actionCacheDir)
28+
}
29+
30+
os.Exit(code)
31+
}

0 commit comments

Comments
 (0)