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

pantsbuild / pants / 25441711719

06 May 2026 02:31PM UTC coverage: 92.915%. Remained the same
25441711719

push

github

web-flow
use sha pin (with comment) format for generated actions (#23312)

Per the GitHub Action best practices we recently enabled at #23249, we
should pin each action to a SHA so that the reference is actually
immutable.

This will -- I hope -- knock out a large chunk of the 421 alerts we
currently get from zizmor. The next followup would then be upgrades and
harmonizing the generated and none-generated pins.

Notice: This idea was suggested by Claude while going over pinact output
and I was surprised to see that post processing the yaml wasn't too
gross.

92206 of 99237 relevant lines covered (92.91%)

4.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/python/pants/jvm/bsp/resources.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from pants.base.build_root import BuildRoot
2✔
5
from pants.bsp.spec.base import BuildTargetIdentifier
2✔
6
from pants.bsp.util_rules.targets import BSPResourcesRequest, BSPResourcesResult
2✔
7
from pants.core.target_types import ResourceSourceField
2✔
8
from pants.core.util_rules import stripped_source_files
2✔
9
from pants.core.util_rules.source_files import SourceFilesRequest
2✔
10
from pants.core.util_rules.stripped_source_files import strip_source_roots
2✔
11
from pants.engine.addresses import Addresses
2✔
12
from pants.engine.fs import AddPrefix
2✔
13
from pants.engine.internals.graph import resolve_coarsened_targets
2✔
14
from pants.engine.intrinsics import add_prefix
2✔
15
from pants.engine.rules import collect_rules, implicitly
2✔
16
from pants.engine.target import SourcesField
2✔
17
from pants.util.strutil import path_safe
2✔
18

19

20
def _jvm_resources_directory(target_id: BuildTargetIdentifier) -> str:
2✔
21
    # TODO: Currently, we have a single BuildTarget per group, and so we include the transitive
22
    # resource dependencies in one owning directory. As part of #15051 we'll likely need to find
23
    # "owning" BuildTargets for each resources target in order to avoid having all of them
24
    # emit the transitive resources.
25
    return f"jvm/resources/{path_safe(target_id.uri)}"
1✔
26

27

28
async def _jvm_bsp_resources(
2✔
29
    request: BSPResourcesRequest,
30
    build_root: BuildRoot,
31
) -> BSPResourcesResult:
32
    """Generically handles a BSPResourcesRequest (subclass).
33

34
    This is a rule helper rather than a `@rule` for the same reason as `_jvm_bsp_compile`.
35
    """
36
    coarsened_tgts = await resolve_coarsened_targets(
1✔
37
        **implicitly(Addresses([fs.address for fs in request.field_sets]))
38
    )
39

40
    source_files = await strip_source_roots(
1✔
41
        **implicitly(
42
            SourceFilesRequest(
43
                [tgt.get(SourcesField) for tgt in coarsened_tgts.closure()],
44
                for_sources_types=(ResourceSourceField,),
45
                enable_codegen=True,
46
            )
47
        )
48
    )
49

50
    rel_resources_dir = _jvm_resources_directory(request.bsp_target.bsp_target_id)
1✔
51
    output_digest = await add_prefix(
1✔
52
        AddPrefix(source_files.snapshot.digest, rel_resources_dir),
53
    )
54

55
    return BSPResourcesResult(
1✔
56
        resources=(
57
            # NB: IntelliJ requires that directory URIs end in slashes.
58
            build_root.pathlib_path.joinpath(".pants.d/bsp", rel_resources_dir).as_uri() + "/",
59
        ),
60
        output_digest=output_digest,
61
    )
62

63

64
def rules():
2✔
65
    return [
2✔
66
        *collect_rules(),
67
        *stripped_source_files.rules(),
68
    ]
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

© 2026 Coveralls, Inc