Auto merge of #134095 - Kobzol:datadog-lockfile, r=MarcoIeni

[CI] Use a lockfile for installing the `datadog` package

Without a lockfile, it could fail to compile when the dependencies have changed. Reported [here](https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/CI.20failure.20in.20DataDog.20upload).

r? `@jdno`

try-job: x86_64-msvc-ext2
This commit is contained in:
bors 2024-12-16 23:07:24 +00:00
commit 13b77c687c
4 changed files with 5018 additions and 10 deletions

View file

@ -235,8 +235,9 @@ jobs:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_GITHUB_JOB_NAME: ${{ matrix.name }}
run: |
npm install -g @datadog/datadog-ci@^2.x.x
python3 src/ci/scripts/upload-build-metrics.py build/cpu-usage.csv
cd src/ci
npm ci
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
# when a workflow is successful listening to webhooks only in our current bors implementation (homu).

5004
src/ci/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

5
src/ci/package.json Normal file
View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@datadog/datadog-ci": "^2.45.1"
}
}

View file

@ -9,8 +9,8 @@ It expects the following environment variables:
- DATADOG_API_KEY: DataDog API token
- DD_GITHUB_JOB_NAME: Name of the current GitHub Actions job
And it also expects the presence of a binary called `datadog-ci` to be in PATH.
It can be installed with `npm install -g @datadog/datadog-ci`.
It expects the presence of a binary called `datadog-ci` inside `node_modules`.
It can be installed with `npm ci` at `src/ci`.
Usage:
```bash
@ -50,16 +50,14 @@ def upload_datadog_measure(name: str, value: float):
"""
print(f"Metric {name}: {value:.4f}")
datadog_cmd = "datadog-ci"
if os.getenv("GITHUB_ACTIONS") is not None and sys.platform.lower().startswith(
"win"
):
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.
datadog_cmd = "C:\\npm\\prefix\\datadog-ci.cmd"
cmd = "C:\\Program Files\\nodejs\\npx.cmd"
subprocess.run(
[datadog_cmd, "measure", "--level", "job", "--measures", f"{name}:{value}"],
[cmd, "datadog-ci", "measure", "--level", "job", "--measures", f"{name}:{value}"],
check=False,
)