From aa40e817c853a5e71ab59ce2cb29b8ee258c0d59 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Mon, 7 Oct 2024 18:51:23 -0400 Subject: [PATCH] ci: add datadog test logging (#44094) --- .../pipeline-segment-electron-test.yml | 15 ++++++++++++++- appveyor-woa.yml | 18 +++++++++++++++--- appveyor.yml | 16 +++++++++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pipeline-segment-electron-test.yml b/.github/workflows/pipeline-segment-electron-test.yml index eb78dd0dd93..137fe919960 100644 --- a/.github/workflows/pipeline-segment-electron-test.yml +++ b/.github/workflows/pipeline-segment-electron-test.yml @@ -146,17 +146,21 @@ jobs: sudo security authorizationdb write com.apple.trust-settings.admin allow cd src/electron ./script/codesign/generate-identity.sh + - name: Install Datadog CLI + run: | + cd src/electron + node script/yarn global add @datadog/datadog-ci - name: Run Electron Tests shell: bash env: MOCHA_REPORTER: mocha-multi-reporters - ELECTRON_TEST_RESULTS_DIR: junit MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap ELECTRON_DISABLE_SECURITY_WARNINGS: 1 ELECTRON_SKIP_NATIVE_MODULE_TESTS: true DISPLAY: ':99.0' run: | cd src/electron + export ELECTRON_TEST_RESULTS_DIR=`pwd`/junit # Get which tests are on this shard tests_files=$(node script/split-tests ${{ matrix.shard }} ${{ inputs.target-platform == 'macos' && 2 || 3 }}) @@ -185,6 +189,15 @@ jobs: runuser -u builduser -- xvfb-run script/actions/run-tests.sh script/yarn test --runners=main --trace-uncaught --enable-logging --files $tests_files fi fi + - name: Upload Test results to Datadog + env: + DD_ENV: ci + DD_SERVICE: electron + DD_API_KEY: ${{ secrets.DD_API_KEY }} + DD_CIVISIBILITY_LOGS_ENABLED: true + DD_TAGS: "os.architecture:${{ inputs.target-arch }},os.family:${{ inputs.target-platform }},os.platform:${{ inputs.target-platform }},asan:${{ inputs.is-asan }}" + run: datadog-ci junit upload src/electron/junit/test-results-main.xml + if: always() && !cancelled() - name: Upload Test Artifacts if: always() && !cancelled() uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 97be324ae0b..822381870ad 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -36,7 +36,7 @@ environment: ELECTRON_ENABLE_STACK_DUMPING: 1 ELECTRON_ALSO_LOG_TO_STDERR: 1 MOCHA_REPORTER: mocha-multi-reporters - MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, tap" + MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, mocha-junit-reporter, tap" DEPOT_TOOLS_WIN_TOOLCHAIN: 1 DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_" GYP_MSVS_HASH_7393122652: 3ba76c5c20 @@ -258,10 +258,14 @@ for: environment: IGNORE_YARN_INSTALL_ERROR: 1 - ELECTRON_TEST_RESULTS_DIR: junit - MOCHA_MULTI_REPORTERS: 'mocha-junit-reporter, tap' + ELECTRON_TEST_RESULTS_DIR: C:\projects\src\electron\junit + MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, mocha-junit-reporter, tap" MOCHA_REPORTER: mocha-multi-reporters ELECTRON_SKIP_NATIVE_MODULE_TESTS: true + DD_ENV: ci + DD_SERVICE: electron + DD_CIVISIBILITY_LOGS_ENABLED: true + DD_GIT_REPOSITORY_URL: "https://github.com/electron/electron.git" build_script: - ps: | @@ -273,6 +277,7 @@ for: } else { $global:LASTEXITCODE = 0 } + - ps: Invoke-WebRequest -Uri "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_win-x64" -OutFile "C:\projects\src\electron\datadog-ci.exe" - cd .. - mkdir out\Default - cd .. @@ -328,3 +333,10 @@ for: on_finish: # Uncomment these lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + - if exist electron\junit\test-results-main.xml ( appveyor-retry appveyor PushArtifact electron\junit\test-results-main.xml ) + - ps: | + $env:DD_GIT_COMMIT_SHA = $env:APPVEYOR_REPO_COMMIT + $env:DD_GIT_BRANCH = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH + $env:DD_TAGS = "os.architecture:$env:TARGET_ARCH,os.family:windows,os.platform:win32" + C:\projects\src\electron\datadog-ci.exe junit upload --verbose C:\projects\src\electron\junit\test-results-main.xml + diff --git a/appveyor.yml b/appveyor.yml index 88290d41ca7..18055fb2820 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,7 +36,7 @@ environment: ELECTRON_ENABLE_STACK_DUMPING: 1 ELECTRON_ALSO_LOG_TO_STDERR: 1 MOCHA_REPORTER: mocha-multi-reporters - MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, tap" + MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, mocha-junit-reporter, tap" DEPOT_TOOLS_WIN_TOOLCHAIN: 1 DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_" GYP_MSVS_HASH_7393122652: 3ba76c5c20 @@ -248,6 +248,13 @@ for: only: - job_name: Test + environment: + DD_ENV: ci + DD_SERVICE: electron + DD_CIVISIBILITY_LOGS_ENABLED: true + DD_GIT_REPOSITORY_URL: "https://github.com/electron/electron.git" + ELECTRON_TEST_RESULTS_DIR: C:\projects\src\electron\junit + init: - ps: | if ($env:RUN_TESTS -ne 'true') { @@ -263,6 +270,7 @@ for: } else { $global:LASTEXITCODE = 0 } + - npm install -g @datadog/datadog-ci - cd .. - mkdir out\Default - cd .. @@ -320,3 +328,9 @@ for: on_finish: # Uncomment these lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + - if exist electron\junit\test-results-main.xml ( appveyor-retry appveyor PushArtifact electron\junit\test-results-main.xml ) + - ps: | + $env:DD_GIT_COMMIT_SHA = $env:APPVEYOR_REPO_COMMIT + $env:DD_GIT_BRANCH = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH + $env:DD_TAGS = "os.architecture:$env:TARGET_ARCH,os.family:windows,os.platform:win32" + C:\Users\appveyor\AppData\Roaming\npm\datadog-ci.ps1 junit upload --verbose C:\projects\src\electron\junit\test-results-main.xml