Skip to content

Commit

Permalink
Merge pull request #31 from prebid/master
Browse files Browse the repository at this point in the history
...
  • Loading branch information
ahmadlob committed Feb 18, 2024
2 parents e43fc44 + 11c77af commit 41df13f
Show file tree
Hide file tree
Showing 515 changed files with 37,929 additions and 11,628 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ aliases:
- &environment
docker:
# specify the version you desire here
- image: circleci/node:12.16.1-browsers
- image: cimg/node:16.20-browsers
resource_class: xlarge
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down
35 changes: 33 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@ module.exports = {
node: {
moduleDirectory: ['node_modules', './']
}
},
'jsdoc': {
mode: 'typescript',
tagNamePreference: {
'tag constructor': 'constructor',
extends: 'extends',
method: 'method',
return: 'return',
}
}
},
extends: 'standard',
extends: [
'standard',
'plugin:jsdoc/recommended'
],
plugins: [
'prebid',
'import'
'import',
'jsdoc'
],
globals: {
'BROWSERSTACK_USERNAME': false,
Expand Down Expand Up @@ -46,6 +59,24 @@ module.exports = {
'no-undef': 2,
'no-useless-escape': 'off',
'no-console': 'error',
'jsdoc/check-types': 'off',
'jsdoc/newline-after-description': 'off',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-param-name': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/require-property': 'off',
'jsdoc/require-property-description': 'off',
'jsdoc/require-property-name': 'off',
'jsdoc/require-property-type': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/require-returns-check': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/require-yields': 'off',
'jsdoc/require-yields-check': 'off',
'jsdoc/tag-lines': 'off'
},
overrides: Object.keys(allowedModules).map((key) => ({
files: key + '/**/*.js',
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
Expand All @@ -57,7 +57,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -70,4 +70,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
env:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ gulp test-coverage
gulp view-coverage
```

Local end-to-end testing can be done with:

```bash
gulp e2e-test --local
```

For Prebid.org members with access to BrowserStack, additional end-to-end testing can be done with:

```bash
Expand Down
63 changes: 42 additions & 21 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ function clean() {
.pipe(gulpClean());
}

function requireNodeVersion(version) {
return (done) => {
const [major] = process.versions.node.split('.');

if (major < version) {
throw new Error(`This task requires Node v${version}`)
}

done();
}
}

// Dependant task for building postbid. It escapes postbid-config file.
function escapePostbidConfig() {
gulp.src('./integrationExamples/postbid/oas/postbid-config.js')
Expand All @@ -76,7 +88,7 @@ function lint(done) {
'!plugins/**/node_modules/**',
'./*.js'
], { base: './' })
.pipe(gulpif(argv.nolintfix, eslint(), eslint({ fix: true })))
.pipe(eslint({ fix: !argv.nolintfix, quiet: !(typeof argv.lintWarnings === 'boolean' ? argv.lintWarnings : true) }))
.pipe(eslint.format('stylish'))
.pipe(eslint.failAfterError())
.pipe(gulpif(isFixed, gulp.dest('./')));
Expand Down Expand Up @@ -293,7 +305,7 @@ function bundle(dev, moduleArr) {
// If --notest is given, it will immediately skip the test task (useful for developing changes with `gulp serve --notest`)

function testTaskMaker(options = {}) {
['watch', 'e2e', 'file', 'browserstack', 'notest'].forEach(opt => {
['watch', 'file', 'browserstack', 'notest'].forEach(opt => {
options[opt] = options.hasOwnProperty(opt) ? options[opt] : argv[opt];
})

Expand All @@ -302,22 +314,6 @@ function testTaskMaker(options = {}) {
return function test(done) {
if (options.notest) {
done();
} else if (options.e2e) {
const integ = startIntegServer();
startLocalServer();
runWebdriver(options)
.then(stdout => {
// kill fake server
integ.kill('SIGINT');
done();
process.exit(0);
})
.catch(err => {
// kill fake server
integ.kill('SIGINT');
done(new Error(`Tests failed with error: ${err}`));
process.exit(1);
});
} else {
runKarma(options, done)
}
Expand All @@ -326,10 +322,34 @@ function testTaskMaker(options = {}) {

const test = testTaskMaker();

function e2eTestTaskMaker() {
return function test(done) {
const integ = startIntegServer();
startLocalServer();
runWebdriver({})
.then(stdout => {
// kill fake server
integ.kill('SIGINT');
done();
process.exit(0);
})
.catch(err => {
// kill fake server
integ.kill('SIGINT');
done(new Error(`Tests failed with error: ${err}`));
process.exit(1);
});
}
}

function runWebdriver({file}) {
process.env.TEST_SERVER_HOST = argv.host || 'localhost';

let local = argv.local || false;

let wdioConfFile = local === true ? 'wdio.local.conf.js' : 'wdio.conf.js';
let wdioCmd = path.join(__dirname, 'node_modules/.bin/wdio');
let wdioConf = path.join(__dirname, 'wdio.conf.js');
let wdioConf = path.join(__dirname, wdioConfFile);
let wdioOpts;

if (file) {
Expand Down Expand Up @@ -486,8 +506,9 @@ gulp.task('serve-e2e-dev', gulp.series(clean, 'build-bundle-dev', gulp.parallel(

gulp.task('default', gulp.series(clean, 'build-bundle-prod'));

gulp.task('e2e-test-only', () => runWebdriver({file: argv.file}));
gulp.task('e2e-test', gulp.series(clean, 'build-bundle-prod', testTaskMaker({e2e: true})));
gulp.task('e2e-test-only', gulp.series(requireNodeVersion(16), () => runWebdriver({file: argv.file})));
gulp.task('e2e-test', gulp.series(requireNodeVersion(16), clean, 'build-bundle-prod', e2eTestTaskMaker()));

// other tasks
gulp.task(bundleToStdout);
gulp.task('bundle', gulpBundle.bind(null, false)); // used for just concatenating pre-built files with no build step
Expand Down
91 changes: 91 additions & 0 deletions integrationExamples/gpt/contxtfulRtdProvider_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<html>

<head>
<script src="http://localhost:9999/build/dev/prebid.js" async></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script async>
const FAILSAFE_TIMEOUT = 8000;
const PREBID_TIMEOUT = 5000;

const bidders = [
{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}
];

var adUnits = [
{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]],
}
},
bids: bidders,
}
];


var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

pbjs.que.push(function () {
pbjs.setConfig({
debug: true,
realTimeData: {
auctionDelay: 100,
dataProviders: [
{
name: "contxtful",
waitForIt: true,
params: {
version: "Contact [email protected] for the API version",
customer: "Contact [email protected] for the customer ID"
}
}
]
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function () {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);

</script>
</head>

<body>
<h2>Contxtful RTD Provider</h2>
<div id='div-gpt-ad-1460505748561-0'></div>
</div>
</body>

</html>
15 changes: 6 additions & 9 deletions integrationExamples/gpt/fledge_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@

pbjs.que.push(function() {
pbjs.setConfig({
fledgeForGpt: {
enabled: true
}
});

pbjs.setBidderConfig({
bidders: ['openx'],
config: {
fledgeEnabled: true
paapi: {
enabled: true,
gpt: {
autoconfig: false
}
}
});

Expand All @@ -69,6 +65,7 @@
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
pbjs.setPAAPIConfigForGPT();
googletag.pubads().refresh();
});
});
Expand Down
Loading

0 comments on commit 41df13f

Please sign in to comment.