Skip to content

Commit

Permalink
ci: Test against Windows, Go 1.21, 1.22 (#407)
Browse files Browse the repository at this point in the history
* ci: Test against Windows, Go 1.21, 1.22

Upgrade to Go 1.21, 1.22 since those are the two latest versions.

Plus Fx supports Windows and has tests against it,
so Dig should test against it too.

* Normalize line endings before comparison
  • Loading branch information
abhinav authored Feb 26, 2024
1 parent 59e9f76 commit 897df36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ permissions:
jobs:

build:
runs-on: ubuntu-latest
name: Test (Go ${{ matrix.go }})
runs-on: ${{ matrix.os }}
name: Test (Go ${{ matrix.go }} / ${{ matrix.os }})
strategy:
matrix:
go: ["1.20.x", "1.21.x"]
os: ["ubuntu-latest", "windows-latest"]
go: ["1.21.x", "1.22.x"]

steps:
- name: Setup Go
Expand Down Expand Up @@ -48,7 +49,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: 1.22.x
cache: false # managed by golangci-lint

- uses: golangci/golangci-lint-action@v3
Expand Down
11 changes: 6 additions & 5 deletions visualize_golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ var generate = flag.Bool("generate", false, "generates output to testdata/ if se
func VerifyVisualization(t *testing.T, testname string, c *Container, opts ...VisualizeOption) {
var b bytes.Buffer
require.NoError(t, Visualize(c, &b, opts...))
got := b.Bytes()
got = bytes.ReplaceAll(got, []byte("\r\n"), []byte("\n")) // normalize line endings

dotFile := filepath.Join("testdata", testname+".dot")

if *generate {
err := os.WriteFile(dotFile, b.Bytes(), 0o644)
err := os.WriteFile(dotFile, got, 0o644)
require.NoError(t, err)
return
}

wantBytes, err := os.ReadFile(dotFile)
want, err := os.ReadFile(dotFile)
require.NoError(t, err)
want = bytes.ReplaceAll(want, []byte("\r\n"), []byte("\n")) // normalize line endings

got := b.String()
want := string(wantBytes)
assert.Equal(t, want, got,
assert.Equal(t, string(want), string(got),
"Output did not match. Make sure you updated the testdata by running 'go test -generate'")
}

0 comments on commit 897df36

Please sign in to comment.