Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
utsabc authored Jul 26, 2024
2 parents 0505718 + cdea69c commit b0fc288
Show file tree
Hide file tree
Showing 118 changed files with 6,261 additions and 343 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ jobs:
fetch-depth: 1

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
uses: docker/setup-buildx-action@v3.4.0

- name: Login to DockerHub
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3.2.0
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PROD_TOKEN }}

- name: Build Docker Image
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6.4.1
with:
context: .
file: ${{ inputs.dockerfile }}
Expand All @@ -67,7 +67,7 @@ jobs:
docker run ${{ inputs.build_tag }} npm run test:ts:ci
- name: Build and Push Multi-platform Images
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6.4.1
with:
context: .
file: ${{ inputs.dockerfile }}
Expand All @@ -93,16 +93,16 @@ jobs:
fetch-depth: 1

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
uses: docker/setup-buildx-action@v3.4.0

- name: Login to DockerHub
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3.2.0
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PROD_TOKEN }}

- name: Build Docker Image
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6.4.1
with:
context: .
file: ${{ inputs.dockerfile }}
Expand All @@ -118,7 +118,7 @@ jobs:
docker run ${{ inputs.build_tag }} npm run test:ts:ci
- name: Build and Push Multi-platform Images
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6.4.1
with:
context: .
file: ${{ inputs.dockerfile }}
Expand All @@ -140,10 +140,10 @@ jobs:

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
uses: docker/setup-buildx-action@v3.4.0

- name: Login to DockerHub
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3.2.0
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PROD_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fetch-depth: 0

- name: Setup Node
uses: actions/[email protected].1
uses: actions/[email protected].3
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/component-test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fetch-depth: 1

- name: Setup Node
uses: actions/[email protected].2
uses: actions/[email protected].3
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fetch-depth: 0

- name: Setup Node
uses: actions/[email protected].2
uses: actions/[email protected].3
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dt-test-and-report-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 1

- name: Setup Node
uses: actions/[email protected].2
uses: actions/[email protected].3
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fetch-depth: 0

- name: Setup Node
uses: actions/[email protected].2
uses: actions/[email protected].3
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ut-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/[email protected].0
uses: actions/[email protected].2
with:
go-version: 1.17

Expand All @@ -26,7 +26,7 @@ jobs:
fetch-depth: 1

- name: Setup Node
uses: actions/[email protected].2
uses: actions/[email protected].3
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-server-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 1

- name: Setup Node
uses: actions/[email protected].2
uses: actions/[email protected].3
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Setup Node
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v4.0.3
with:
node-version-file: .nvmrc
cache: 'npm'
Expand Down
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ src/features.json @rudderlabs/integrations
constants/ @rudderlabs/integrations
warehouse/ @rudderlabs/warehouse
src/util/ @rudderlabs/integrations @rudderlabs/data-management
*/trackingPlan.ts @rudderlabs/data-management
*/userTransform.ts @rudderlabs/data-management
**/trackingPlan.ts @rudderlabs/data-management
**/userTransform.ts @rudderlabs/data-management
2 changes: 2 additions & 0 deletions go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go.work
go.work.sum
23 changes: 23 additions & 0 deletions go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# GO libraries

## webhook/testdata

To generate the test files use:

```bash
go generate ./...
```

Work against local rudder-server:

```bash
go work init
go work use .
go work use ../../rudder-server
```

Then run the webhook tests:

```bash
go test github.com/rudderlabs/rudder-server/gateway/webhook -count 1 -timeout 2m
```
11 changes: 11 additions & 0 deletions go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/rudderlabs/rudder-transformer/go

go 1.22.4

require github.com/stretchr/testify v1.9.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
9 changes: 9 additions & 0 deletions go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
99 changes: 99 additions & 0 deletions go/webhook/testcases/testcases.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package testcases

import (
"embed"
"encoding/json"
"io/fs"
"testing"
"time"

"github.com/stretchr/testify/require"
)

type Setup struct {
Context Context
Cases []Case
}

type Context struct {
Now time.Time
RequestIP string `json:"request_ip"`
}

type Case struct {
Name string
Description string
Skip string
Input Input
Output Output
}

type Input struct {
Request Request
}
type Request struct {
Method string
RawQuery string `json:"query"`
Headers map[string]string
Body json.RawMessage
}

type Output struct {
Response Response
Queue []json.RawMessage
ErrQueue []json.RawMessage `json:"err_queue"`
}

type Response struct {
Body json.RawMessage
StatusCode int `json:"status"`
}

//go:generate npx ts-node ../../../test/scripts/generateJson.ts sources ./testdata/testcases
//go:generate npx prettier --write ./testdata/**/*.json

//go:embed testdata/context.json
var contextData []byte

//go:embed testdata/testcases/**/*.json
var testdata embed.FS

func Load(t *testing.T) Setup {
t.Helper()

var tc Context
err := json.Unmarshal(contextData, &tc)
require.NoError(t, err)

var tcs []Case
err = fs.WalkDir(testdata, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}

if d.IsDir() {
return nil
}

f, err := testdata.Open(path)
if err != nil {
return err
}
defer f.Close()

var tc Case
err = json.NewDecoder(f).Decode(&tc)
if err != nil {
return err
}
tcs = append(tcs, tc)

return nil
})
require.NoError(t, err)

return Setup{
Context: tc,
Cases: tcs,
}
}
5 changes: 5 additions & 0 deletions go/webhook/testcases/testdata/context.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"request_ip_comment": "192.0.2.x/24 - This block is assigned as \"TEST-NET\" for use in documentation and example code.",
"request_ip": "192.0.2.30",
"now": "2024-03-03T04:48:29.000Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "adjust",
"description": "Simple track call",
"input": {
"request": {
"body": {
"id": "adjust",
"query_parameters": {
"gps_adid": ["38400000-8cf0-11bd-b23e-10b96e40000d"],
"adid": ["18546f6171f67e29d1cb983322ad1329"],
"tracker_token": ["abc"],
"custom": ["custom"],
"tracker_name": ["dummy"],
"created_at": ["1404214665"],
"event_name": ["Click"]
},
"updated_at": "2023-02-10T12:16:07.251Z",
"created_at": "2023-02-10T12:05:04.402Z"
},
"headers": {
"Content-Type": "application/json"
}
}
},
"output": {
"response": {
"status": 200,
"body": "OK"
},
"queue": [
{
"context": {
"library": {
"name": "unknown",
"version": "unknown"
},
"integration": {
"name": "Adjust"
},
"device": {
"id ": "18546f6171f67e29d1cb983322ad1329"
}
},
"integrations": {
"Adjust": false
},
"type": "track",
"event": "Click",
"originalTimestamp": "2014-07-01T11:37:45.000Z",
"timestamp": "2014-07-01T11:37:45.000Z",
"properties": {
"gps_adid": "38400000-8cf0-11bd-b23e-10b96e40000d",
"tracker_token": "abc",
"custom": "custom",
"tracker_name": "dummy"
},
"anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513",
"receivedAt": "2024-03-03T04:48:29.000Z",
"request_ip": "192.0.2.30",
"messageId": "00000000-0000-0000-0000-000000000000"
}
],
"errQueue": []
},
"skip": "FIXME"
}
Loading

0 comments on commit b0fc288

Please sign in to comment.