From 73281006b183cfffba7edfa34e822ad574cca3e6 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 19 Nov 2021 14:26:43 -0300 Subject: [PATCH 1/3] Jenkins: Add new method of extracting the current HEAD commit --- .ci/Jenkinsfile | 60 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 28ef5e005..0d6d1e987 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -120,19 +120,39 @@ pipeline { steps { script { - /* Run a dummy git clone on any node to try and save the latest commit regardless of executor status. - This avoids a timing issue where HEAD changes between polling and the nodes being available below. - I talked to a few people, and we reached the conclusion that reading the polled commit from within - the pipeline is not really possible (maybe short of switching to a multi-branch pipeline), so we - have to live with this hack, which shortens but doesn't fully eliminate the timing issue's window. */ - node { - /* Ignore exceptions as this is not really critical. */ - try { - gitClone() - } catch (e) {} - try { - cleanWs() - } catch (e) {} + /* Cursed hack to extract the current HEAD commit from this build's + git polling log. This avoids a timing issue where HEAD changes + between polling and the nodes being available below. */ + if (env.GIT_COMMIT == null) { + /* This must run on the master node to read the polling log. */ + node('master') { + /* Ignore exceptions as this is not really critical. */ + try { + /* Switch to this build's directory. */ + dir("${env.JENKINS_HOME}/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}") { + /* Parse polling log. */ + def pollingLog = readFile file: 'polling.log' + def match = pollingLog =~ /Latest remote head revision on [^ ]+ is: ([a-zA-Z0-9]+)/ + if (match && match[0]) { + env.GIT_COMMIT = match[0][1] + println "[-] Read git tag [${env.GIT_COMMIT}] from polling log" + } + } + } catch (e) {} + } + + /* If the polling log parsing fails, run a dummy git clone on any node. */ + if (env.GIT_COMMIT == null) { + node { + /* Ignore exceptions again as this is not really critical. */ + try { + gitClone() + } catch (e) {} + try { + cleanWs() + } catch (e) {} + } + } } /* Create source tarball. */ @@ -187,14 +207,10 @@ pipeline { removeDir('output') /* Switch to output directory. */ - dir('output') { + dir("output/${dynarecNames[dynarec]}/$os - ${archNames[arch]}") { + /* Run build process. */ def packageName = "${env.JOB_BASE_NAME}${dynarecSlugs[dynarec]}${presetSlugs[preset]}-$os-$arch-b${env.BUILD_NUMBER}" - dir(dynarecNames[dynarec]) { - dir("$os - ${archNames[arch]}") { - /* Run build process. */ - runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"") - } - } + runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"") /* Archive resulting artifacts. */ archiveArtifacts artifacts: "**/**/$packageName*" @@ -223,12 +239,14 @@ pipeline { post { always { script { + /* Mark build as failed if any step has failed. */ if (anyFailure) { println "[!] Failing build because a build stage failed" currentBuild.result = 'FAILURE' } - if (!env.JOB_BASE_NAME.contains("TestBuildPleaseIgnore")) { + /* Send out build notifications. */ + if (!env.JOB_BASE_NAME.contains('TestBuildPleaseIgnore')) { try { /* Notify Discord. */ def result = currentBuild.currentResult.toLowerCase() From d97e63cca257eb197f01ebe6ab17cd082ef5c83d Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 19 Nov 2021 15:14:41 -0300 Subject: [PATCH 2/3] Jenkins: Read polling log to better avoid "no changes" --- .ci/Jenkinsfile | 52 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 0d6d1e987..1ab455a26 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -78,13 +78,26 @@ def presetFlags = [ def anyFailure = false def gitClone() { + /* Read git tag from environment or set the default one. */ if (env.GIT_COMMIT == null) env.GIT_COMMIT = 'master' println "[-] Using git tag [${env.GIT_COMMIT}]" - def scmVars = checkout scm: [$class: 'GitSCM', - branches: [[name: env.GIT_COMMIT]], - userRemoteConfigs: [[url: 'https://github.com/86Box/86Box.git']]] - env.GIT_COMMIT = scmVars.GIT_COMMIT + + /* Use stashes to avoid performing multiple clones. */ + if (env.GIT_STASHED != 'true') { + /* Perform clone/checkout. */ + def scmVars = checkout scm: [$class: 'GitSCM', + branches: [[name: env.GIT_COMMIT]], + userRemoteConfigs: [[url: 'https://github.com/86Box/86Box.git']]] + env.GIT_COMMIT = scmVars.GIT_COMMIT + + /* Stash data and mark it as stashed. */ + stash name: 'git' + env.GIT_STASHED = 'true' + } else { + /* Unstash data. */ + unstash name: 'git' + } } def removeDir(dir) { @@ -98,31 +111,37 @@ def runBuild(args) { if (isUnix()) sh "chmod u+x \"$WORKSPACE/.ci/build.sh\" && exec \"$WORKSPACE/.ci/build.sh\" $args" else - bat "C:\\msys64\\msys2_shell.cmd -msys2 -defterm -here -no-start -c 'exec \"\$(cygpath -u \\'%WORKSPACE%\\')\"/.ci/build.sh $args'" + bat "C:\\msys64\\msys2_shell.cmd -msys2 -defterm -here -no-start -c 'exec \"\$(cygpath -u \\'%WORKSPACE%\\')/.ci/build.sh\" $args'" } pipeline { agent none + environment { + DISCORD_WEBHOOK_URL = credentials('discord-webhook-url') + } + + options { + disableConcurrentBuilds() + quietPeriod(0) + } + parameters { string(name: 'BUILD_TYPE', defaultValue: 'beta', /* !!! CHANGE HERE !!! for build type */ description: "Build type to pass on to CMake. Don't change this, you should instead change the default value on .ci/Jenkinsfile") } - environment { - DISCORD_WEBHOOK_URL = credentials('discord-webhook-url') - } - stages { stage('Source Tarball') { agent none steps { script { - /* Cursed hack to extract the current HEAD commit from this build's - git polling log. This avoids a timing issue where HEAD changes - between polling and the nodes being available below. */ + /* Hack to extract the current HEAD commit from this build's git polling + log. This avoids a race condition where HEAD changes in the time period + between Jenkins polling the git repository and the first build node + performing the first git clone once ready. (See issue JENKINS-20518) */ if (env.GIT_COMMIT == null) { /* This must run on the master node to read the polling log. */ node('master') { @@ -141,7 +160,8 @@ pipeline { } catch (e) {} } - /* If the polling log parsing fails, run a dummy git clone on any node. */ + /* If the polling log parsing fails, perform a dummy git clone on any node. + Not quite as fast as reading the polling log, but it works as a backup. */ if (env.GIT_COMMIT == null) { node { /* Ignore exceptions again as this is not really critical. */ @@ -207,10 +227,12 @@ pipeline { removeDir('output') /* Switch to output directory. */ - dir("output/${dynarecNames[dynarec]}/$os - ${archNames[arch]}") { + dir('output') { /* Run build process. */ def packageName = "${env.JOB_BASE_NAME}${dynarecSlugs[dynarec]}${presetSlugs[preset]}-$os-$arch-b${env.BUILD_NUMBER}" - runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"") + dir("${dynarecNames[dynarec]}/$os - ${archNames[arch]}") { + runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"") + } /* Archive resulting artifacts. */ archiveArtifacts artifacts: "**/**/$packageName*" From f32deff7f6634ed1bd37fbda4fff9fcc34c4106b Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 19 Nov 2021 15:56:21 -0300 Subject: [PATCH 3/3] snd_ac97_codec: Fix fatal and crash caused by AMR card spill-over --- src/sound/snd_ac97_codec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sound/snd_ac97_codec.c b/src/sound/snd_ac97_codec.c index b992b0e6a..ac19cdd7b 100644 --- a/src/sound/snd_ac97_codec.c +++ b/src/sound/snd_ac97_codec.c @@ -542,7 +542,7 @@ ac97_codec_init(const device_t *info) /* Associate this codec to the current controller. */ if (!ac97_codec || (ac97_codec_count <= 0)) { - fatal("AC97 Codec %d: No controller to associate codec\n", ac97_codec_id); + pclog("AC97 Codec %d: No controller to associate codec\n", ac97_codec_id); return NULL; } *ac97_codec = dev; @@ -583,6 +583,8 @@ static void ac97_codec_close(void *priv) { ac97_codec_t *dev = (ac97_codec_t *) priv; + if (!dev) + return; ac97_codec_log("AC97 Codec %d: close()\n", dev->codec_id);