From e882cc1dd8c25fede1e40baa27d8c5988b4730a4 Mon Sep 17 00:00:00 2001 From: Koen Bollen Date: Fri, 26 Apr 2024 13:38:56 +0200 Subject: [PATCH] Add Github Actions workflow as CI - Also fixed a go vet issue - Set the project to use Go version 1.22.2 --- .github/workflows/golang.yaml | 85 +++++++++++++++++++++++++++++++++++ examples/readme_test.go | 2 +- fuzz/go.mod | 2 +- go.mod | 2 +- integration/go.mod | 2 +- 5 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/golang.yaml diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml new file mode 100644 index 0000000..6bf8ef9 --- /dev/null +++ b/.github/workflows/golang.yaml @@ -0,0 +1,85 @@ +name: Go + +on: + push: + branches: + - main + - setup-github-actions # for testing + pull_request: + branches: + - main + +concurrency: + group: ${{github.workflow}}-${{ github.ref }} + cancel-in-progress: true + +jobs: + unit-tests: + name: unit tests + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.22.2' + - uses: actions/checkout@v4 + - run: go mod verify + - run: go test ./... + + fuzz-tests: + name: fuzz tests + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.22.2' + - uses: actions/checkout@v4 + - run: go mod verify + - run: cd fuzz && go test ./... + + integration-tests: + name: integration tests + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.22.2' + - uses: actions/checkout@v4 + - run: go mod verify + - run: cd integration && go test ./... + + go-vet: + name: go vet + runs-on: ubuntu-latest + strategy: + matrix: + modules: ['.', 'fuzz', 'integration'] + permissions: + contents: read + pull-requests: read + checks: write + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.22.2' + - uses: actions/checkout@v4 + - run: cd "${{ matrix.modules }}" && go vet ./... + + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + strategy: + matrix: + modules: ['.', 'fuzz', 'integration'] + permissions: + contents: read + pull-requests: read + checks: write + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.22.2' + - uses: actions/checkout@v4 + - uses: golangci/golangci-lint-action@v5 + with: + working-directory: '${{ matrix.modules }}' + version: 'v1.57.2' diff --git a/examples/readme_test.go b/examples/readme_test.go index 3e1c16c..7cfb652 100644 --- a/examples/readme_test.go +++ b/examples/readme_test.go @@ -6,7 +6,7 @@ import ( "github.com/poki/mongodb-filter-to-postgres/filter" ) -func ExampleNewConverter_README() { +func ExampleNewConverter_readme() { // Remeber to use `filter.WithArrayDriver(pg.Array)` when using github.com/lib/pq converter := filter.NewConverter(filter.WithNestedJSONB("meta", "created_at", "updated_at")) diff --git a/fuzz/go.mod b/fuzz/go.mod index 6b9b116..655c5e5 100644 --- a/fuzz/go.mod +++ b/fuzz/go.mod @@ -1,6 +1,6 @@ module github.com/poki/mongodb-filter-to-postgres/fuzz -go 1.21.0 +go 1.22.2 replace github.com/poki/mongodb-filter-to-postgres v0.0.0 => ../ diff --git a/go.mod b/go.mod index d1b66bb..80812b0 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/poki/mongodb-filter-to-postgres -go 1.21.0 +go 1.22.2 diff --git a/integration/go.mod b/integration/go.mod index dc7cfcb..557061e 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -1,6 +1,6 @@ module github.com/poki/mongodb-filter-to-postgres/fuzz -go 1.21.0 +go 1.22.2 replace github.com/poki/mongodb-filter-to-postgres v0.0.0 => ../