From 24dba8faa14c4b0a024cc6db5daed8cbbef56b9a Mon Sep 17 00:00:00 2001 From: Love Kumar Chauhan Date: Sat, 6 Jun 2026 16:29:40 +0530 Subject: [PATCH 1/2] fix: improve Windows cross-platform compatibility in tests - Add .gitattributes to enforce LF line endings for YAML/YML files - Normalize CRLF to LF in yaml_test.go before string comparisons - Use filepath.FromSlash in runner/names/test_test.go for portable path assertions - Skip POSIX chmod-based unreadable directory test on Windows in fs/discover_test.go Signed-off-by: Love Kumar Chauhan --- .gitattributes | 2 ++ pkg/runner/names/test_test.go | 4 ++-- pkg/utils/fs/discover_test.go | 4 ++++ pkg/utils/yaml/yaml_test.go | 5 +++-- 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..c96917d0a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.yaml text eol=lf +*.yml text eol=lf diff --git a/pkg/runner/names/test_test.go b/pkg/runner/names/test_test.go index 138bc7c95..40fc88d46 100644 --- a/pkg/runner/names/test_test.go +++ b/pkg/runner/names/test_test.go @@ -67,7 +67,7 @@ func TestTest(t *testing.T) { }, }, wantErr: false, - want: "../dir/dir[foo]", + want: filepath.FromSlash("../dir/dir[foo]"), }, { name: "full name", full: true, @@ -80,7 +80,7 @@ func TestTest(t *testing.T) { }, }, wantErr: false, - want: "dir/dir[foo]", + want: filepath.FromSlash("dir/dir[foo]"), }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/utils/fs/discover_test.go b/pkg/utils/fs/discover_test.go index deea83ae9..421c330d5 100644 --- a/pkg/utils/fs/discover_test.go +++ b/pkg/utils/fs/discover_test.go @@ -4,6 +4,7 @@ import ( "errors" "os" "path/filepath" + "runtime" "testing" "github.com/stretchr/testify/assert" @@ -29,6 +30,9 @@ func TestDiscoverFolders(t *testing.T) { } func TestDiscoverFoldersWithError(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("skipping test on Windows: chmod 0000 does not make directory unreadable") + } root := t.TempDir() unreadableDir := filepath.Join(root, "unreadable") assert.NoError(t, os.MkdirAll(unreadableDir, os.ModePerm)) diff --git a/pkg/utils/yaml/yaml_test.go b/pkg/utils/yaml/yaml_test.go index a161b6b3a..48e042665 100644 --- a/pkg/utils/yaml/yaml_test.go +++ b/pkg/utils/yaml/yaml_test.go @@ -3,6 +3,7 @@ package yaml import ( "errors" "os" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -39,7 +40,7 @@ func Test_remarshal(t *testing.T) { } else { assert.NoError(t, err) } - assert.Equal(t, tt.want, string(got)) + assert.Equal(t, strings.ReplaceAll(tt.want, "\r\n", "\n"), strings.ReplaceAll(string(got), "\r\n", "\n")) }) } } @@ -68,7 +69,7 @@ func TestRemarshal(t *testing.T) { } else { assert.NoError(t, err) } - assert.Equal(t, tt.want, string(got)) + assert.Equal(t, strings.ReplaceAll(tt.want, "\r\n", "\n"), strings.ReplaceAll(string(got), "\r\n", "\n")) }) } } From 8cdd0ec19994155dd077373d1ce2e1012006ec8f Mon Sep 17 00:00:00 2001 From: Love Kumar Chauhan Date: Wed, 17 Jun 2026 19:51:36 +0530 Subject: [PATCH 2/2] docs: add Ecosystem & Related Projects page for Sawchain Signed-off-by: Love Kumar Chauhan --- README.md | 8 +++++++ website/docs/community/ecosystem.md | 32 +++++++++++++++++++++++++++ website/docs/quick-start/resources.md | 6 +++++ website/mkdocs.yaml | 1 + 4 files changed, 47 insertions(+) create mode 100644 website/docs/community/ecosystem.md diff --git a/README.md b/README.md index a90fa1d55..84e59f6b6 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,14 @@ Built under the Kyverno umbrella, you can use the Kyverno Chainsaw **Slack chann - [Kyverno Chainsaw 0.1.4 - Awesome new features!](https://kyverno.io/blog/2024/02/15/kyverno-chainsaw-0.1.4-awesome-new-features/) - [Mastering Kubernetes Testing with Kyverno Chainsaw!](https://youtu.be/hQJWGzogIiI) +## Related Projects & Ecosystem + +Chainsaw's package design allows other projects to build on top of its core libraries: + +- [Sawchain](https://github.com/guidewire-oss/sawchain): An open-source Go testing library that builds on Chainsaw's public packages to enable ergonomic YAML-driven Kubernetes testing within Go test frameworks implementing `testing.TB` (like Ginkgo). + +For more related projects, check out our [Ecosystem & Related Projects](https://kyverno.github.io/chainsaw/latest/community/ecosystem/) documentation. + ## Getting Started Please refer to the [Getting Started](https://kyverno.github.io/chainsaw/latest/quick-start/) documentation. diff --git a/website/docs/community/ecosystem.md b/website/docs/community/ecosystem.md new file mode 100644 index 000000000..037844159 --- /dev/null +++ b/website/docs/community/ecosystem.md @@ -0,0 +1,32 @@ +# Ecosystem & Related Projects + +Chainsaw is designed to be modular, extensible, and reusable. Several of Chainsaw's core packages—such as resource templating, JMESPath expressions, and resource matching/validation—are exposed as public Go modules that can be integrated into other projects. + +This page lists community-driven libraries, tools, and integrations that build on top of or complement Chainsaw. + +--- + +## Sawchain + +[Sawchain](https://github.com/guidewire-oss/sawchain) is an open-source Go testing library developed by Guidewire. It bridges the gap between Chainsaw's declarative testing power and programmatic Go test suites. + +### How it works with Chainsaw +Instead of running as a standalone command-line runner, Sawchain integrates Chainsaw's core packages directly into Go's standard `testing.TB` framework (including Ginkgo and Gomega). It leverages Chainsaw's: +- **Resource templating** for dynamic test inputs. +- **JMESPath expressions** for rich queries. +- **Resource matching and assertion engine** for declarative checking. + +### Key Features +- **Gomega Matchers**: Provides Gomega matchers for declarative Kubernetes resource verification inside Go test assertions. +- **Controller-runtime Integration**: Integrates directly with controller-runtime clients for smooth interaction with Kubernetes APIs. +- **Ergonomic DSL**: Allows developer-friendly, fluent test configurations directly in Go codebase. + +### Resources +- [Sawchain GitHub Repository](https://github.com/guidewire-oss/sawchain) +- [Kubernetes Deserves Better Tests: Meet Sawchain (Deep Dive Blog)](https://medium.com/guidewire-engineering-blog/kubernetes-deserves-better-tests-meet-sawchain-2e8c8f750501) + +--- + +!!! tip "Have a project built on Chainsaw?" + + We welcome community contributions! Please open a pull request to add your related project or integration to this list. diff --git a/website/docs/quick-start/resources.md b/website/docs/quick-start/resources.md index b4301bcdb..85affb51b 100644 --- a/website/docs/quick-start/resources.md +++ b/website/docs/quick-start/resources.md @@ -18,3 +18,9 @@ If you haven't watched the video below yet, we strongly recommend watching it to title="Mastering Kubernetes Testing with Kyverno Chainsaw!" frameborder="0" allowfullscreen> + +## Ecosystem & Related Projects + +- [Sawchain](https://github.com/guidewire-oss/sawchain) - An open-source Go testing library that builds on Chainsaw's packages to enable ergonomic YAML-driven Kubernetes testing in Go. +- For more related projects and integrations, visit the [Ecosystem & Related Projects](../community/ecosystem.md) page. + diff --git a/website/mkdocs.yaml b/website/mkdocs.yaml index a06cd5af3..bb0df6453 100644 --- a/website/mkdocs.yaml +++ b/website/mkdocs.yaml @@ -232,6 +232,7 @@ nav: - guides/test-docs.md - Community: - community/index.md + - Ecosystem & Related Projects: community/ecosystem.md - Contributing: community/contribute.md - Reporting a bug: community/reporting-a-bug.md - Reporting a docs issue: community/reporting-a-docs-issue.md