From b3ada4a51a030ef76b2ad6d402c412cf45180e8e Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Mon, 4 Nov 2024 06:36:23 +0000 Subject: [PATCH] chore: Fix tests (#84) - Skip UDS tests if not running on Linux https://github.com/docker/for-mac/issues/483 - Test against correct Go versions https://github.com/actions/setup-go/issues/491 Signed-off-by: Andrew Haines --- .github/workflows/pr-test.yaml | 6 ++++-- CONTRIBUTING.md | 2 +- cerbos/grpc_linux_test.go | 8 ++++++++ cerbos/grpc_other_oses_test.go | 8 ++++++++ cerbos/grpc_test.go | 4 ++++ 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 cerbos/grpc_linux_test.go create mode 100644 cerbos/grpc_other_oses_test.go diff --git a/.github/workflows/pr-test.yaml b/.github/workflows/pr-test.yaml index 5cc36cf..d814dad 100644 --- a/.github/workflows/pr-test.yaml +++ b/.github/workflows/pr-test.yaml @@ -4,12 +4,14 @@ on: pull_request: branches: - main +env: + GOTOOLCHAIN: local jobs: test: runs-on: ubuntu-latest strategy: matrix: - go: ["1.21", "1.22"] + go: ["1.22", "1.23"] name: Test on Go ${{ matrix.go }} timeout-minutes: 10 steps: @@ -19,7 +21,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go}} + go-version: ${{ matrix.go }} check-latest: true - name: Install just diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 06aae7d..bd4dfc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,4 +41,4 @@ Submitting pull requests Developing Cerbos Go SDK ------------------------ -We currently require Go 1.20.x for development. [Just](https://just.systems/man/en/chapter_1.html) is used for build tasks. Run `just` at the root of the directory to see the list of available targets. +We currently require Go 1.22.x for development. [Just](https://just.systems/man/en/chapter_1.html) is used for build tasks. Run `just` at the root of the directory to see the list of available targets. diff --git a/cerbos/grpc_linux_test.go b/cerbos/grpc_linux_test.go new file mode 100644 index 0000000..a933cb0 --- /dev/null +++ b/cerbos/grpc_linux_test.go @@ -0,0 +1,8 @@ +// Copyright 2021-2024 Zenauth Ltd. +// SPDX-License-Identifier: Apache-2.0 + +//go:build tests && linux + +package cerbos_test + +const osSupportsUDS = true diff --git a/cerbos/grpc_other_oses_test.go b/cerbos/grpc_other_oses_test.go new file mode 100644 index 0000000..8bf2be0 --- /dev/null +++ b/cerbos/grpc_other_oses_test.go @@ -0,0 +1,8 @@ +// Copyright 2021-2024 Zenauth Ltd. +// SPDX-License-Identifier: Apache-2.0 + +//go:build tests && !linux + +package cerbos_test + +const osSupportsUDS = false diff --git a/cerbos/grpc_test.go b/cerbos/grpc_test.go index d2d04cf..60573c8 100644 --- a/cerbos/grpc_test.go +++ b/cerbos/grpc_test.go @@ -93,6 +93,10 @@ func TestGRPCClient(t *testing.T) { }) t.Run("uds", func(t *testing.T) { + if !osSupportsUDS { + t.Skip("Sharing a Unix domain socket over a Docker bind mount is not supported on this operating system") + } + tempDir := t.TempDir() s, err := launcher.Launch(testutil.LaunchConf{ ConfFilePath: tc.confFilePath,