Update golden checker to read all the golden artifacts

This commit is contained in:
David Dworken 2024-02-10 10:05:06 -08:00
parent 168d738b2d
commit f4694bdd28
No known key found for this signature in database
2 changed files with 18 additions and 18 deletions

View File

@ -98,7 +98,7 @@ jobs:
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
if: success() || failure() if: success() || failure()
with: with:
name: goldens-used-${{ matrix.os }}-${{ matrix.tests }}.txt name: goldens-used-${{ matrix.os }}-${{ matrix.tests }}
path: /tmp/goldens-used.txt path: /tmp/goldens-used.txt
# - name: Setup tmate session # - name: Setup tmate session
@ -117,8 +117,6 @@ jobs:
go-version: 1.21 go-version: 1.21
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with:
name: goldens-used-ubuntu-TUI.txt
- name: Check all goldens were used - name: Check all goldens were used
run: | run: |
ls . ls .

View File

@ -43,17 +43,24 @@ func checkGoldensUsed() {
} }
// Read the goldens that were used // Read the goldens that were used
usedGoldens := make([]string, 0) usedGoldens := make([]string, 0)
usedGoldensFile, err := os.Open("/tmp/goldens-used.txt") filenames := []string{
if err != nil { "goldens-used-macos-14-BASIC/goldens-used.txt", "goldens-used-macos-14-TUI/goldens-used.txt",
log.Fatalf("failed to open /tmp/goldens-used.txt: %v", err) "goldens-used-macos-latest-BASIC/goldens-used.txt", "goldens-used-macos-latest-TUI/goldens-used.txt",
"goldens-used-ubuntu-latest-BASIC/goldens-used.txt", "goldens-used-ubuntu-latest-TUI/goldens-used.txt",
} }
defer usedGoldensFile.Close() for _, filename := range filenames {
scanner := bufio.NewScanner(usedGoldensFile) usedGoldensFile, err := os.Open(filename)
for scanner.Scan() { if err != nil {
usedGoldens = append(usedGoldens, strings.TrimSpace(scanner.Text())) log.Fatalf("failed to open /tmp/goldens-used.txt: %v", err)
} }
if err := scanner.Err(); err != nil { defer usedGoldensFile.Close()
log.Fatalf("failed to read lines from /tmp/goldens-used.txt: %v", err) scanner := bufio.NewScanner(usedGoldensFile)
for scanner.Scan() {
usedGoldens = append(usedGoldens, strings.TrimSpace(scanner.Text()))
}
if err := scanner.Err(); err != nil {
log.Fatalf("failed to read lines from /tmp/goldens-used.txt: %v", err)
}
} }
// List all the goldens that exist // List all the goldens that exist
@ -72,11 +79,6 @@ func checkGoldensUsed() {
// It is allowlisted to not be used // It is allowlisted to not be used
continue continue
} }
if (runtime.GOOS == "darwin" && strings.Contains(goldenName, "-linux")) ||
(runtime.GOOS == "linux" && strings.Contains(goldenName, "-darwin")) {
// It is for another OS
continue
}
unusedGoldenErr = fmt.Errorf("golden file %v was never used", goldenName) unusedGoldenErr = fmt.Errorf("golden file %v was never used", goldenName)
fmt.Println(unusedGoldenErr) fmt.Println(unusedGoldenErr)
} }