From 88ed415d3ad8371b2a43d58c00a670c429359d77 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Wed, 4 Sep 2019 00:24:12 +0200 Subject: [PATCH] ci: Integrate Github Actions Integrates Github Actions which is much much faster than AppVeyor in all areas, and even supports multiple workflows instead of forcing everything into just one workflow like AppVeyor does. Plus we get 20 parallel builds that nearly instantly finish, which results in much faster feedback without having to run our own Jenkins CI. The builder and packager scripts have been adjusted to add support for both Windows and Linux, and both AppVeyor and Github Actions. Additionally to that, the builder script now correctly executes x32 and x64 steps in a chain, instead of waiting for the other architecture to finish first. This further reduces build times. --- .github/workflows/main.yml | 34 ++++++++ appveyor.yml | 6 ++ ci/builder.js | 162 +++++++++++++++++-------------------- ci/packager.js | 63 +++++++++++++++ ci/runner.js | 1 - 5 files changed, 177 insertions(+), 89 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 ci/packager.js diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..438da76 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,34 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + os: [windows-2016, windows-2019] + include: + - os: windows-2016 + generator_32: "Visual Studio 15 2017" + generator_64: "Visual Studio 15 2017 Win64" + sysversion: "10.0.17763.0" + - os: windows-2019 + generator_32: + generator_64: "Visual Studio 16 2019" + sysversion: "10.0.18362.0" + runs-on: ${{ matrix.os }} + steps: + - name: Clone Repository + uses: actions/checkout@v1 + - name: Update Submodules + run: git submodule update --init --force --recursive + - name: Install Node.JS 10.x + uses: actions/setup-node@v1 + with: + node-version: 10 + - name: Build + env: + CMAKE_GENERATOR_32: ${{ matrix.generator_32 }} + CMAKE_GENERATOR_64: ${{ matrix.generator_64 }} + CMAKE_SYSTEM_VERSION: ${{ matrix.sysversion }} + run: node ./ci/builder.js diff --git a/appveyor.yml b/appveyor.yml index d301453..439a9bc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,11 +7,16 @@ matrix: # Build Image & Environment platform: x64 +# Build Tags only +skip_non_tags: true + image: - Visual Studio 2017 environment: CMAKE_SYSTEM_VERSION: 10.0.17134.0 + CMAKE_GENERATOR_32: "Visual Studio 15 2017" + CMAKE_GENERATOR_64: "Visual Studio 15 2017 Win64" PACKAGE_PREFIX: obs-ffmpeg-encoder INNOSETUP_URL: http://www.jrsoftware.org/download.php/is.exe CURL_VERSION: 7.39.0 @@ -32,6 +37,7 @@ build_script: - cmd: node ci/builder.js after_build: +- cmd: node ci/packager.js - cmd: ci/appveyor-package.bat # Testing diff --git a/ci/builder.js b/ci/builder.js index e94cfab..efd93cd 100644 --- a/ci/builder.js +++ b/ci/builder.js @@ -2,108 +2,94 @@ const process = require('process'); const runner = require('./runner.js'); +let env = process.env; -// Steps -let configure_runners = []; -let build_runners = []; -let package_runners = []; +let x32_steps = []; +let x64_steps = []; -{ - let cmake_configure_extra = [ +if ((process.platform == "win32") || (process.platform == "win64")) { + // Windows + let extra_conf = [ `-DCMAKE_SYSTEM_VERSION=${process.env.CMAKE_SYSTEM_VERSION}`, + `-DCMAKE_PACKAGE_NAME=obs-stream-effects`, '-DCMAKE_INSTALL_PREFIX="build/distrib/"', '-DCMAKE_PACKAGE_PREFIX="build/"', - `-DCMAKE_PACKAGE_NAME="${process.env.PACKAGE_PREFIX}"`, ]; - let cmake_build_extra = [ + let extra_build = [ + ]; - // Configuration depends on platform - if (process.platform == "win32" || process.platform == "win64") { - configure_runners.push(new runner('32-bit', 'cmake', [ + if(process.env.APPVEYOR) { + extra_build.concat(['--', '/logger:"C:\\Program Files\\AppVeyor\\BuildAgent\\Appveyor.MSBuildLogger.dll"']); + } + + if ((process.env.CMAKE_GENERATOR_32 !== undefined) && (process.env.CMAKE_GENERATOR_32 !== "")) { + x32_steps.push( + [ 'cmake', [ '-H.', '-Bbuild/32', - `-G"Visual Studio 15 2017"`, - ].concat(cmake_configure_extra))); - configure_runners.push(new runner('64-bit', 'cmake', [ + `-G"${process.env.CMAKE_GENERATOR_32}"`, + ].concat(extra_conf), env ] + ); + x32_steps.push( + [ 'cmake', [ + '--build', 'build/32', + '--config', 'RelWithDebInfo', + '--target', 'INSTALL' + ].concat(extra_build), env ] + ); + } + if ((process.env.CMAKE_GENERATOR_64 !== undefined) && (process.env.CMAKE_GENERATOR_64 !== "")) { + x64_steps.push( + [ 'cmake', [ '-H.', '-Bbuild/64', - `-G"Visual Studio 15 2017 Win64"`, - '-T"host=x64"', - ].concat(cmake_configure_extra))); - - // Extra build steps for AppVeyor on Windows for Logging purposes. - if(process.env.APPVEYOR) { - cmake_build_extra.concat(['--', '/logger:"C:\\Program Files\\AppVeyor\\BuildAgent\\Appveyor.MSBuildLogger.dll"']); - } - } else if (process.platform == "linux") { - configure_runners.push(new runner('32-bit', 'cmake', [ - '-H.', - '-Bbuild32', - `-G"Unix Makefiles"`, - `-DCOPIED_DEPENDENCIES=false`, - ].concat(cmake_configure_extra), - { ...process.env, ...{ - CFLAGS: `${process.env.COMPILER_FLAGS_32}`, - CXXFLAGS: `${process.env.COMPILER_FLAGS_32}`, - }})); - configure_runners.push(new runner('64-bit', 'cmake', [ - '-H.', - '-Bbuild64', - `-G"Unix Makefiles"`, - `-DCOPIED_DEPENDENCIES=false`, - ].concat(cmake_configure_extra), - { ...process.env, ...{ - CFLAGS: `${process.env.COMPILER_FLAGS_64}`, - CXXFLAGS: `${process.env.COMPILER_FLAGS_64}`, - }})); + `-G"${process.env.CMAKE_GENERATOR_64}"`, + '-T"host=x64"' + ].concat(extra_conf), env ] + ); + x64_steps.push( + [ 'cmake', [ + '--build', 'build/64', + '--config', 'RelWithDebInfo', + '--target', 'INSTALL' + ].concat(extra_build), env ] + ); } - - build_runners.push(new runner('32-bit', 'cmake', [ - '--build', 'build/32', - '--config', 'RelWithDebInfo', - '--target', 'INSTALL' - ].concat(cmake_build_extra))); - build_runners.push(new runner('64-bit', 'cmake', [ - '--build', 'build/64', - '--config', 'RelWithDebInfo', - '--target', 'INSTALL' - ].concat(cmake_build_extra))); - package_runners.push(new runner('32-bit', 'cmake', [ - '--build', 'build/32', - '--target', 'PACKAGE_7Z', - '--config', 'RelWithDebInfo' - ].concat(cmake_build_extra))); - package_runners.push(new runner('64-bit', 'cmake', [ - '--build', 'build/64', - '--target', 'PACKAGE_ZIP', - '--config', 'RelWithDebInfo' - ].concat(cmake_build_extra))); +} else { + // Unix + } -// Run Configure steps. -let configure_promises = []; -for (let config of configure_runners) { - configure_promises.push(config.run()); -} -Promise.all(configure_promises).then(function(result) { - let build_promises = []; - for (let build of build_runners) { - build_promises.push(build.run()); - } - Promise.all(build_promises).then(function(result) { - let package_promises = []; - for (let pack of package_runners) { - package_promises.push(pack.run()); +function runRunners(runnerArray, name) { + return new Promise(async (resolve, reject) => { + let local = runnerArray.reverse(); + while (local.length > 0) { + try { + let task = local.pop(); + let work = new runner(name, task[0], task[1], task[2]); + await work.run(); + } catch (e) { + reject(e); + return; + } } - Promise.all(package_promises).then(function(result) { - process.exit(result); - }).catch(function(result) { - process.exit(result); - }); - }).catch(function(result) { - process.exit(result); + resolve(0); }); -}).catch(function(result) { - process.exit(result); -}); +} + +let promises = []; +promises.push(runRunners(x32_steps, "32-Bit")); +promises.push(runRunners(x64_steps, "64-Bit")); +Promise.all(promises).then( + res => { + process.exit(0); + }, + err => { + console.log(err); + process.exit(1); + } +).catch(err => { + console.log(err); + process.exit(1); +}) diff --git a/ci/packager.js b/ci/packager.js new file mode 100644 index 0000000..efb2ae8 --- /dev/null +++ b/ci/packager.js @@ -0,0 +1,63 @@ +"use strict"; + +const process = require('process'); +const runner = require('./runner.js'); + +function runRunners(runnerArray, name) { + return new Promise(async (resolve, reject) => { + let local = runnerArray.reverse(); + while (local.length > 0) { + let task = local.pop(); + let work = new runner(name, task[0], task[1], task[2]); + await work.run(); + } + resolve(0); + }); +} + +let env = process.env; +let steps = []; + +if ((process.env.CMAKE_GENERATOR_64 !== undefined) && (process.env.CMAKE_GENERATOR_64 !== "")) { + steps.push( + [ 'cmake', [ + '--build', 'build/64', + '--config', 'RelWithDebInfo', + '--target', 'PACKAGE_7Z' + ], env ] + ); + steps.push( + [ 'cmake', [ + '--build', 'build/64', + '--config', 'RelWithDebInfo', + '--target', 'PACKAGE_ZIP' + ], env ] + ); +} else if ((process.env.CMAKE_GENERATOR_32 !== undefined) && (process.env.CMAKE_GENERATOR_32 !== "")) { + steps.push( + [ 'cmake', [ + '--build', 'build/32', + '--config', 'RelWithDebInfo', + '--target', 'PACKAGE_7Z' + ], env ] + ); + steps.push( + [ 'cmake', [ + '--build', 'build/32', + '--config', 'RelWithDebInfo', + '--target', 'PACKAGE_ZIP' + ], env ] + ); +} + +let promises = []; +promises.push(runRunners(steps, "32-Bit")); +Promise.all(promises).then( + res => { + process.exit(0); + }, + err => { + console.log(err); + process.exit(1); + } +) diff --git a/ci/runner.js b/ci/runner.js index 744002f..66bccf4 100644 --- a/ci/runner.js +++ b/ci/runner.js @@ -18,7 +18,6 @@ class Runner { run() { let self = this; return new Promise(function(resolve, reject) { - console.log(self.cmd, self.args); self.proc = cp.spawn( self.cmd, self.args, { windowsVerbatimArguments: true, -- 2.52.0