Skip to content

Commit 192204c

Browse files
authored
Merge branch 'main' into tracability-improvements
2 parents f967a55 + 590778c commit 192204c

51 files changed

Lines changed: 1578 additions & 1210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/consumer_test.yml

Lines changed: 11 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
consumer: ["process_description", "score", "module_template"]
28+
consumer: [
29+
"process_description and local",
30+
"process_description and remote",
31+
"score and local",
32+
"score and remote",
33+
"module_template and local",
34+
"module_template and remote",
35+
]
2936

3037
steps:
3138
- name: 🛡️ Harden Runner
@@ -35,74 +42,15 @@ jobs:
3542
egress-policy: audit
3643

3744
- name: Checkout PR
38-
uses: actions/checkout@v4.2.2
45+
uses: actions/checkout@v6.0.2
3946

4047
- name: Prepare Python
41-
run: |
42-
bazel run --lockfile_mode=error //:ide_support
48+
run: bazel run //:ide_support
4349

44-
- name: Prepare report directory
45-
run: |
46-
mkdir -p reports
47-
48-
# The pipefail ensures that non 0 exit codes inside the pytest execution get carried into the pipe
49-
# & make the tests red in the end. Without this we only would check the exit code of the 'tee' command.
5050
- name: Run Consumer tests
51-
52-
run: |
53-
pytest_rc=0
54-
.venv_docs/bin/python -m pytest -vv src/tests/ \
55-
--repo="$CONSUMER" \
56-
--junitxml="reports/${{ matrix.consumer }}.xml" \
57-
|| pytest_rc=$?
58-
59-
60-
if [ -f "consumer_test.log" ]; then
61-
src_log="consumer_test.log"
62-
else
63-
echo "consumer_test.log not found; expected at ./consumer_test.log"
64-
exit ${pytest_rc:-1}
65-
fi
66-
67-
dest_log="reports/${{ matrix.consumer }}.log"
68-
mv "$src_log" "$dest_log"
69-
70-
tail -n 15 "$dest_log" >> "$GITHUB_STEP_SUMMARY"
71-
72-
cat "$dest_log"
73-
exit $pytest_rc
51+
run: .venv_docs/bin/python -m pytest -vv -s src/tests/test_consumer.py -k "$CONSUMER"
7452
env:
7553
FORCE_COLOR: "1"
7654
TERM: xterm-256color
7755
PYTHONUNBUFFERED: "1"
7856
CONSUMER: ${{ matrix.consumer }}
79-
80-
- name: Upload consumer test report
81-
if: ${{ always() }}
82-
uses: actions/upload-artifact@v4
83-
with:
84-
name: tests-${{ matrix.consumer }}
85-
path: reports/
86-
87-
summarize:
88-
needs: test
89-
runs-on: ubuntu-latest
90-
if: ${{ always() }}
91-
steps:
92-
- name: Prepare consumer report directory
93-
run: |
94-
mkdir -p tests-report
95-
96-
- name: Download individual consumer reports
97-
uses: actions/download-artifact@v4
98-
with:
99-
pattern: tests-*
100-
path: tests-report
101-
merge-multiple: true
102-
103-
- name: Upload bundled consumer report
104-
if: ${{ always() }}
105-
uses: actions/upload-artifact@v4
106-
with:
107-
name: tests-report
108-
path: tests-report

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ __pycache__/
2727
# bug: This file is created in repo root on test discovery.
2828
/consumer_test.log
2929
.clwb
30+
31+
# AI
32+
/.codex
33+
/.claude

docs.bzl

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,27 @@ def _merge_sourcelinks(name, sourcelinks, known_good = None):
8181
extra_srcs = [known_good]
8282
known_good_arg = "--known_good $(location %s)" % known_good
8383

84+
merge_sourcelinks_tool = Label("//scripts_bazel:merge_sourcelinks")
85+
8486
native.genrule(
8587
name = name,
8688
srcs = sourcelinks + extra_srcs,
8789
outs = [name + ".json"],
8890
cmd = """
89-
$(location @score_docs_as_code//scripts_bazel:merge_sourcelinks) \
91+
$(location {merge_sourcelinks_tool}) \
9092
--output $@ \
9193
{known_good_arg} \
9294
$(SRCS)
93-
""".format(known_good_arg = known_good_arg),
94-
tools = ["@score_docs_as_code//scripts_bazel:merge_sourcelinks"],
95+
""".format(known_good_arg = known_good_arg, merge_sourcelinks_tool = merge_sourcelinks_tool),
96+
tools = [merge_sourcelinks_tool],
9597
)
9698

9799
def _missing_requirements(deps):
98100
"""Add Python hub dependencies if they are missing."""
99101
found = []
100102
missing = []
101103
def _target_to_packagename(target):
102-
return target.split("/")[-1].split(":")[0]
104+
return str(target).split("/")[-1].split(":")[0]
103105
all_packages = [_target_to_packagename(pkg) for pkg in all_requirements]
104106
def _find(pkg):
105107
for dep in deps:
@@ -156,10 +158,12 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
156158
module_deps = deps
157159
deps = deps + _missing_requirements(deps)
158160
deps = deps + [
159-
"@score_docs_as_code//src:plantuml_for_python",
160-
"@score_docs_as_code//src/extensions/score_sphinx_bundle:score_sphinx_bundle",
161+
Label("//src:plantuml_for_python"),
162+
Label("//src/extensions/score_sphinx_bundle:score_sphinx_bundle"),
161163
]
162164

165+
incremental_src = Label("//src:incremental.py")
166+
163167
sphinx_build_binary(
164168
name = "sphinx_build",
165169
visibility = ["//visibility:private"],
@@ -212,8 +216,9 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
212216
"SCORE_SOURCELINKS": "$(location :merged_sourcelinks)",
213217
} | metamodel_env
214218
if known_good:
215-
docs_env["KNOWN_GOOD_JSON"] = "$(location "+ known_good + ")"
216-
docs_sources_env["KNOWN_GOOD_JSON"] = "$(location "+ known_good + ")"
219+
known_good_str = str(known_good)
220+
docs_env["KNOWN_GOOD_JSON"] = "$(location " + known_good_str + ")"
221+
docs_sources_env["KNOWN_GOOD_JSON"] = "$(location " + known_good_str + ")"
217222
docs_data.append(known_good)
218223
combo_data.append(known_good)
219224

@@ -222,7 +227,7 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
222227
py_binary(
223228
name = "docs",
224229
tags = ["cli_help=Build documentation:\nbazel run //:docs"],
225-
srcs = ["@score_docs_as_code//src:incremental.py"],
230+
srcs = [incremental_src],
226231
data = docs_data,
227232
deps = deps,
228233
env = docs_env
@@ -232,7 +237,7 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
232237
py_binary(
233238
name = "docs_combo",
234239
tags = ["cli_help=Build full documentation with all dependencies:\nbazel run //:docs_combo"],
235-
srcs = ["@score_docs_as_code//src:incremental.py"],
240+
srcs = [incremental_src],
236241
data = combo_data,
237242
deps = deps,
238243
env = docs_sources_env
@@ -248,7 +253,7 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
248253
py_binary(
249254
name = "docs_link_check",
250255
tags = ["cli_help=Verify Links inside Documentation:\nbazel run //:link_check\n (Note: this could take a long time)"],
251-
srcs = ["@score_docs_as_code//src:incremental.py"],
256+
srcs = [incremental_src],
252257
data = docs_data,
253258
deps = deps,
254259
env = docs_env
@@ -258,7 +263,7 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
258263
py_binary(
259264
name = "docs_check",
260265
tags = ["cli_help=Verify documentation:\nbazel run //:docs_check"],
261-
srcs = ["@score_docs_as_code//src:incremental.py"],
266+
srcs = [incremental_src],
262267
data = docs_data,
263268
deps = deps,
264269
env = docs_env
@@ -268,7 +273,7 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
268273
py_binary(
269274
name = "live_preview",
270275
tags = ["cli_help=Live preview documentation in the browser:\nbazel run //:live_preview"],
271-
srcs = ["@score_docs_as_code//src:incremental.py"],
276+
srcs = [incremental_src],
272277
data = docs_data,
273278
deps = deps,
274279
env = docs_env
@@ -278,7 +283,7 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
278283
py_binary(
279284
name = "live_preview_combo_experimental",
280285
tags = ["cli_help=Live preview full documentation with all dependencies in the browser:\nbazel run //:live_preview_combo_experimental"],
281-
srcs = ["@score_docs_as_code//src:incremental.py"],
286+
srcs = [incremental_src],
282287
data = combo_data,
283288
deps = deps,
284289
env = docs_sources_env
@@ -316,10 +321,18 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = [], known_good =
316321
allow_persistent_workers = False,
317322
)
318323

324+
native.genrule(
325+
name = "metrics_json",
326+
srcs = [":needs_json"],
327+
outs = ["metrics.json"],
328+
cmd = "cp $(location :needs_json)/metrics.json $@",
329+
visibility = ["//visibility:public"],
330+
)
331+
319332
native.alias(
320333
name = "traceability_gate",
321-
actual = "@score_docs_as_code//scripts_bazel:traceability_gate",
322-
tags = ["cli_help=Enforce traceability coverage thresholds:\nbazel run //:traceability_gate -- --metrics-json bazel-bin/needs_json/_build/needs/metrics.json"],
334+
actual = Label("//scripts_bazel:traceability_gate"),
335+
tags = ["cli_help=Enforce traceability coverage thresholds:\nbazel run //:traceability_gate -- --metrics-json $(location //:metrics_json)"],
323336
)
324337

325338
def _sourcelinks_json(name, srcs):
@@ -334,15 +347,17 @@ def _sourcelinks_json(name, srcs):
334347
"""
335348
output_file = name + ".json"
336349

350+
generate_sourcelinks_tool = Label("//scripts_bazel:generate_sourcelinks")
351+
337352
native.genrule(
338353
name = name,
339354
srcs = srcs,
340355
outs = [output_file],
341356
cmd = """
342-
$(location @score_docs_as_code//scripts_bazel:generate_sourcelinks) \
357+
$(location {generate_sourcelinks_tool}) \
343358
--output $@ \
344359
$(SRCS)
345-
""",
346-
tools = ["@score_docs_as_code//scripts_bazel:generate_sourcelinks"],
360+
""".format(generate_sourcelinks_tool = generate_sourcelinks_tool),
361+
tools = [generate_sourcelinks_tool],
347362
visibility = ["//visibility:public"],
348363
)

docs/how-to/other_modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Example `BUILD` snippet (consumer module):
4848

4949
.. code-block:: starlark
5050
51-
load("@rules_docs//:docs.bzl", "docs")
51+
load("@score_docs_as_code//:docs.bzl", "docs")
5252
docs(
5353
data = [
5454
"@score_process//:needs_json",

docs/how-to/setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ designed to enhance documentation capabilities in S-CORE.
2323
Add the module to your `MODULE.bazel` file:
2424

2525
```starlark
26-
bazel_dep(name = "score_docs_as_code", version = "4.0.1")
26+
bazel_dep(name = "score_docs_as_code", version = "4.1.0")
2727
```
2828

2929
And make sure to also add the S-core Bazel registry to your `.bazelrc` file

docs/how-to/source_to_doc_links.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Finally, pass the scan results to the ``docs`` rule as ``scan_code`` attribute.
5353
"foo.py",
5454
"bar.cpp",
5555
"data.yaml",
56-
] + glob(["subdir/**/.py"]),
56+
] + glob(["subdir/**/*.py"]),
5757
)
5858
5959
docs(

docs/how-to/write_docs.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
Write Documentation
1616
===================
1717

18+
Outside Documentation
19+
^^^^^^^^^^^^^^^^^^^^^
20+
1821
`Sphinx <https://www.sphinx-doc.org/en/master/>`_:
1922
the documentation generator we use.
2023

@@ -23,3 +26,47 @@ the plain-text markup language used for most source files in this project.
2326

2427
`Sphinx-Needs <https://sphinx-needs.readthedocs.io/en/latest/>`_:
2528
a Sphinx extension that models requirements, tests, tasks and other "needs" inside the docs.
29+
30+
31+
Advanced
32+
^^^^^^^^
33+
34+
Needextend
35+
~~~~~~~~~~
36+
37+
Needextend allows you to extend needs that are defined in the documentation.
38+
The scope of allowed behaviour in Docs-As-Code for needextend is limited as we do not allow all of its usecases.
39+
40+
Allowed usecases:
41+
42+
* Setting an attribute or Link **IF** it is not already set in the need that is getting modified
43+
* Appending to a list of links
44+
45+
Not Allowed:
46+
47+
* Overwriting an attribute or Link that already is set in the need that gets modified
48+
* Deleting an attribute or Link
49+
50+
.. code-block:: rst
51+
52+
.. stkh_req:: Test Req Extends 1
53+
:id: stkh_req__test__need_extends_1
54+
:status: invalid
55+
56+
57+
# ✅ ALLOWED => The replacing of attributes on needs that are NOT set.
58+
.. needextend:: c.this_doc() and id == 'stkh_req__test__need_extends_1'
59+
:safety: NO
60+
61+
62+
# ❌ NOT ALLOWED => Overwriting attributes that are already set in the need
63+
.. needextend:: c.this_doc() and id == 'stkh_req__test__need_extends_1'
64+
:status: valid
65+
66+
67+
For further documentation on needextends please `look here <https://sphinx-needs.readthedocs.io/en/latest/directives/needextend.html>`_
68+
69+
.. note::
70+
71+
In the future we will enable a check that needextends will only modify needs in the current document.
72+
You can ensure this by adding `c.this_doc()` to the filter string of the need.

docs/internals/extensions/extension_guide.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This document will help you with the most important building blocks and provide
66

77
## Getting Started
88

9-
1. Create a new folder in `docs/_tooling/extensions` called `score_<name of your extension>`
9+
1. Create a new folder in `src/extensions` called `score_<name of your extension>`
1010
2. Copy the template inside the `__init__.py`
1111
3. Adapt to your needs
1212

@@ -76,7 +76,7 @@ extensions = [
7676
]
7777
```
7878

79-
> **Important:** There cannot be any BUILD file inside the entire 'extensions' folder, as that would break the Python imports.
79+
> **Important:** Each extension needs its own `BUILD` file to declare the `py_library` target and its dependencies.
8080
8181

8282

@@ -90,16 +90,13 @@ We perform testing with unit tests as well as integration tests that validate th
9090
### Where to Place Your Test Code
9191

9292
```bash
93-
_tooling/
94-
├── extensions/
95-
│ ├── README.md
96-
│ ├── score_draw_uml_funcs/
97-
│ ├── YOUR_EXTENSION/
98-
│ │ ├── __init__.py # your python code (setup needs to be in here)
99-
│ │ ├── xyz.py # your python code (if you need/want to split it across different files)
100-
│ │ └── tests/
101-
│ │ ├── test_xyz.py # unit tests
102-
│ │ └── test_YOUR_EXTENSION.py # integration tests
93+
src/extensions/
94+
├── YOUR_EXTENSION/
95+
│ ├── __init__.py # your python code (setup needs to be in here)
96+
│ ├── xyz.py # your python code (if you need/want to split it across different files)
97+
│ └── tests/
98+
│ ├── test_xyz.py # unit tests
99+
│ └── test_YOUR_EXTENSION.py # integration tests
103100
├── score_metamodel/
104101
├── score_plantuml.py
105102
```

docs/internals/extensions/index.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
Extensions
2020
==========
2121

22-
Hello there
23-
2422

2523
.. grid:: 1 1 3 3
2624
:class-container: score-grid

0 commit comments

Comments
 (0)