Skip to content

Commit

Permalink
Merge branch 'ci' into UOE-9681
Browse files Browse the repository at this point in the history
  • Loading branch information
AvinashKapre authored Nov 3, 2023
2 parents f6b3b10 + dcaa2a6 commit 9baf864
Show file tree
Hide file tree
Showing 76 changed files with 2,372 additions and 920 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/adapter-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
id: run_coverage
if: ${{ steps.get_directories.outputs.result }} != ""
run: |
git config --global url."https://${USERNAME}:${TOKEN}@git.pubmatic.com".insteadOf "https://git.pubmatic.com"
directories=$(echo '${{ steps.get_directories.outputs.result }}' | jq -r '.[]')
go mod download
Expand All @@ -65,13 +67,18 @@ jobs:
# remove pull request branch files
cd ..
rm -f -r ./*
env:
GO111MODULE: "on"
GOPRIVATE: "git.pubmatic.com/PubMatic/*"
TOKEN: ${{ secrets.PM_OPENWRAP_CICD_PASSWORD }}
USERNAME: ${{ secrets.PM_OPENWRAP_CICD_USERNAME }}

- name: Checkout coverage-preview branch
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: coverage-preview
repository: prebid/prebid-server
repository: PubMatic-OpenWrap/prebid-server

- name: Commit coverage files to coverage-preview branch
if: ${{ steps.run_coverage.outputs.coverage_dir }} != ""
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cross-repo-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request_target:
types: [closed]
branches:
- "master"
- "master-disable"

jobs:
cross-repo:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/validate-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Validate Merge

on:
pull_request:
branches: [master]
branches:
- master
- main
- ci

jobs:
validate-merge:
Expand All @@ -19,6 +22,10 @@ jobs:

- name: Validate
run: |
git config --global url."https://${USERNAME}:${TOKEN}@git.pubmatic.com".insteadOf "https://git.pubmatic.com"
./validate.sh --nofmt --cov --race 10
env:
GO111MODULE: "on"
GOPRIVATE: "git.pubmatic.com/PubMatic/*"
TOKEN: ${{ secrets.PM_OPENWRAP_CICD_PASSWORD }}
USERNAME: ${{ secrets.PM_OPENWRAP_CICD_USERNAME }}
4 changes: 4 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:

- name: Validate
run: |
git config --global url."https://${USERNAME}:${TOKEN}@git.pubmatic.com".insteadOf "https://git.pubmatic.com"
./validate.sh --nofmt --cov --race 10
env:
GO111MODULE: "on"
GOPRIVATE: "git.pubmatic.com/PubMatic/*"
TOKEN: ${{ secrets.PM_OPENWRAP_CICD_PASSWORD }}
USERNAME: ${{ secrets.PM_OPENWRAP_CICD_USERNAME }}
24 changes: 24 additions & 0 deletions adapters/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
const MAX_IMPRESSIONS_PUBMATIC = 30

const (
ae = "ae"
PUBMATIC = "[PUBMATIC]"
buyId = "buyid"
buyIdTargetingKey = "hb_buyid_"
Expand Down Expand Up @@ -60,6 +61,7 @@ type pubmaticBidExtVideo struct {
type ExtImpBidderPubmatic struct {
adapters.ExtImpBidder
Data json.RawMessage `json:"data,omitempty"`
AE int `json:"ae,omitempty"`
SKAdnetwork json.RawMessage `json:"skadn,omitempty"`
}

Expand All @@ -79,6 +81,10 @@ type extRequestAdServer struct {
openrtb_ext.ExtRequest
}

type respExt struct {
FledgeAuctionConfigs map[string]json.RawMessage `json:"fledge_auction_configs,omitempty"`
}

const (
dctrKeyName = "key_val"
pmZoneIDKeyName = "pmZoneId"
Expand Down Expand Up @@ -386,6 +392,10 @@ func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractP
extMap[bidViewability] = pubmaticExt.BidViewabilityScore
}

if bidderExt.AE != 0 {
extMap[ae] = bidderExt.AE
}

imp.Ext = nil
if len(extMap) > 0 {
ext, err := json.Marshal(extMap)
Expand Down Expand Up @@ -582,6 +592,20 @@ func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa
if bidResp.Cur != "" {
bidResponse.Currency = bidResp.Cur
}

if bidResp.Ext != nil {
var bidRespExt respExt
if err := json.Unmarshal(bidResp.Ext, &bidRespExt); err == nil && bidRespExt.FledgeAuctionConfigs != nil {
bidResponse.FledgeAuctionConfigs = make([]*openrtb_ext.FledgeAuctionConfig, 0, len(bidRespExt.FledgeAuctionConfigs))
for impId, config := range bidRespExt.FledgeAuctionConfigs {
fledgeAuctionConfig := &openrtb_ext.FledgeAuctionConfig{
ImpId: impId,
Config: config,
}
bidResponse.FledgeAuctionConfigs = append(bidResponse.FledgeAuctionConfigs, fledgeAuctionConfig)
}
}
}
return bidResponse, errs
}

Expand Down
166 changes: 166 additions & 0 deletions adapters/pubmatic/pubmatictest/exemplary/fledge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"ext": {
"ae": 1,
"bidder": {
"publisherId": "999",
"adSlot": "AdTag_Div1@300x250"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://hbopenbid.pubmatic.com/translator?source=prebid-server",
"body": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
],
"h": 250,
"w": 300
},
"tagid": "AdTag_Div1",
"ext": {
"ae": 1
}
}
],
"ext": {"prebid":{}}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "pubmatic",
"bid": [
{
"id": "9d8e77c2-ee0f-4781-af59-5359493b11af",
"impid": "test-imp-id",
"price": 1.1,
"adm": "some-test-ad",
"crid": "crid_10",
"h": 90,
"w": 728,
"ext": {}
}
]
}
],
"cur": "USD",
"ext": {
"fledge_auction_configs": {
"test-imp-id": {
"seller": "PUBMATIC_SELLER_CONSTANT_STRING",
"sellerTimeout": 123,
"decisionLogicUrl": "PUBMATIC_URL_CONSTANT_STRING",
"interestGroupBuyers": [
"somedomain1.com",
"somedomain2.com",
"somedomain3.com",
"somedomain4.com"
],
"perBuyerSignals": {
"somedomain1.com": {
"multiplier": 1,
"win_reporting_id": "1234"
},
"somedomain2.com": {
"multiplier": 2,
"win_reporting_id": "2345"
},
"somedomain3.com": {
"multiplier": 3,
"win_reporting_id": "3456"
},
"somedomain4.com": {
"multiplier": 4,
"win_reporting_id": "4567"
}
}
}
}
}
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "9d8e77c2-ee0f-4781-af59-5359493b11af",
"impid": "test-imp-id",
"price": 1.1,
"adm": "some-test-ad",
"crid": "crid_10",
"w": 728,
"h": 90,
"ext": {}
},
"type": "banner"
}
],
"fledgeauctionconfigs": [
{
"impid": "test-imp-id",
"config": {
"seller": "PUBMATIC_SELLER_CONSTANT_STRING",
"sellerTimeout": 123,
"decisionLogicUrl": "PUBMATIC_URL_CONSTANT_STRING",
"interestGroupBuyers": [
"somedomain1.com",
"somedomain2.com",
"somedomain3.com",
"somedomain4.com"
],
"perBuyerSignals": {
"somedomain1.com": {
"multiplier": 1,
"win_reporting_id": "1234"
},
"somedomain2.com": {
"multiplier": 2,
"win_reporting_id": "2345"
},
"somedomain3.com": {
"multiplier": 3,
"win_reporting_id": "3456"
},
"somedomain4.com": {
"multiplier": 4,
"win_reporting_id": "4567"
}
}
}
}
]
}
]
}
52 changes: 30 additions & 22 deletions adapters/vastbidder/bidder_macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -177,16 +176,35 @@ func (tag *BidderMacro) GetHeaders() http.Header {
return http.Header{}
}

// GetValueFromKV returns the value from KV map wrt key
func (tag *BidderMacro) GetValueFromKV(key string) string {
if tag.KV == nil {
return ""
}
key = strings.TrimPrefix(key, kvPrefix)
if value, found := tag.KV[key]; found {
return fmt.Sprintf("%v", value)
// GetValue returns the value for given key
// isKeyFound will check the key is present or not
func (tag *BidderMacro) GetValue(key string) (string, bool) {
macroKeys := strings.Split(key, ".")
isKeyFound := false

// This will check if key has prefix kv/kvm
// if prefix present it will always return isKeyFound as true as it will help to replace the key with empty string in VAST TAG
if (macroKeys[0] == MacroKV || macroKeys[0] == MacroKVM) && len(macroKeys) > 1 {
isKeyFound = true
if tag.KV == nil {
return "", isKeyFound
}
switch macroKeys[0] {
case MacroKV:
val := getValueFromMap(macroKeys[1:], tag.KV)
if dataMap, ok := val.(map[string]interface{}); ok {
return mapToQuery(dataMap), isKeyFound
}
return fmt.Sprintf("%v", val), isKeyFound
case MacroKVM:
val := getValueFromMap(macroKeys[1:], tag.KV)
if isMap(val) {
return getJSONString(val), isKeyFound
}
return fmt.Sprintf("%v", val), isKeyFound
}
}
return ""
return "", isKeyFound
}

/********************* Request *********************/
Expand Down Expand Up @@ -1209,25 +1227,15 @@ func (tag *BidderMacro) MacroKV(key string) string {
if tag.KV == nil {
return ""
}

values := url.Values{}
for key, val := range tag.KV {
values.Add(key, fmt.Sprintf("%v", val))
}
return values.Encode()

return mapToQuery(tag.KV)
}

// MacroKVM replace the kvm macro
func (tag *BidderMacro) MacroKVM(key string) string {
if tag.KV == nil {
return ""
}
jsonBytes, err := json.Marshal(tag.KV)
if err != nil {
return ""
}
return string(jsonBytes)
return getJSONString(tag.KV)
}

/********************* Request Headers *********************/
Expand Down
Loading

0 comments on commit 9baf864

Please sign in to comment.