From acef18dcf002fd861a463174a8b1c5c920d67edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Mon, 16 Dec 2024 12:01:43 +0100 Subject: [PATCH] WIP --- .github/workflows/ci.yml | 55 ++++++++++++++------------ src/ci/scripts/upload-build-metrics.py | 10 ++++- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 553ef676154bc..c85e83509d98d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -192,12 +192,12 @@ jobs: - name: ensure the stable version number is correct run: src/ci/scripts/verify-stable-version-number.sh - - name: run the build + # - name: run the build # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. - run: src/ci/scripts/run-build-from-ci.sh 2>&1 - env: - AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }} + # run: src/ci/scripts/run-build-from-ci.sh 2>&1 + # env: + # AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }} - name: create github artifacts run: src/ci/scripts/create-doc-artifacts.sh @@ -207,26 +207,26 @@ jobs: echo "disk usage:" df -h - - name: upload artifacts to github - uses: actions/upload-artifact@v4 - with: - # name is set in previous step - name: ${{ env.DOC_ARTIFACT_NAME }} - path: obj/artifacts/doc - if-no-files-found: ignore - retention-days: 5 - - - name: upload artifacts to S3 - run: src/ci/scripts/upload-artifacts.sh - env: - AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }} - # Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy - # builders *should* have the AWS credentials available. Still, explicitly - # adding the condition is helpful as this way CI will not silently skip - # deploying artifacts from a dist builder if the variables are misconfigured, - # erroring about invalid credentials instead. - if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1' + # - name: upload artifacts to github + # uses: actions/upload-artifact@v4 + # with: + # # name is set in previous step + # name: ${{ env.DOC_ARTIFACT_NAME }} + # path: obj/artifacts/doc + # if-no-files-found: ignore + # retention-days: 5 + # + # - name: upload artifacts to S3 + # run: src/ci/scripts/upload-artifacts.sh + # env: + # AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }} + # # Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy + # # builders *should* have the AWS credentials available. Still, explicitly + # # adding the condition is helpful as this way CI will not silently skip + # # deploying artifacts from a dist builder if the variables are misconfigured, + # # erroring about invalid credentials instead. + # if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1' - name: upload job metrics to DataDog if: needs.calculate_matrix.outputs.run_type != 'pr' @@ -237,6 +237,11 @@ jobs: run: | cd src/ci npm ci + which npx || exit 0 + where npx || exit 0 + which datadog-ci || exit 0 + where datadog-ci || exit 0 + npm root -g python3 scripts/upload-build-metrics.py ../../build/cpu-usage.csv # This job isused to tell bors the final status of the build, as there is no practical way to detect diff --git a/src/ci/scripts/upload-build-metrics.py b/src/ci/scripts/upload-build-metrics.py index 638c054388cfa..30b27326ad0e9 100644 --- a/src/ci/scripts/upload-build-metrics.py +++ b/src/ci/scripts/upload-build-metrics.py @@ -22,7 +22,9 @@ import argparse import csv +import os import subprocess +import sys from pathlib import Path from typing import List @@ -48,8 +50,14 @@ def upload_datadog_measure(name: str, value: float): """ print(f"Metric {name}: {value:.4f}") + cmd = "npx" + if os.getenv("GITHUB_ACTIONS") is not None and sys.platform.lower().startswith("win"): + # Due to weird interaction of MSYS2 and Python, we need to use an absolute path, + # and also specify the ".cmd" at the end. See https://github.com/rust-lang/rust/pull/125771. + cmd = "C:\\npm\\prefix\\npx.cmd" + subprocess.run( - ["npx", "datadog-ci", "measure", "--level", "job", "--measures", f"{name}:{value}"], + [cmd, "datadog-ci", "measure", "--level", "job", "--measures", f"{name}:{value}"], check=False, )