Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'

Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ jobs:
OS_TAG: "osx"
steps:
- name: 'Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install dependencies
Expand Down Expand Up @@ -115,15 +115,15 @@ jobs:
OS_TAG: "osx"
steps:
- name: 'Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
shell: bash
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install dependencies
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
package-and-deploy-macos:
name: 'Package and Deploy macOS'
needs: run-tests-macos
if: ${{ needs.run-tests-macos.result == 'success' }}
if: ${{ needs.run-tests-macos.result == 'success' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ${{ matrix.image }}
strategy:
matrix:
Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
OS_TAG: "osx"
steps:
- name: 'Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download build artifacts
Expand Down Expand Up @@ -252,10 +252,8 @@ jobs:
env:
OS_TAG: "win64"
steps:
- name: 'Add msbuild to PATH'
uses: microsoft/setup-msbuild@v1
- name: 'Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Get the version
Expand All @@ -266,7 +264,7 @@ jobs:
shell: pwsh
- name: Install dependencies
run: |
yarn install --immutable --immutable-cache --check-cache
yarn install
yarn add electron@${{env.ElectronVersion}} -D
- name: Configure obs-studio-node
run: ./ci/configure-osn.cmd
Expand Down Expand Up @@ -301,7 +299,7 @@ jobs:
OS_TAG: "win64"
steps:
- name: 'Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download build artifacts
Expand All @@ -317,7 +315,7 @@ jobs:
shell: pwsh
- name: Install dependencies
run: |
yarn install --immutable --immutable-cache --check-cache
yarn install
yarn add electron@${{env.ElectronVersion}} -D
- name: 'Run tests'
timeout-minutes: 20
Expand All @@ -333,7 +331,7 @@ jobs:
package-and-deploy-win64:
name: 'Package and Deploy Windows'
needs: run-tests-win64
if: ${{ needs.run-tests-win64.result == 'success' }}
if: ${{ needs.run-tests-win64.result == 'success' && startsWith(github.ref, 'refs/tags/') }}
runs-on: windows-2022
env:
OS_TAG: "win64"
Expand Down Expand Up @@ -376,7 +374,7 @@ jobs:
OS_TAG: "win64"
steps:
- name: 'Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2
repository: stream-labs/symsrv-scripts
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ build/
logs/
node_modules/
distribute/
yarn-error.log
yarn.lock
yarn-error.log
.yarn/
test-results.xml

# Binaries
Expand Down
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,30 @@
"local:config": "yarn install && git submodule update --init --recursive --force && cmake -Bbuild -H. -G\"Visual Studio 16 2019\" -A\"x64\" -DCMAKE_INSTALL_PREFIX=\"./obs-studio-node\" -DLIBOBS_BUILD_TYPE=\"debug\" -DCMAKE_PREFIX_PATH=%CD%/build/libobs-src/cmake/",
"local:build": "cmake --build build --target install --config Debug",
"local:clean": "rm -rf build/*",
"test": "electron-mocha -t 80000 --js-flags=\"--expose-gc\" -c true -r ts-node/register tests/osn-tests/src/**/*.ts --reporter tests/osn-tests/util/list-reporter.js"
"test": "electron-mocha -t 80000 --js-flags=\"--expose-gc\" --color -r ts-node/register tests/osn-tests/src/**/*.ts --reporter tests/osn-tests/util/list-reporter.js"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.0.0",
"@aws-sdk/lib-storage": "^3.0.0",
"@types/chai": "^4.1.7",
"@types/chai-subset": "^1.3.5",
"@types/mocha": "^5.2.5",
"@types/node": "^16.7.13",
"archiver": "^3.1.1",
"aws-sdk": "^2.1164.0",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"archiver": "^7.0.0",
"chai": "^4.2.0",
"chai-subset": "^1.6.0",
"colors": "^1.4.0",
"electron": "29.4.3",
"electron-mocha": "^12.1.0",
"get-func-name": "^3.0.0",
"mocha": "^7.1.0",
"mocha": "^11.0.0",
"mocha-junit-reporter": "^1.22.0",
"node-addon-api": "^7.1.1",
"request": "^2.88.0",
"ts-node": "^7.0.1",
"typedoc": "^0.16.11",
"typedoc-default-themes": "^0.5.0",
"typedoc-plugin-markdown": "^2.2.17",
"typescript": "^4.0.7",
"uuid": "^3.0.1",
"typedoc": "^0.28.0",
"typedoc-plugin-markdown": "^4.0.0",
"typescript": "^5.0.0",
"uuid": "^9.0.0",
"wait-queue": "^1.1.4"
},
"keywords": [
Expand Down
1 change: 1 addition & 0 deletions tests/osn-tests/src/test_osn_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ describe(testName, () => {

it('Set enabled and get it for all filter types', () => {
obs.filterTypes.forEach(function(filterType) {
logInfo(testName, 'Testing filter type: ' + filterType);
// Creating filter
const filter = osn.FilterFactory.create(filterType, 'filter');

Expand Down
39 changes: 21 additions & 18 deletions tests/osn-tests/util/cache-uploader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as aws from 'aws-sdk';
import { S3Client } from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
import * as archiver from 'archiver';
import { logInfo } from '../util/logger';

Expand Down Expand Up @@ -28,38 +29,40 @@ export class CacheUploader {
const archive = archiver('zip', { zlib: { level: 9 } });

if (!("OSN_ACCESS_KEY_ID" in process.env)) {
reject('Failed to upload cache. The environment variable OSN_ACCESS_KEY_ID does not exist');
return reject('Failed to upload cache. The environment variable OSN_ACCESS_KEY_ID does not exist');
}

if (!("OSN_SECRET_ACCESS_KEY" in process.env)) {
reject('Failed to upload cache. The environment variable OSN_SECRET_ACCESS_KEY does not exist');
return reject('Failed to upload cache. The environment variable OSN_SECRET_ACCESS_KEY does not exist');
}

output.on('close', () => {
const file = fs.createReadStream(cacheFile);
const keyname = this.dateStr + '-' + this.testName + '-test-cache-' + this.releaseName + '.zip';

aws.config.region = 'us-west-2';

// This is a restricted cache upload account
aws.config.credentials = new aws.Credentials({
accessKeyId: process.env.OSN_ACCESS_KEY_ID,
secretAccessKey: process.env.OSN_SECRET_ACCESS_KEY,
const s3 = new S3Client({
region: 'us-east-2',
credentials: {
accessKeyId: process.env.OSN_ACCESS_KEY_ID,
secretAccessKey: process.env.OSN_SECRET_ACCESS_KEY,
},
});

const upload = new aws.S3.ManagedUpload({
params: {
Bucket: 'obs-studio-node-tests-cache',
Key: keyname,
Body: file,
},

const upload = new Upload({
client: s3,
params: {
Bucket: 'obs-studio-node-tests-cache',
Key: keyname,
Body: file,
},
});
upload.promise().then(() => {

upload.done().then(() => {
logInfo(this.testName, 'Finished uploading cache');
logInfo(this.testName, keyname);
resolve(keyname);
});
}).catch((err) => reject(err));
});

// Modify the stream key in service.json in a reversible way when uploading user caches
Expand Down
14 changes: 7 additions & 7 deletions tests/osn-tests/util/error_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,16 @@ export const enum ETestErrorMsg {
}

export function GetErrorMessage(message: string, value1?: string, value2?: string, value3?: string): string {
let replacements: any;
let replacements: Record<string, string>;

if (typeof value1 != 'undefined' &&
typeof value2 != 'undefined' &&
typeof value3 != 'undefined') {
if (typeof value1 !== 'undefined' &&
typeof value2 !== 'undefined' &&
typeof value3 !== 'undefined') {
replacements = {"%VALUE1%": value1, "%VALUE2%": value2, "%VALUE3%": value3}
} else if (typeof value1 != 'undefined' &&
typeof value2 != 'undefined') {
} else if (typeof value1 !== 'undefined' &&
typeof value2 !== 'undefined') {
replacements = {"%VALUE1%": value1, "%VALUE2%": value2}
} else if (typeof value1 != 'undefined') {
} else if (typeof value1 !== 'undefined') {
replacements = {"%VALUE1%": value1}
} else {
return message;
Expand Down
4 changes: 2 additions & 2 deletions tests/osn-tests/util/general.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as fs from 'fs';
import * as path from 'path';
import { ITimeSpec } from '../osn';

// OBS types
Expand Down Expand Up @@ -73,8 +75,6 @@ export function getCppErrorMsg(errorStack: any): string {
}

export function deleteConfigFiles(): void {
const fs = require('fs');
const path = require('path');
const configFolderPath = path.join(path.normalize(__dirname), '..', 'osnData/slobs-client');
if (fs.existsSync(configFolderPath)) {
let currentFile: string;
Expand Down
22 changes: 11 additions & 11 deletions tests/osn-tests/util/obs_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logInfo, logWarning } from '../util/logger';
import { UserPoolHandler } from './user_pool_handler';
import { CacheUploader } from '../util/cache-uploader'
import { EOBSOutputType, EOBSOutputSignal, EOBSSettingsCategories } from '../util/obs_enums'
import { v4 as uuidv4 } from 'uuid';
const WaitQueue = require('wait-queue');

// Interfaces
Expand Down Expand Up @@ -61,13 +62,12 @@ export type TConfigEvent = 'starting_step' | 'progress' | 'stopping_step' | 'err
// OBSHandler class
export class OBSHandler {
private path = require('path');
private uuid = require('uuid/v4');

// Variables for obs initialization
private workingDirectory: string = this.path.normalize(osn.wd);
private language: string = 'en-US';
private obsPath: string = this.path.join(this.path.normalize(__dirname), '..', 'osnData/slobs-client');
private pipeName: string = 'osn-tests-pipe-'.concat(this.uuid());
private pipeName: string = 'osn-tests-pipe-'.concat(uuidv4());
private version: string = '0.00.00-preview.0';
private crashServer: string = '';

Expand Down Expand Up @@ -106,13 +106,13 @@ export class OBSHandler {
}

startup() {
let initResult: any;
let initResult: number;
logInfo(this.osnTestName, 'Initializing OBS');

try {
const exitCode = osn.NodeObs.IPC.host(this.pipeName);
if (exitCode != osn.EVideoCodes.Success) {
if (exitCode == osn.EIPCError.OTHER_ERROR) {
if (exitCode !== osn.EVideoCodes.Success) {
if (exitCode === osn.EIPCError.OTHER_ERROR) {
throw Error('OBS IPC host failed: missing executable or some other error.');
}
throw Error(`OBS IPC host failed with code ${exitCode}. See osn.EIPCError for more details.`);
Expand All @@ -123,7 +123,7 @@ export class OBSHandler {
throw Error('Exception when initializing OBS process: ' + e);
}

if (initResult != osn.EVideoCodes.Success) {
if (initResult !== osn.EVideoCodes.Success) {
throw Error('OBS process initialization failed with code ' + initResult);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ export class OBSHandler {
this.setStreamKey(this.userStreamKey);

let savedStreamKey = this.getStreamKey();
if (savedStreamKey == this.userStreamKey) {
if (savedStreamKey === this.userStreamKey) {
logInfo(this.osnTestName, 'Stream key saved successfully');
} else {
throw Error('Failed to save stream key');
Expand Down Expand Up @@ -219,7 +219,7 @@ export class OBSHandler {
});

// Saving updated settings container
if (value != oldValue) {
if (value !== oldValue) {
osn.NodeObs.OBS_settings_saveSettings(category, settings);
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ export class OBSHandler {

startAutoconfig() {
osn.NodeObs.InitializeAutoConfig((progressInfo: IConfigProgress) => {
if (progressInfo.event == 'stopping_step' || progressInfo.event == 'done' || progressInfo.event == 'error') {
if (progressInfo.event === 'stopping_step' || progressInfo.event === 'done' || progressInfo.event === 'error') {
this.progress.push(progressInfo);
}
},
Expand Down Expand Up @@ -330,11 +330,11 @@ export class OBSHandler {
}

setSourceMessageListener() {
osn.NodeObs.RegisterSourceCallback((message: any) => {
osn.NodeObs.RegisterSourceCallback((message: unknown) => {
console.log('Source callback received' + JSON.stringify(message));
});

osn.NodeObs.RegisterSourceMessageCallback((message: any) => {
osn.NodeObs.RegisterSourceMessageCallback((message: unknown) => {
console.log('Source message callback received' + JSON.stringify(message));
});
}
Expand Down
Loading
Loading