• 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/backend/cc/goals/tailor.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
1✔
5

6
from collections.abc import Iterable
1✔
7
from dataclasses import dataclass
1✔
8

9
from pants.backend.cc.target_types import CC_FILE_EXTENSIONS, CCSourcesGeneratorTarget
1✔
10
from pants.core.goals.tailor import (
1✔
11
    AllOwnedSources,
12
    PutativeTarget,
13
    PutativeTargets,
14
    PutativeTargetsRequest,
15
)
16
from pants.engine.intrinsics import path_globs_to_paths
1✔
17
from pants.engine.rules import collect_rules, rule
1✔
18
from pants.engine.target import Target
1✔
19
from pants.engine.unions import UnionRule
1✔
20
from pants.util.dirutil import group_by_dir
1✔
21
from pants.util.logging import LogLevel
1✔
22

23

24
@dataclass(frozen=True)
1✔
25
class PutativeCCTargetsRequest(PutativeTargetsRequest):
1✔
26
    pass
1✔
27

28

29
def classify_source_files(paths: Iterable[str]) -> dict[type[Target], set[str]]:
1✔
30
    """Returns a dict of target type -> files that belong to targets of that type."""
31
    sources_files = set(paths)
1✔
32
    return {CCSourcesGeneratorTarget: sources_files}
1✔
33

34

35
@rule(level=LogLevel.DEBUG, desc="Determine candidate CC targets to create")
1✔
36
async def find_putative_targets(
1✔
37
    req: PutativeCCTargetsRequest,
38
    all_owned_sources: AllOwnedSources,
39
) -> PutativeTargets:
40
    all_cc_files = await path_globs_to_paths(
1✔
41
        req.path_globs(*(f"*{ext}" for ext in CC_FILE_EXTENSIONS))
42
    )
43
    unowned_cc_files = set(all_cc_files.files) - set(all_owned_sources)
1✔
44
    classified_unowned_kotlin_files = classify_source_files(unowned_cc_files)
1✔
45

46
    putative_targets: list[PutativeTarget] = []
1✔
47
    for tgt_type, paths in classified_unowned_kotlin_files.items():
1✔
48
        for dirname, filenames in group_by_dir(paths).items():
1✔
49
            putative_targets.append(
1✔
50
                PutativeTarget.for_target_type(
51
                    tgt_type, path=dirname, name=None, triggering_sources=sorted(filenames)
52
                )
53
            )
54

55
    return PutativeTargets(putative_targets)
1✔
56

57

58
def rules():
1✔
59
    return [
1✔
60
        *collect_rules(),
61
        UnionRule(PutativeTargetsRequest, PutativeCCTargetsRequest),
62
    ]
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