Skip to content

Commit

Permalink
Merge branch 'master' into synchronize-maven-dependencies
Browse files Browse the repository at this point in the history
# Conflicts:
#	extra/bundle/pom.xml
#	extra/pom.xml
  • Loading branch information
osulzhenko committed Jan 30, 2024
2 parents 4631fc8 + f0489f6 commit 99a4471
Show file tree
Hide file tree
Showing 86 changed files with 3,335 additions and 132 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-image-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish Docker image for new tag/release

on:
push:
tags:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
name: Publish Docker image for new tag/release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
java: [ 17 ]
dockerfile-path: [Dockerfile, extra/Dockerfile]
include:
- dockerfile-path: Dockerfile
build-cmd: mvn clean package -Dcheckstyle.skip -Dmaven.test.skip=true
package-name: ghcr.io/${{ github.repository }}
- dockerfile-path: extra/Dockerfile
build-cmd: mvn clean package --file extra/pom.xml -Dcheckstyle.skip -Dmaven.test.skip=true
package-name: ghcr.io/${{ github.repository }}-bundle
steps:
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
cache: 'maven'
java-version: ${{ matrix.java }}
- name: Build .jar via Maven
run: ${{ matrix.build-cmd }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker Image
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.package-name }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile-path }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/pr-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
java-version: ${{ matrix.java }}

- name: Build with Maven
run: mvn -B verify -DskipUnitTests=true -Dtests.max-container-count=5 --file extra/pom.xml
run: mvn -B verify -DskipUnitTests=true -DskipModuleFunctionalTests=true -Dtests.max-container-count=5 -DdockerfileName=Dockerfile --file extra/pom.xml
36 changes: 36 additions & 0 deletions .github/workflows/pr-module-functional-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Module functional tests

on:
pull_request:
paths-ignore:
- 'docs/**'
- '.github/**'
branches:
- master
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
java: [ 17 ]

steps:
- uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
cache: 'maven'
java-version: ${{ matrix.java }}

- name: Build with Maven
run: mvn package -DskipUnitTests=true --file extra/pom.xml

- name: Run module tests
run: mvn -B verify -DskipUnitTests=true -DskipFunctionalTests=true -Dtests.max-container-count=5 -DdockerfileName=Dockerfile-modules --file extra/pom.xml
43 changes: 43 additions & 0 deletions .github/workflows/release-asset-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish release .jar

on:
push:
tags:
- '*'

jobs:
build:
name: Publish release .jar
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17 ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
cache: 'maven'
java-version: ${{ matrix.java }}

- name: Build base .jar via Maven
run: mvn clean package -Dcheckstyle.skip -Dmaven.test.skip=true
- name: Upload and attach base .jar to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/prebid-server.jar
asset_name: prebid-server-${{ github.ref_name }}.jar
tag: ${{ github.ref }}

- name: Build bundled .jar via Maven
run: mvn clean package --file extra/pom.xml -Dcheckstyle.skip -Dmaven.test.skip=true
- name: Upload and attach bundled .jar to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: extra/bundle/target/prebid-server-bundle.jar
asset_name: prebid-server-bundle-${{ github.ref_name }}.jar
overwrite: true
tag: ${{ github.ref }}
15 changes: 15 additions & 0 deletions Dockerfile-modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM amazoncorretto:17

WORKDIR /app/prebid-server

VOLUME /app/prebid-server/conf
VOLUME /app/prebid-server/data

COPY src/main/docker/run.sh ./
COPY src/main/docker/application.yaml ./
COPY target/prebid-server-bundle.jar ./prebid-server.jar

EXPOSE 8080
EXPOSE 8060

ENTRYPOINT [ "/app/prebid-server/run.sh" ]
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,28 @@ Run your local server with the command:
```bash
java -jar target/prebid-server.jar --spring.config.additional-location=sample/prebid-config.yaml
```

For more options how to start the server, please follow [documentation](docs/run.md).

## Running prebuilt .jar
Starting from PBS Java v2.9, you can download prebuilt .jar packages from [Release Notes](https://github.com/prebid/prebid-server-java/releases) page, instead of building them by yourself.
This prebuilt packages are delivered with or without extra modules.

## Verifying

To check the server is started go to [http://localhost:8080/status](http://localhost:8080/status)
and verify response status is `200 OK`.

There are a couple of 'hello world' test requests described in sample/requests/README.txt

## Running Docker image

Starting from PBS Java v2.9, you can download prebuilt Docker images from [GitHub Packages](https://github.com/orgs/prebid/packages?repo_name=prebid-server-java) page,
and use them instead of plain .jar files. This prebuilt images are delivered with or without extra modules.

In order to run such image correctly, you should attach PBS config file. Easiest way is to mount config file into container,
using [--mount or --volume (-v) Docker CLI arguments](https://docs.docker.com/engine/reference/commandline/run/).
Keep in mind, that config file should be mounted into specific location: ```/app/prebid-server/``` or ```/app/prebid-server/conf/```.

# Documentation

## Development
Expand Down
40 changes: 33 additions & 7 deletions docs/developers/functional-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,43 @@ And [MockServer](https://www.mock-server.com/) for mocking external services.
- Install [Docker](https://docs.docker.com/engine/install/)
- Set launchContainers system property to 'true'

### Prepare PBS image
## Preparing the PBS Image

`mvn clean -B package -DskipUnitTests=true docker:build` - to build image
To prepare the PBS image, follow these steps from the root directory:

> Don't forget to rebuild image for manual test start (after change in dev code)
1. Build the project using Maven:

### Run integration tests
`mvn clean -B package -f extra/pom.xml`

- You can use `mvn verify` - to include all previous steps (including java test) because groovy runs
in `failsafe:integration-test` phase
- Or use more granular `mvn -B verify -DskipUnitTests=true` for functional tests only
2. Build the image:

2.1 Build image without modules:

`mvn docker:build -f pom.xml`

2.2 Build image with modules:

`mvn docker:build -f pom.xml -DdockerfileName=Dockerfile-modules`

**Note:** Don't forget to rebuild the image for manual test start after making changes in the dev code.

## Running Functional Tests

You have two options for running functional tests:

1. Use `mvn verify` to include all previous steps (including Java tests and modular tests) because Groovy runs in the `failsafe:integration-test` phase.
2. For functional tests only, use a more granular command:

`mvn -B verify -DskipModuleFunctionalTests=true`

## Running Module Functional Tests

You have two options for running modular tests:

1. Use `mvn verify -DdockerfileName=Dockerfile-modules` to include all previous steps (including Java tests and functional tests) because Groovy runs in the `failsafe:integration-test` phase.
2. For modular tests only, use a more granular command:

`mvn -B verify -DskipUnitTests=true -DskipFunctionalTests=true -DdockerfileName=Dockerfile-modules`

## Developing

Expand Down
14 changes: 14 additions & 0 deletions extra/bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<artifactId>ortb2-blocking</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>pb-richmedia-filter</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -58,6 +63,15 @@
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>pbs-build</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<outputDirectory>../../target</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
55 changes: 55 additions & 0 deletions extra/modules/pb-richmedia-filter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Overview

This module filters out bids from all the bid responses by the provided filtering logic for any given auction.
The filtering logic can be provided by enabling the hook.

## Configuration

To start using current module you have to enable module and add ``pb-richmedia-filter-all-processed-bid-responses-hook`` into hooks execution plan inside your yaml file:
```yaml
hooks:
pb-richmedia-filter:
enabled: true
host-execution-plan: >
{
"endpoints": {
"/openrtb2/auction": {
"stages": {
"all-processed-bid-responses": {
"groups": [
{
"timeout": 100,
"hook-sequence": [
{
"module-code": "pb-richmedia-filter",
"hook-impl-code": "pb-richmedia-filter-all-processed-bid-responses-hook"
}
]
}
]
}
}
}
}
}
```
And configure
## List of module configuration options
- `filter-mraid` - `true` enables the following logic: filter out any bid response that contains the provided `mraid-script-pattern` in the `adm` field
- `mraid-script-pattern` - a raw string with the MRAID script to be searched as it is

```yaml
hooks:
modules:
pb-richmedia-filter:
filter-mraid: true
mraid-script-pattern: >
<script src="mraid.js"></script>
```

## Maintainer contacts

Any suggestions or questions can be directed by opening a new [issue](https://github.com/prebid/prebid-server-java/issues/new)
or [pull request](https://github.com/prebid/prebid-server-java/pulls) in this repository.
16 changes: 16 additions & 0 deletions extra/modules/pb-richmedia-filter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>${revision}</version>
</parent>

<artifactId>pb-richmedia-filter</artifactId>

<name>pb-richmedia-filter</name>
<description>Richmedia Filter</description>

</project>
2 changes: 2 additions & 0 deletions extra/modules/pb-richmedia-filter/src/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.stopBubbling = true
lombok.anyConstructor.suppressConstructorProperties = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.prebid.server.hooks.modules.pb.richmedia.filter.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.prebid.server.hooks.modules.pb.richmedia.filter.core.BidResponsesMraidFilter;
import org.prebid.server.hooks.modules.pb.richmedia.filter.core.ModuleConfigResolver;
import org.prebid.server.hooks.modules.pb.richmedia.filter.model.PbRichMediaFilterProperties;
import org.prebid.server.hooks.modules.pb.richmedia.filter.v1.PbRichmediaFilterAllProcessedBidResponsesHook;
import org.prebid.server.hooks.modules.pb.richmedia.filter.v1.PbRichmediaFilterModule;
import org.prebid.server.json.ObjectMapperProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@ConditionalOnProperty(prefix = "hooks." + PbRichmediaFilterModule.CODE, name = "enabled", havingValue = "true")
@Configuration
public class PbRichmediaFilterModuleConfiguration {

@Bean
PbRichmediaFilterModule pbRichmediaFilterModule(
@Value("${hooks.modules.pb-richmedia-filter.filter-mraid}") Boolean filterMraid,
@Value("${hooks.modules.pb-richmedia-filter.mraid-script-pattern}") String mraidScriptPattern) {

final ObjectMapper mapper = ObjectMapperProvider.mapper();
final PbRichMediaFilterProperties globalProperties = PbRichMediaFilterProperties.of(
filterMraid,
mraidScriptPattern);

return new PbRichmediaFilterModule(List.of(
new PbRichmediaFilterAllProcessedBidResponsesHook(
mapper,
new BidResponsesMraidFilter(),
new ModuleConfigResolver(mapper, globalProperties))));
}

}
Loading

0 comments on commit 99a4471

Please sign in to comment.