Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: Run python_basics integration tests
# Have to create the virtualenv as it's a run command. Otherwise basic_venv is just build and won't be able
# To execute what we need in the simple-tests.
run: |
cd python_basics/integration_tests
bazel run //simple-tests:basic_venv
bazel test //...
- name: Run starpls integration tests
run: |
Expand Down
3 changes: 3 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
formatter:
type: basic
retain_line_breaks: true
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ multitool.hub(
)
use_repo(multitool, "yamlfmt_hub")

bazel_dep(name = "score_docs_as_code", version = "3.0.1", dev_dependency = True)
bazel_dep(name = "score_docs_as_code", version = "3.0.1")

# bazel_dep(name = "score_platform", version = "0.5.0")
bazel_dep(name = "score_process", version = "1.3.2")
4 changes: 2 additions & 2 deletions python_basics/integration_tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Python version & Pip
#
###############################################################################
bazel_dep(name = "rules_python", version = "1.4.1")
bazel_dep(name = "rules_python", version = "1.8.4")

PYTHON_VERSION = "3.12"

Expand Down Expand Up @@ -45,7 +45,7 @@ use_repo(pip, "pip_score_venv_test")
# Generic linting and formatting rules
#
###############################################################################
bazel_dep(name = "aspect_rules_py", version = "1.4.0")
bazel_dep(name = "aspect_rules_py", version = "1.6.6")

bazel_dep(name = "bazel_skylib", version = "1.7.1", dev_dependency = True)

Expand Down
1 change: 1 addition & 0 deletions python_basics/integration_tests/simple-tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ score_py_pytest(
name = "venv_ok_test",
srcs = ["test_venv_ok.py"],
data = [":basic_venv"],
deps = ["@rules_python//python/runfiles"],
)

score_py_pytest(
Expand Down
9 changes: 7 additions & 2 deletions python_basics/integration_tests/simple-tests/test_venv_ok.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
import os
import subprocess
from pathlib import Path
from python.runfiles import Runfiles


def test_venv_ok():
runfiles = os.getenv("RUNFILES_DIR")
"""
This test checks if the pytest module is available in the runfiles and if it can be used without
installing pytest explicitly inside the virtualenv
"""
if (r := Runfiles.Create()) and (rd := r.EnvVars().get("RUNFILES_DIR")):
runfiles = Path(rd)
assert runfiles, "runfiles could not be found, RUNFILES_DIR is not set"
packages = os.listdir(runfiles)
assert any(x.endswith("pytest") for x in packages), (
Expand All @@ -26,7 +32,6 @@ def test_venv_ok():
import pytest # type ignore

python_venv_folder = [x for x in packages if "python_3_12_" in x][0]

# Trying to actually use pytest module and collect current test & file
proc = subprocess.run(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
import os
from python.runfiles import Runfiles
from pathlib import Path


def test_venv_ok():
runfiles = os.getenv("RUNFILES_DIR")
if (r := Runfiles.Create()) and (rd := r.EnvVars().get("RUNFILES_DIR")):
runfiles = Path(rd)
packages = os.listdir(runfiles)
assert any(x.endswith("requests") for x in packages), (
f"'Request not found in runfiles: {runfiles}"
Expand Down
Loading