• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 19186107394
80%

Build:
DEFAULT BRANCH: main
Ran 08 Nov 2025 01:57AM UTC
Jobs 12
Files 1718
Run time 3min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

08 Nov 2025 01:49AM UTC coverage: 80.298% (-0.01%) from 80.31%
19186107394

push

github

web-flow
nfpm: support chaining multiple `InjectNfpmPackageFieldsRequest`s (sorted w/ simple priority integer) (#22864)

This extends then `pants.backend.experimental.nfpm` backend's plugin
API, allowing multiple implementations of this polymorphic-rule plugin
hook (before this change, only one implementation was allowed):

- `inject_nfpm_package_fields(InjectNfpmPackageFieldsRequest) -> InjectedNfpmPackageFields`

Unlike many polymorphic/union rules, each rule runs sequentially instead
of concurrently. This is conceptually similar to middleware, because the
request passed to each rule includes the results of the previous (lower
priority) rule. So, one rule can override or extend fields that were
injected in previous rules, not just the original fields from the
BUILD-file-based `nfpm_*_package` target.

I tried several approaches to sorting the request classes, but most were
error prone or simply didn't work. Heuristic-based sorting proved to be
complex and didn't work in all of my test cases (eg one heuristic was
looking at the class's module to make pants-provided requests lower
priority). A simple `priority` integer is far simpler and more reliable,
so that's what this implements.

Another thing that didn't work was adding `__lt__` as a `@classmethod`
on the abstract `InjectNfpmPackageFieldsRequest`. That fails because
`sorted()` requires an instance method, not a class method. The only way
I found to add an `__lt__` method on a class is via a metaclass. So,
this adds a `_PrioritizedSortableClassMetaclass` to
`InjectNfpmPackageFieldsRequest` allowing for simple `OneRequest <
TwoRequest` sorting of the class type like this:

```diff
     inject_nfpm_config_request_types = union_membership.get(InjectNfpmPackageFieldsRequest)
     applicable_inject_nfpm_config_request_types = tuple(
-        request
-        for request in inject_nfpm_config_request_types
-        if request.is_applicable(target)
+        sorted(
+            request_type
+            for requ... (continued)

41 of 74 new or added lines in 2 files covered. (55.41%)

1 existing line in 1 file now uncovered.

78098 of 97260 relevant lines covered (80.3%)

3.36 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
13
66.67
5.13% src/python/pants/backend/nfpm/util_rules/inject_config.py
20
69.33
-19.86% src/python/pants/backend/nfpm/util_rules/inject_config_test.py

Uncovered Existing Lines

Lines Coverage ∆ File
1
69.33
-19.86% src/python/pants/backend/nfpm/util_rules/inject_config_test.py
Jobs
ID Job ID Ran Files Coverage
1 test_python_linux_x86_64_4/10 - 19186107394.1 08 Nov 2025 02:07AM UTC 1210
49.91
GitHub Action Run
2 test_python_linux_x86_64_3/10 - 19186107394.2 08 Nov 2025 02:00AM UTC 1177
45.68
GitHub Action Run
3 test_python_linux_x86_64_8/10 - 19186107394.3 08 Nov 2025 02:03AM UTC 1180
45.42
GitHub Action Run
4 test_python_macos14_arm64 - 19186107394.4 08 Nov 2025 02:03AM UTC 1162
43.25
GitHub Action Run
5 test_python_linux_x86_64_0/10 - 19186107394.5 08 Nov 2025 02:00AM UTC 1199
46.89
GitHub Action Run
6 test_python_linux_x86_64_1/10 - 19186107394.6 08 Nov 2025 02:00AM UTC 1177
40.2
GitHub Action Run
7 test_python_linux_x86_64_5/10 - 19186107394.7 08 Nov 2025 01:58AM UTC 1194
48.13
GitHub Action Run
8 test_python_linux_x86_64_7/10 - 19186107394.8 08 Nov 2025 02:02AM UTC 1184
42.67
GitHub Action Run
9 test_python_linux_x86_64_2/10 - 19186107394.9 08 Nov 2025 01:58AM UTC 1180
46.91
GitHub Action Run
10 test_python_linux_arm64 - 19186107394.10 08 Nov 2025 02:02AM UTC 1162
43.24
GitHub Action Run
11 test_python_linux_x86_64_6/10 - 19186107394.11 08 Nov 2025 01:57AM UTC 1174
40.76
GitHub Action Run
12 test_python_linux_x86_64_9/10 - 19186107394.12 08 Nov 2025 02:03AM UTC 1185
45.06
GitHub Action Run
Source Files on build 19186107394
  • Tree
  • List 1718
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #19186107394
  • a20fa8db on github
  • Prev Build on main (#19184165478)
  • Next Build on main (#19197356939)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc