ソースを参照

handle old versions of latexmk in run count extraction (#30597)

* handle old versions of latexmk in run count extraction

the log lines for the run number change from stderr to stdout in TL2022

* extend SimpleLatexFileTest to include TL2017

* reset metrics for each scenario in SimpleLatexFileTests

* fix buildscript merge conflict

GitOrigin-RevId: fb74f2025d21ddf43be6a3b90ac6f7df4d975db6
Brian Gough 4 ヶ月 前
コミット
9f1e4d99e5

+ 3 - 1
services/clsi/app/js/LatexRunner.js

@@ -87,7 +87,9 @@ function runLatex(projectId, options, callback) {
       }
       // number of latex runs and whether there were errors
       const runs =
-        output?.stdout?.match(/^Run number \d+ of .*latex/gm)?.length || 0
+        output?.stdout?.match(/^Run number \d+ of .*latex/gm)?.length || // TeXLive 2022 and later
+        output?.stderr?.match(/^Run number \d+ of .*latex/gm)?.length || // TeXLive 2021 and earlier
+        0
       const failed = output?.stdout?.match(/^Latexmk: Errors/m) != null ? 1 : 0
       // counters from latexmk output
       stats['latexmk-errors'] = failed

+ 1 - 1
services/clsi/buildscript.txt

@@ -1,7 +1,7 @@
 clsi
 --data-dirs=cache,compiles,output
 --dependencies=
---env-add=DOWNLOAD_HOST=http://clsi-nginx:8080,ALLOWED_COMPILE_GROUPS="clsi-perf simple-latex-file",ENABLE_PDF_CACHING="true",PDF_CACHING_ENABLE_WORKER_POOL="true",ALLOWED_IMAGES=quay.io/sharelatex/texlive-full:2025.1,TEXLIVE_IMAGE=quay.io/sharelatex/texlive-full:2025.1,TEX_LIVE_IMAGE_NAME_OVERRIDE=us-east1-docker.pkg.dev/overleaf-ops/ol-docker,TEXLIVE_IMAGE_USER="tex",SANDBOXED_COMPILES="true",SANDBOXED_COMPILES_HOST_DIR_COMPILES=$PWD/compiles,SANDBOXED_COMPILES_HOST_DIR_OUTPUT=$PWD/output
+--env-add=DOWNLOAD_HOST=http://clsi-nginx:8080,ALLOWED_COMPILE_GROUPS="clsi-perf simple-latex-file",ENABLE_PDF_CACHING="true",PDF_CACHING_ENABLE_WORKER_POOL="true",ALLOWED_IMAGES="quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1",TEXLIVE_IMAGE=quay.io/sharelatex/texlive-full:2025.1,TEX_LIVE_IMAGE_NAME_OVERRIDE=us-east1-docker.pkg.dev/overleaf-ops/ol-docker,TEXLIVE_IMAGE_USER="tex",SANDBOXED_COMPILES="true",SANDBOXED_COMPILES_HOST_DIR_COMPILES=$PWD/compiles,SANDBOXED_COMPILES_HOST_DIR_OUTPUT=$PWD/output
 --env-pass-through=
 --esmock-loader=False
 --node-version=24.13.0

+ 1 - 1
services/clsi/docker-compose.ci.yml

@@ -31,7 +31,7 @@ services:
       ALLOWED_COMPILE_GROUPS: "clsi-perf simple-latex-file"
       ENABLE_PDF_CACHING: "true"
       PDF_CACHING_ENABLE_WORKER_POOL: "true"
-      ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2025.1
+      ALLOWED_IMAGES: "quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1"
       TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
       TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
       TEXLIVE_IMAGE_USER: "tex"

+ 1 - 1
services/clsi/docker-compose.yml

@@ -45,7 +45,7 @@ services:
       ALLOWED_COMPILE_GROUPS: "clsi-perf simple-latex-file"
       ENABLE_PDF_CACHING: "true"
       PDF_CACHING_ENABLE_WORKER_POOL: "true"
-      ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2025.1
+      ALLOWED_IMAGES: "quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1"
       TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
       TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
       TEXLIVE_IMAGE_USER: "tex"

+ 28 - 2
services/clsi/test/acceptance/js/SimpleLatexFileTests.js

@@ -3,6 +3,7 @@ import { fetchNothing, fetchString } from '@overleaf/fetch-utils'
 import ClsiApp from './helpers/ClsiApp.js'
 import { expect } from 'chai'
 import Settings from '@overleaf/settings'
+import Metrics from '@overleaf/metrics'
 
 describe('Simple LaTeX file', function () {
   const content = `\
@@ -21,6 +22,18 @@ Hello world
         },
       },
     },
+    {
+      description: 'simple file (TL2017)',
+      request: {
+        resources: [{ path: 'main.tex', content }],
+        options: {
+          compileGroup: 'simple-latex-file',
+          imageName: 'quay.io/sharelatex/texlive-full:2017.1',
+        },
+      },
+      // In TL2017 latexmk performs an extra LaTeX pass even for this simple document.
+      expectedRuns: 2,
+    },
     {
       description: 'clsi-perf request',
       request: {
@@ -49,6 +62,13 @@ Hello world
         }
       })
 
+      after(function () {
+        // Clear all metrics after each scenario
+        if (Metrics.prom && Metrics.prom.register) {
+          Metrics.prom.register.resetMetrics()
+        }
+      })
+
       it('should return the PDF', function () {
         const pdf = Client.getOutputFile(this.body, 'pdf')
         pdf.type.should.equal('pdf')
@@ -111,14 +131,15 @@ Hello world
           ]
         }
 
+        const expectedRuns = scenario.expectedRuns ?? 1
         // Note: chai's all.keys assertion rejects extra keys
         stats.should.have.all.keys(
           'isInitialCompile',
           'latexmk-errors',
           'latex-runs',
           'latex-runs-with-errors',
-          'latex-runs-1',
-          'latex-runs-with-errors-1',
+          `latex-runs-${expectedRuns}`,
+          `latex-runs-with-errors-${expectedRuns}`,
           'pdf-size',
           ...pdfCachingStats
         )
@@ -130,6 +151,11 @@ Hello world
           ...pdfCachingTimings
         )
       })
+
+      it('should report the correct number of runs', function () {
+        const { stats } = this.body.compile
+        expect(stats['latex-runs']).to.equal(scenario.expectedRuns ?? 1)
+      })
     })
   }