Skip to content

Commit

Permalink
Update golden checker to read all the golden artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddworken committed Feb 10, 2024
1 parent 168d738 commit f4694bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: goldens-used-${{ matrix.os }}-${{ matrix.tests }}.txt
name: goldens-used-${{ matrix.os }}-${{ matrix.tests }}
path: /tmp/goldens-used.txt

# - name: Setup tmate session
Expand All @@ -117,8 +117,6 @@ jobs:
go-version: 1.21
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: goldens-used-ubuntu-TUI.txt
- name: Check all goldens were used
run: |
ls .
Expand Down
32 changes: 17 additions & 15 deletions client/posttest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,24 @@ func checkGoldensUsed() {
}
// Read the goldens that were used
usedGoldens := make([]string, 0)
usedGoldensFile, err := os.Open("/tmp/goldens-used.txt")
if err != nil {
log.Fatalf("failed to open /tmp/goldens-used.txt: %v", err)
}
defer usedGoldensFile.Close()
scanner := bufio.NewScanner(usedGoldensFile)
for scanner.Scan() {
usedGoldens = append(usedGoldens, strings.TrimSpace(scanner.Text()))
filenames := []string{
"goldens-used-macos-14-BASIC/goldens-used.txt", "goldens-used-macos-14-TUI/goldens-used.txt",
"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",
}
if err := scanner.Err(); err != nil {
log.Fatalf("failed to read lines from /tmp/goldens-used.txt: %v", err)
for _, filename := range filenames {
usedGoldensFile, err := os.Open(filename)
if err != nil {
log.Fatalf("failed to open /tmp/goldens-used.txt: %v", err)
}
defer usedGoldensFile.Close()
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
Expand All @@ -72,11 +79,6 @@ func checkGoldensUsed() {
// It is allowlisted to not be used
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)
fmt.Println(unusedGoldenErr)
}
Expand Down

0 comments on commit f4694bd

Please sign in to comment.