Skip to content

Commit

Permalink
Temporary fix TERM issue with rules_uv
Browse files Browse the repository at this point in the history
see theoremlp/rules_uv#167

Change-Id: I2758c56e2e7009d0ba8d1b1383e4cbeda565f5db
  • Loading branch information
TimotheusBachinger committed Dec 5, 2024
1 parent 6b6f5ab commit 3ed1e01
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 42 deletions.
7 changes: 7 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_rust", version = "0.49.3")
bazel_dep(name = "rules_python", version = "0.37.0")
bazel_dep(name = "rules_uv", version = "0.42.0")
# TODO: Check if term issue is fixed:
# https://github.com/theoremlp/rules_uv/pull/167
single_version_override(
module_name = "rules_uv",
patch_strip = 1,
patches = ["//bazel/patches:rules_uv_term.patch"],
)

# TODO: how to sync this with the PYTHON_VERSION in package_versions.bzl?
PYTHON_VERSION = "3.12.3"
Expand Down
29 changes: 18 additions & 11 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added bazel/patches/BUILD
Empty file.
33 changes: 33 additions & 0 deletions bazel/patches/rules_uv_term.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 2f9c114e1fd7fc7aff2cb7fe58187c127a3d1c4f Mon Sep 17 00:00:00 2001
From: Timotheus Bachinger <Timotheus.bachinger@checkmk.com>
Date: Sat, 30 Nov 2024 03:43:30 +0100
Subject: [PATCH 1/1] Enable create_venv for non-interactive runs (#167)

When using `create_venv` in non-interactive docker container runs, we
would get:
```
tput: No value for $TERM and no -T specified
```
This sets `TERM` in case it isn't and enables such runs.
---
uv/private/create_venv.sh | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/uv/private/create_venv.sh b/uv/private/create_venv.sh
index 10edaf4..b88b2d4 100644
--- a/uv/private/create_venv.sh
+++ b/uv/private/create_venv.sh
@@ -8,6 +8,10 @@ REQUIREMENTS_TXT="{{requirements_txt}}"

PYTHON="$(realpath "$RESOLVED_PYTHON")"

+if [ -z ${TERM} ] || [ ${TERM} == "dumb" ]; then
+ export TERM=xterm
+fi
+
bold="$(tput bold)"
normal="$(tput sgr0)"

--
2.43.0

30 changes: 15 additions & 15 deletions buildscripts/scripts/stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ STAGES:
- NAME: "Package cmk-agent-based"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_AGENT_BASED_FILES
DIR: "packages/cmk-agent-based"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-agent-based.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-agent-based.txt"
TEXT_ON_SKIP: "No cmk-agent-based files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-agent-based.txt"

Expand All @@ -438,91 +438,91 @@ STAGES:
- NAME: "Package cmk-agent-receiver"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_AGENT_RECEIVER_FILES
DIR: "packages/cmk-agent-receiver"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-agent-receiver.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-agent-receiver.txt"
TEXT_ON_SKIP: "No cmk-agent-receiver files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-agent-receiver.txt"

- NAME: "Package cmk-ccc"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_CCC_FILES
DIR: "packages/cmk-ccc"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-ccc.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-ccc.txt"
TEXT_ON_SKIP: "No cmk-ccc files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-ccc.txt"

- NAME: "Package cmk-crypto"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_CRYPTO_FILES
DIR: "packages/cmk-crypto"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-crypto.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-crypto.txt"
TEXT_ON_SKIP: "No cmk-crypto files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-crypto.txt"

- NAME: "Package cmk-events"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_EVENTS_FILES
DIR: "packages/cmk-mkp-tool"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-events.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-events.txt"
TEXT_ON_SKIP: "No cmk-events files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-events.txt"

- NAME: "Package cmk-graphing"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_GRAPHING_FILES
DIR: "packages/cmk-graphing"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-graphing.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-graphing.txt"
TEXT_ON_SKIP: "No cmk-graphing files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-graphing.txt"

- NAME: "Package cmk-livestatus-client"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_LIVESTATUS_CLIENT_FILES
DIR: "packages/cmk-livestatus-client"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-livestatus-client.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-livestatus-client.txt"
TEXT_ON_SKIP: "No cmk-livestatus-client files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-livestatus-client.txt"

- NAME: "Package cmk-messaging"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_MESSAGING_FILES
DIR: "packages/cmk-messaging"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-messaging.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-messaging.txt"
TEXT_ON_SKIP: "No cmk-messaging files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-messaging.txt"

- NAME: "Package cmk-mkp-tool"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_MKP_TOOL_FILES
DIR: "packages/cmk-mkp-tool"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-mkp-tool.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-mkp-tool.txt"
TEXT_ON_SKIP: "No cmk-mkp-tool files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-mkp-tool.txt"

- NAME: "Package cmk-otel-collector"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_OTEL_FILES
DIR: "non-free/packages/cmk-otel-collector"
COMMAND: "../../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-otel-collector.txt"
COMMAND: "../../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-otel-collector.txt"
TEXT_ON_SKIP: "No cmk-otel-collector files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-otel-collector.txt"

- NAME: "Package cmk-rulesets"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_RULESETS_FILES
DIR: "packages/cmk-rulesets"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-rulesets.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-rulesets.txt"
TEXT_ON_SKIP: "No cmk-rulesets files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-rulesets.txt"

- NAME: "Package cmk-server-side-calls"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_SERVER_SIDE_CALLS_FILES
DIR: "packages/cmk-server-side-calls"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-server-side-calls.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-server-side-calls.txt"
TEXT_ON_SKIP: "No cmk-server-side-calls files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-server-side-calls.txt"

- NAME: "Package cmk-werks"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_WERKS_FILES
DIR: "packages/cmk-werks"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-werks.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-werks.txt"
TEXT_ON_SKIP: "No cmk-werks package files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-werks.txt"

- NAME: "Package cmk-trace"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_CMK_TRACE_FILES
DIR: "packages/cmk-trace"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --all &> ${RESULTS}/cmk-trace.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --all &> ${RESULTS}/cmk-trace.txt"
TEXT_ON_SKIP: "No cmk-trace package files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-trace.txt"

Expand All @@ -536,7 +536,7 @@ STAGES:
- NAME: "Package cmk-shared-typing"
ONLY_WHEN_NOT_EMPTY: CHANGED_REFERENCE_IMAGE,CHANGED_PYPROJECT_TOML_FILE,CHANGED_SHARED_TYPING_FILES
DIR: "packages/cmk-shared-typing"
COMMAND: "../../scripts/run-in-docker.sh TERM=xterm ./run --clean --all &> ${RESULTS}/cmk-shared-typing.txt"
COMMAND: "../../scripts/run-in-docker.sh ./run --clean --all &> ${RESULTS}/cmk-shared-typing.txt"
TEXT_ON_SKIP: "No cmk-shared-typing files changed"
RESULT_CHECK_FILE_PATTERN: "results/cmk-shared-typing.txt"

Expand Down
2 changes: 1 addition & 1 deletion packages/cmk-agent-based/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-nile@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-agent-receiver/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-main@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-ccc/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["mathias.laurin@checkmk.com"],
}
2 changes: 1 addition & 1 deletion packages/cmk-crypto/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-security@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-events/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["ronny.bruska@checkmk.com", "christopher.krause@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-graphing/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-nile@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-livestatus-client/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-main@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-messaging/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-nile@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-mkp-tool/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-nile@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-rulesets/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-nile@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-server-side-calls/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-nile@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-shared-typing/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-prj-engelbart@checkmk.com"]
}
2 changes: 1 addition & 1 deletion packages/cmk-trace/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["lm@checkmk.com"],
}
2 changes: 1 addition & 1 deletion packages/cmk-werks/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh TERM=xterm ./run --clean --all",
"command_line": "BAZEL_CMD=../../scripts/run-bazel.sh ./run --clean --all",
"maintainers": ["team-prj-engelbart@checkmk.com"],
"dependencies": [".werks/"]
}
4 changes: 2 additions & 2 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ test-semgrep:
$(realpath ..)

test-semgrep-docker:
../scripts/run-in-docker.sh TERM=xterm make test-semgrep
../scripts/run-in-docker.sh make test-semgrep

test-bandit: bandit.ini
# Currently only care about high severity reported issues. Once this is reached,
Expand Down Expand Up @@ -406,7 +406,7 @@ test-cycles:
--verbose

test-cycles-docker:
../scripts/run-in-docker.sh TERM=xterm make --quiet test-cycles
../scripts/run-in-docker.sh make --quiet test-cycles

test-unit-omdlib:
cd .. && TZ=$(RANDOM_TZ) $(PYTEST) \
Expand Down

0 comments on commit 3ed1e01

Please sign in to comment.