Skip to content

Commit 1b1fcd0

Browse files
authored
chore: report the coverage from the e2e/use_release test (#498)
So we can see that it's working, based on comments that get posted to the PR. Notes: - I had to move the files to a `src` subfolder so I can use an `--instrumentation_filter` that doesn't include `//...` since that's causing external repos to get instrumented. - The GHA setup here is fighting me on referencing the combined_report in bazel-out so I just look for **/coverage.dat - actually it's not required to ask bazel to merge the coverage reports for this case. --- ### Changes are visible to end-users: no ### Test plan - New test cases added
1 parent a17eb3d commit 1b1fcd0

File tree

12 files changed

+157
-28
lines changed

12 files changed

+157
-28
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,17 @@ jobs:
6666
steps:
6767
- uses: actions/checkout@v4
6868
- run: ./minimal_download_test.sh
69-
- run: |
70-
bazel coverage //...
71-
ls -R $(bazel info bazel-testlogs)/_coverage/test
69+
- run: bazel coverage //src/...
70+
- uses: hrishikesh-kadam/setup-lcov@6c1aa0cc9e1c02f9f58f01ac599f1064ccc83470 # v1
71+
# The github-actions-report-lcov doesn't follow symlinks, so get an absolute path
72+
- run: echo "bazel_testlogs=$(bazel info bazel-testlogs)" >> $GITHUB_ENV
73+
- name: Report code coverage
74+
uses: zgosalvez/github-actions-report-lcov@5989987f8058a03137e90bc16f9c0baaac5e069a # v4.1.22
75+
with:
76+
working-directory: ${{ env.bazel_testlogs }}
77+
coverage-files: "**/coverage.dat"
78+
github-token: ${{ secrets.GITHUB_TOKEN }}
79+
update-comment: true
7280

7381
# For branch protection settings, this job provides a "stable" name that can be used to gate PR merges
7482
# on "all matrix jobs were successful".

e2e/use_release/.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Don't instrument the root folder, since that walks into the //external folder too
2+
# See https://bazelbuild.slack.com/archives/C07HTMQFTBN/p1737600241213179?thread_ts=1736875351.548719&cid=C07HTMQFTBN
3+
coverage --instrumentation_filter=//src

e2e/use_release/BUILD.bazel

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_test")
1+
load("@rules_uv//uv:pip.bzl", "pip_compile")
22

3-
py_binary(
4-
name = "main",
5-
srcs = [
6-
"__init__.py",
7-
"__main__.py",
8-
],
9-
main = "__main__.py",
10-
)
11-
12-
py_test(
13-
name = "test",
14-
srcs = ["test.py"],
15-
deps = [
16-
":main",
17-
],
18-
)
3+
pip_compile(name = "pip_compile")

e2e/use_release/MODULE.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
bazel_dep(name = "aspect_rules_py", version = "0.0.0")
2+
bazel_dep(name = "rules_python", version = "1.1.0")
3+
bazel_dep(name = "rules_uv", version = "0.51.0")
4+
25
local_path_override(
36
module_name = "aspect_rules_py",
47
path = "../..",
@@ -7,3 +10,11 @@ local_path_override(
710
tools = use_extension("@aspect_rules_py//py:extensions.bzl", "py_tools")
811
tools.rules_py_tools(is_prerelease = False)
912
use_repo(tools, "rules_py_tools")
13+
14+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
15+
pip.parse(
16+
hub_name = "pip",
17+
python_version = "3.11",
18+
requirements_lock = "//:requirements.txt",
19+
)
20+
use_repo(pip, "pip")

e2e/use_release/minimal_download_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fi
1616
patch -p1 < .bcr/patches/*.patch
1717
)
1818
OUTPUT_BASE=$(mktemp -d)
19-
output=$(bazel "--output_base=$OUTPUT_BASE" run --enable_bzlmod //:main)
19+
output=$(bazel "--output_base=$OUTPUT_BASE" run --enable_bzlmod //src:main)
2020
if [[ "$output" != "hello world" ]]; then
2121
>&2 echo "ERROR: bazel command did not produce expected output"
2222
exit 1
@@ -37,7 +37,7 @@ fi
3737
#############
3838
# Test WORKSPACE
3939
OUTPUT_BASE=$(mktemp -d)
40-
output=$(bazel "--output_base=$OUTPUT_BASE" run --noenable_bzlmod //:main)
40+
output=$(bazel "--output_base=$OUTPUT_BASE" run --noenable_bzlmod //src:main)
4141
if [[ "$output" != "hello world" ]]; then
4242
>&2 echo "ERROR: bazel command did not produce expected output"
4343
exit 1

e2e/use_release/requirements.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage
2+
pytest

e2e/use_release/requirements.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# This file was autogenerated by uv via the following command:
2+
# bazel run @@//:pip_compile
3+
--index-url https://pypi.org/simple
4+
5+
coverage==7.6.10 \
6+
--hash=sha256:05fca8ba6a87aabdd2d30d0b6c838b50510b56cdcfc604d40760dae7153b73d9 \
7+
--hash=sha256:0aa9692b4fdd83a4647eeb7db46410ea1322b5ed94cd1715ef09d1d5922ba87f \
8+
--hash=sha256:0c807ca74d5a5e64427c8805de15b9ca140bba13572d6d74e262f46f50b13273 \
9+
--hash=sha256:0d7a2bf79378d8fb8afaa994f91bfd8215134f8631d27eba3e0e2c13546ce994 \
10+
--hash=sha256:0f460286cb94036455e703c66988851d970fdfd8acc2a1122ab7f4f904e4029e \
11+
--hash=sha256:204a8238afe787323a8b47d8be4df89772d5c1e4651b9ffa808552bdf20e1d50 \
12+
--hash=sha256:2396e8116db77789f819d2bc8a7e200232b7a282c66e0ae2d2cd84581a89757e \
13+
--hash=sha256:254f1a3b1eef5f7ed23ef265eaa89c65c8c5b6b257327c149db1ca9d4a35f25e \
14+
--hash=sha256:26bcf5c4df41cad1b19c84af71c22cbc9ea9a547fc973f1f2cc9a290002c8b3c \
15+
--hash=sha256:27c6e64726b307782fa5cbe531e7647aee385a29b2107cd87ba7c0105a5d3853 \
16+
--hash=sha256:299e91b274c5c9cdb64cbdf1b3e4a8fe538a7a86acdd08fae52301b28ba297f8 \
17+
--hash=sha256:2bcfa46d7709b5a7ffe089075799b902020b62e7ee56ebaed2f4bdac04c508d8 \
18+
--hash=sha256:2ccf240eb719789cedbb9fd1338055de2761088202a9a0b73032857e53f612fe \
19+
--hash=sha256:32ee6d8491fcfc82652a37109f69dee9a830e9379166cb73c16d8dc5c2915165 \
20+
--hash=sha256:3f7b444c42bbc533aaae6b5a2166fd1a797cdb5eb58ee51a92bee1eb94a1e1cb \
21+
--hash=sha256:457574f4599d2b00f7f637a0700a6422243b3565509457b2dbd3f50703e11f59 \
22+
--hash=sha256:489a01f94aa581dbd961f306e37d75d4ba16104bbfa2b0edb21d29b73be83609 \
23+
--hash=sha256:4bcc276261505d82f0ad426870c3b12cb177752834a633e737ec5ee79bbdff18 \
24+
--hash=sha256:4e0de1e902669dccbf80b0415fb6b43d27edca2fbd48c74da378923b05316098 \
25+
--hash=sha256:4e4630c26b6084c9b3cb53b15bd488f30ceb50b73c35c5ad7871b869cb7365fd \
26+
--hash=sha256:4eea95ef275de7abaef630c9b2c002ffbc01918b726a39f5a4353916ec72d2f3 \
27+
--hash=sha256:507a20fc863cae1d5720797761b42d2d87a04b3e5aeb682ef3b7332e90598f43 \
28+
--hash=sha256:54a5f0f43950a36312155dae55c505a76cd7f2b12d26abeebbe7a0b36dbc868d \
29+
--hash=sha256:55b201b97286cf61f5e76063f9e2a1d8d2972fc2fcfd2c1272530172fd28c359 \
30+
--hash=sha256:59af35558ba08b758aec4d56182b222976330ef8d2feacbb93964f576a7e7a90 \
31+
--hash=sha256:5c912978f7fbf47ef99cec50c4401340436d200d41d714c7a4766f377c5b7b78 \
32+
--hash=sha256:656c82b8a0ead8bba147de9a89bda95064874c91a3ed43a00e687f23cc19d53a \
33+
--hash=sha256:6713ba4b4ebc330f3def51df1d5d38fad60b66720948112f114968feb52d3f99 \
34+
--hash=sha256:675cefc4c06e3b4c876b85bfb7c59c5e2218167bbd4da5075cbe3b5790a28988 \
35+
--hash=sha256:6f93531882a5f68c28090f901b1d135de61b56331bba82028489bc51bdd818d2 \
36+
--hash=sha256:714f942b9c15c3a7a5fe6876ce30af831c2ad4ce902410b7466b662358c852c0 \
37+
--hash=sha256:79109c70cc0882e4d2d002fe69a24aa504dec0cc17169b3c7f41a1d341a73694 \
38+
--hash=sha256:7bbd8c8f1b115b892e34ba66a097b915d3871db7ce0e6b9901f462ff3a975377 \
39+
--hash=sha256:7ed2f37cfce1ce101e6dffdfd1c99e729dd2ffc291d02d3e2d0af8b53d13840d \
40+
--hash=sha256:7fb105327c8f8f0682e29843e2ff96af9dcbe5bab8eeb4b398c6a33a16d80a23 \
41+
--hash=sha256:89d76815a26197c858f53c7f6a656686ec392b25991f9e409bcef020cd532312 \
42+
--hash=sha256:9a7cfb50515f87f7ed30bc882f68812fd98bc2852957df69f3003d22a2aa0abf \
43+
--hash=sha256:9e1747bab246d6ff2c4f28b4d186b205adced9f7bd9dc362051cc37c4a0c7bd6 \
44+
--hash=sha256:9e80eba8801c386f72e0712a0453431259c45c3249f0009aff537a517b52942b \
45+
--hash=sha256:a01ec4af7dfeb96ff0078ad9a48810bb0cc8abcb0115180c6013a6b26237626c \
46+
--hash=sha256:a372c89c939d57abe09e08c0578c1d212e7a678135d53aa16eec4430adc5e690 \
47+
--hash=sha256:a3b204c11e2b2d883946fe1d97f89403aa1811df28ce0447439178cc7463448a \
48+
--hash=sha256:a534738b47b0de1995f85f582d983d94031dffb48ab86c95bdf88dc62212142f \
49+
--hash=sha256:a5e37dc41d57ceba70956fa2fc5b63c26dba863c946ace9705f8eca99daecdc4 \
50+
--hash=sha256:aa744da1820678b475e4ba3dfd994c321c5b13381d1041fe9c608620e6676e25 \
51+
--hash=sha256:ab32947f481f7e8c763fa2c92fd9f44eeb143e7610c4ca9ecd6a36adab4081bd \
52+
--hash=sha256:abb02e2f5a3187b2ac4cd46b8ced85a0858230b577ccb2c62c81482ca7d18852 \
53+
--hash=sha256:b330368cb99ef72fcd2dc3ed260adf67b31499584dc8a20225e85bfe6f6cfed0 \
54+
--hash=sha256:bc67deb76bc3717f22e765ab3e07ee9c7a5e26b9019ca19a3b063d9f4b874244 \
55+
--hash=sha256:c0b1818063dc9e9d838c09e3a473c1422f517889436dd980f5d721899e66f315 \
56+
--hash=sha256:c56e097019e72c373bae32d946ecf9858fda841e48d82df7e81c63ac25554078 \
57+
--hash=sha256:c7827a5bc7bdb197b9e066cdf650b2887597ad124dd99777332776f7b7c7d0d0 \
58+
--hash=sha256:ccc2b70a7ed475c68ceb548bf69cec1e27305c1c2606a5eb7c3afff56a1b3b27 \
59+
--hash=sha256:d37a84878285b903c0fe21ac8794c6dab58150e9359f1aaebbeddd6412d53132 \
60+
--hash=sha256:e2f0280519e42b0a17550072861e0bc8a80a0870de260f9796157d3fca2733c5 \
61+
--hash=sha256:e4ae5ac5e0d1e4edfc9b4b57b4cbecd5bc266a6915c500f358817a8496739247 \
62+
--hash=sha256:e67926f51821b8e9deb6426ff3164870976fe414d033ad90ea75e7ed0c2e5022 \
63+
--hash=sha256:e78b270eadb5702938c3dbe9367f878249b5ef9a2fcc5360ac7bff694310d17b \
64+
--hash=sha256:ea3c8f04b3e4af80e17bab607c386a830ffc2fb88a5484e1df756478cf70d1d3 \
65+
--hash=sha256:ec22b5e7fe7a0fa8509181c4aac1db48f3dd4d3a566131b313d1efc102892c18 \
66+
--hash=sha256:f4f620668dbc6f5e909a0946a877310fb3d57aea8198bde792aae369ee1c23b5 \
67+
--hash=sha256:fd34e7b3405f0cc7ab03d54a334c17a9e802897580d964bd8c2001f4b9fd488f
68+
# via -r requirements.in
69+
iniconfig==2.0.0 \
70+
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
71+
--hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374
72+
# via pytest
73+
packaging==24.2 \
74+
--hash=sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759 \
75+
--hash=sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f
76+
# via pytest
77+
pluggy==1.5.0 \
78+
--hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \
79+
--hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669
80+
# via pytest
81+
pytest==8.3.4 \
82+
--hash=sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6 \
83+
--hash=sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761
84+
# via -r requirements.in

e2e/use_release/src/BUILD.bazel

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_pytest_main", "py_test")
2+
3+
py_binary(
4+
name = "main",
5+
srcs = [
6+
"__init__.py",
7+
"__main__.py",
8+
],
9+
main = "__main__.py",
10+
)
11+
12+
# TODO(alex): land https://github.com/aspect-build/rules_py/pull/401 and shorten this
13+
py_pytest_main(
14+
name = "__test__",
15+
deps = [
16+
"@pip//coverage",
17+
"@pip//pytest",
18+
],
19+
)
20+
21+
py_test(
22+
name = "test",
23+
srcs = [
24+
"my_test.py",
25+
":__test__",
26+
],
27+
main = ":__test__.py",
28+
deps = [
29+
":__test__",
30+
":main",
31+
],
32+
)
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __init__ import welcome
1+
from src import welcome
22

33
if __name__ == "__main__":
44
print(welcome("world"))

0 commit comments

Comments
 (0)