Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Jun 18, 2024
2 parents 9cdfaaf + b53f89f commit 3df2fd6
Show file tree
Hide file tree
Showing 22 changed files with 258 additions and 1,232 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Node.js CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: ['18.x', '20.x']

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm i
- name: Running tests
run: npm run test-core-plugins
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
"iframely"
],

KNOWN_VIDEO_SOURCES: /(youtube|youtu|youtube\-nocookie|vimeo|dailymotion|theplatform|jwplatform|jwplayer|cnevids|newsinc|podbean|simplecast|libsyn|wistia|podiant|art19|kaltura|mtvnservices|brightcove|bcove|soundcloud|giphy|viddler|flowplayer|vidible|bandzoogle|podigee|smugmug|facebook|vid|ultimedia|mixcloud|vidyard|youplay|streamable|captivate|mdstrm)\.\w+\//i,
KNOWN_VIDEO_SOURCES: /(youtube|youtu|youtube\-nocookie|vimeo|dailymotion|theplatform|jwplatform|jwplayer|cnevids|newsinc|podbean|simplecast|libsyn|wistia|podiant|art19|kaltura|mtvnservices|brightcove|bcove|soundcloud|giphy|viddler|flowplayer|vidible|bandzoogle|podigee|smugmug|facebook|vid|ultimedia|mixcloud|vidyard|youplay|streamable|captivate|mdstrm|mediadelivery)\.\w+\//i,

OEMBED_RELS_PRIORITY: ["app", "player", "survey", "image", "reader"],
OEMBED_RELS_MEDIA_PRIORITY: ["player", "survey", "image", "reader", "app"],
Expand Down
5 changes: 4 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,10 @@
var query = !options.getProviderOptions('app.disable_url_options', false)
? {...requestOptions, ...urlOptions}
: {...requestOptions}
delete query.autoplay;

if (query.autoplay && !query.mute && !query.muted) {
delete query.autoplay;
}
return query;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/system/oembed/providers.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
{
"name": "Giphy",
"templates": [
"giphy\\.com/gifs/[a-zA-Z0-9_-]+\\-([a-zA-Z0-9]+)(?:\\?.+)?"
"giphy\\.com/(?:gifs|stickers)/[a-zA-Z0-9_-]+\\-([a-zA-Z0-9]+)(?:\\?.+)?"
],
"url": "https://media.giphy.com/media/{1}/giphy.gif",
"endpoint": "https://giphy.com/services/oembed"
Expand Down Expand Up @@ -192,7 +192,7 @@
{
"name": "SlideShare",
"templates": [
"\\w+\\.slideshare\\.net/.+/.*"
"\\w+\\.slideshare\\.net/(?!slideshow).+/.*"
],
"endpoint": "https://www.slideshare.net/api/oembed/2"
},
Expand Down
8 changes: 1 addition & 7 deletions modules/tests-ui/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
import mongoose from 'mongoose';
import CONFIG from '../../config.loader.js';

mongoose.set('strictQuery', false);

if (global.Promise) {
mongoose.Promise = global.Promise;
}

const db = mongoose.createConnection(CONFIG.tests.mongodb);

var Schema = mongoose.Schema;
Expand Down Expand Up @@ -38,7 +32,7 @@

TestingProgressSchema.methods.getPercent = function() {

if (this.total_plugins_count == this.total_plugins_count) {
if (this.tested_plugins_count === this.total_plugins_count) {
return 100;
} else if (this.total_plugins_count && this.total_plugins_count > 0) {
var p = this.tested_plugins_count / this.total_plugins_count;
Expand Down
115 changes: 83 additions & 32 deletions modules/tests-ui/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ process.on('uncaughtException', function(err) {

console.log("uncaughtException", err.stack);

TestingProgress.update({
TestingProgress.updateOne({
_id: 1
}, {
$set: {
Expand All @@ -37,7 +37,8 @@ process.on('uncaughtException', function(err) {
}
}, {
upsert: false
}, function(){
})
.finally(() => {
process.abort();
});
});
Expand All @@ -60,33 +61,47 @@ function cerror() {
}

function updateObsoletePluginTests(providersIds, cb) {
PluginTest.update({
PluginTest.updateMany({
_id: {
$nin: providersIds
},
obsolete: false
}, {$set: {obsolete: true}}, {multi: true}, cb);
}, {$set: {obsolete: true}}, {multi: true})
.then(data => {
cb(null, data);
})
.catch(cb);
}

function updateActualPluginTests(providersIds, cb) {
PluginTest.update({
PluginTest.updateMany({
_id: {
$in: providersIds
},
obsolete: true
}, {$set: {obsolete: false}}, {multi: true}, cb);
}, {$set: {obsolete: false}}, {multi: true})
.then(data => {
cb(null, data);
})
.catch(cb);
}

function createNewPluginTests(providersIds, cb) {

async.waterfall([

function findExistingProviders(cb) {
PluginTest.find({
PluginTest
.find({
_id: {
$in: providersIds
}
}).distinct('_id', cb);
})
.distinct('_id')
.then(data => {
cb(null, data);
})
.catch(cb);
},

function(ids, cb) {
Expand All @@ -95,13 +110,17 @@ function createNewPluginTests(providersIds, cb) {

async.eachSeries(newIds, function(id, cb) {

PluginTest.update({_id: id}, {
PluginTest.updateOne({_id: id}, {
$set: {
obsolete: false
}
}, {
upsert: true
}, cb)
})
.then(data => {
cb(null, data);
})
.catch(cb);

}, cb);
}
Expand All @@ -121,7 +140,7 @@ function checkPageTestLogChangeNotification(logEntry) {
})
.sort({created_at: -1})
.limit(1)
.exec(function(error, previousLogEntry) {
.exec().then(previousLogEntry => {

previousLogEntry = previousLogEntry && previousLogEntry.length && previousLogEntry[0];

Expand Down Expand Up @@ -211,15 +230,19 @@ function processPluginTests(pluginTest, plugin, count, cb) {

function markStart(cb) {
pluginTest.last_test_started_at = new Date();
pluginTest.save(cb);
pluginTest.save()
.then(data => {
cb(null, data);
})
.catch(cb);
},

function fixProgress(a, cb) {
if (testOnePlugin) {
cb(null, a);
} else {

TestingProgress.update({
TestingProgress.updateOne({
_id: 1
}, {
$set: {
Expand All @@ -229,7 +252,11 @@ function processPluginTests(pluginTest, plugin, count, cb) {
}
}, {
upsert: false
}, cb);
})
.then(data => {
cb(null, data);
})
.catch(cb);
}
},

Expand Down Expand Up @@ -327,7 +354,11 @@ function processPluginTests(pluginTest, plugin, count, cb) {
urls: urls
});
testUrlsSet.errors_list = errors.length ? errors : undefined;
testUrlsSet.save(cb);
testUrlsSet.save()
.then(data => {
cb(null, data);
})
.catch(cb);
},

function(testUrlsSet, cb) {
Expand Down Expand Up @@ -462,12 +493,7 @@ function processPluginTests(pluginTest, plugin, count, cb) {
}
}

logEntry.save(function(error) {

if (error) {
console.log('error', error)
return cb(error);
}
logEntry.save().then(() => {

checkPageTestLogChangeNotification(logEntry);

Expand Down Expand Up @@ -497,6 +523,9 @@ function processPluginTests(pluginTest, plugin, count, cb) {
cb();
}

}).catch(error => {
console.log('error', error)
cb(error);
});
}

Expand All @@ -520,12 +549,16 @@ function processPluginTests(pluginTest, plugin, count, cb) {
},

function removeOldSets(cb) {
TestUrlsSet.remove({
TestUrlsSet.deleteMany({
_id: {
$ne: testUrlsSet._id
},
plugin: plugin.id
}, cb);
})
.then(data => {
cb(null, data);
})
.catch(cb);
}

], cb);
Expand Down Expand Up @@ -569,15 +602,23 @@ function testAll(cb) {
function loadPluginTests(data, cb) {

if (testOnePlugin) {
PluginTest.find({_id: testOnePlugin}, cb);
PluginTest.find({_id: testOnePlugin})
.then(data => {
cb(null, data);
})
.catch(cb);
} else {

async.waterfall([

function loadPluginTests(cb) {
PluginTest.find({
obsolete: false
}, {}, {}, cb);
})
.then(data => {
cb(null, data);
})
.catch(cb);
},

function filterAndSort(pluginTests, cb) {
Expand Down Expand Up @@ -625,7 +666,7 @@ function testAll(cb) {
if (testOnePlugin || pluginTests.length == 0) {
cb(null, pluginTests)
} else {
TestingProgress.update({
TestingProgress.updateOne({
_id: 1
}, {
$set: {
Expand All @@ -641,9 +682,11 @@ function testAll(cb) {
}
}, {
upsert: true
}, function(error) {
cb(error, pluginTests);
});
})
.then(() => {
cb(null, pluginTests);
})
.catch(cb);
}
},

Expand All @@ -663,7 +706,11 @@ function testAll(cb) {
} else {
pluginTest.error = undefined;
}
pluginTest.save(cb);
pluginTest.save()
.then(data => {
cb(null, data);
})
.catch(cb);
});

}, cb);
Expand All @@ -675,7 +722,7 @@ function testAll(cb) {
} else {
console.log('finish');

TestingProgress.update({
TestingProgress.updateOne({
_id: 1
}, {
$set: {
Expand All @@ -689,7 +736,11 @@ function testAll(cb) {
}
}, {
upsert: false
}, cb);
})
.then(data => {
cb(null, data);
})
.catch(cb);
}
}

Expand Down
Loading

0 comments on commit 3df2fd6

Please sign in to comment.