Skip to content

Commit debe1f2

Browse files
authored
Add Github Actions workflow as CI (#1)
Adding CI to this project using Github Actions. It will run: - unit tests, go test in the root directory - fuzz tests, go test in the fuzz/ directory - integration tests, go test in the integration/ directory - `golangci-lint run ./...` in all modules - `go vet ./...` in all modules We need to run these commands in all Go module directories because the expansion pattern `./...` in the root module will not expand to the Go files in the sub Go modules (fuzz and integration).
1 parent aae2ae5 commit debe1f2

File tree

5 files changed

+98
-4
lines changed

5 files changed

+98
-4
lines changed

.github/workflows/golang.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: ${{github.workflow}}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
unit-tests:
17+
name: unit tests
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: '1.22.2'
23+
cache-dependency-path: "**/*.sum"
24+
- uses: actions/checkout@v4
25+
- run: go mod verify
26+
- run: go test ./...
27+
28+
fuzz-tests:
29+
name: fuzz tests
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version: '1.22.2'
35+
cache-dependency-path: "**/*.sum"
36+
- uses: actions/checkout@v4
37+
- run: go mod verify
38+
- run: go mod download
39+
- run: cd fuzz && go test ./...
40+
41+
integration-tests:
42+
name: integration tests
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/setup-go@v5
46+
with:
47+
go-version: '1.22.2'
48+
cache-dependency-path: "**/*.sum"
49+
- uses: actions/checkout@v4
50+
- run: go mod verify
51+
- run: go mod download
52+
- run: cd integration && go test ./...
53+
54+
go-vet:
55+
name: go vet
56+
runs-on: ubuntu-latest
57+
permissions:
58+
contents: read
59+
pull-requests: read
60+
checks: write
61+
steps:
62+
- uses: actions/setup-go@v5
63+
with:
64+
go-version: '1.22.2'
65+
cache-dependency-path: "**/*.sum"
66+
- uses: actions/checkout@v4
67+
- run: go vet ./...
68+
- run: cd fuzz && go vet ./...
69+
- run: cd integration && go vet ./...
70+
71+
golangci-lint:
72+
name: golangci-lint
73+
runs-on: ubuntu-latest
74+
permissions:
75+
contents: read
76+
pull-requests: read
77+
checks: write
78+
steps:
79+
- uses: actions/setup-go@v5
80+
with:
81+
go-version: '1.22.2'
82+
cache-dependency-path: "**/*.sum"
83+
- uses: actions/checkout@v4
84+
- uses: golangci/golangci-lint-action@v5
85+
with:
86+
version: 'v1.57.2'
87+
- uses: golangci/golangci-lint-action@v5
88+
with:
89+
working-directory: 'fuzz'
90+
version: 'v1.57.2'
91+
- uses: golangci/golangci-lint-action@v5
92+
with:
93+
working-directory: 'integration'
94+
version: 'v1.57.2'

examples/readme_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/poki/mongodb-filter-to-postgres/filter"
77
)
88

9-
func ExampleNewConverter_README() {
9+
func ExampleNewConverter_readme() {
1010
// Remeber to use `filter.WithArrayDriver(pg.Array)` when using github.com/lib/pq
1111
converter := filter.NewConverter(filter.WithNestedJSONB("meta", "created_at", "updated_at"))
1212

fuzz/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/poki/mongodb-filter-to-postgres/fuzz
22

3-
go 1.21.0
3+
go 1.22.2
44

55
replace github.com/poki/mongodb-filter-to-postgres v0.0.0 => ../
66

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/poki/mongodb-filter-to-postgres
22

3-
go 1.21.0
3+
go 1.22.2

integration/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/poki/mongodb-filter-to-postgres/fuzz
22

3-
go 1.21.0
3+
go 1.22.2
44

55
replace github.com/poki/mongodb-filter-to-postgres v0.0.0 => ../
66

0 commit comments

Comments
 (0)