From 4ed91700c884a5d5bd3767c81c72ffe6522ee15f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 13 Jan 2023 17:30:54 +0100 Subject: [PATCH] gha: add basic test Test against the "oldest" supported version and the current version of go. Go 1.17 is kept in this matrix as it is the minimum version specified in go.mod, and maintaining compatibility with go 1.17 is currently not much of a burden. Most projects using this module are using newer versions than that, so we can drop the old version if it becomes too much of a burden. Signed-off-by: Sebastiaan van Stijn --- .github/workflows/test.yml | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0bd1b6e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ +name: test +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: + branches: + - master + - main + +jobs: + test: + permissions: + contents: read # for actions/checkout to fetch code + timeout-minutes: 10 + + strategy: + matrix: + # test against the "oldest" supported version and the current version + # of go. Go 1.17 is kept in this matrix as it is the minimum version + # specified in go.mod, and maintaining compatibility with go 1.17 is + # currently not much of a burden. Most projects using this module are + # using newer versions than that, so we can drop the old version if + # it becomes too much of a burden. + go-version: [1.17.x, stable] + os: [ubuntu-20.04, ubuntu-22.04, windows-2022] + runs-on: ${{ matrix.os }} + steps: + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v3 + - name: go mod tidy + run: | + go mod tidy + git diff --exit-code + - name: Test + run: | + go test -exec "sudo -n" -v ./... +