• 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/lint/clangformat/rules.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
import logging
1✔
7
from collections.abc import Iterable
1✔
8
from dataclasses import dataclass
1✔
9

10
from pants.backend.cc.lint.clangformat.subsystem import ClangFormat
1✔
11
from pants.backend.cc.target_types import CCSourceField
1✔
12
from pants.backend.python.util_rules.pex import PexProcess, create_pex
1✔
13
from pants.core.goals.fmt import FmtResult, FmtTargetsRequest
1✔
14
from pants.core.util_rules.config_files import find_config_file
1✔
15
from pants.core.util_rules.partitions import PartitionerType
1✔
16
from pants.engine.fs import MergeDigests
1✔
17
from pants.engine.intrinsics import merge_digests
1✔
18
from pants.engine.process import fallible_to_exec_result_or_raise
1✔
19
from pants.engine.rules import Rule, collect_rules, concurrently, implicitly, rule
1✔
20
from pants.engine.target import FieldSet
1✔
21
from pants.engine.unions import UnionRule
1✔
22
from pants.util.logging import LogLevel
1✔
23
from pants.util.strutil import pluralize
1✔
24

25
logger = logging.getLogger(__name__)
1✔
26

27

28
@dataclass(frozen=True)
1✔
29
class ClangFormatFmtFieldSet(FieldSet):
1✔
30
    required_fields = (CCSourceField,)
1✔
31

32
    sources: CCSourceField
1✔
33

34

35
class ClangFormatRequest(FmtTargetsRequest):
1✔
36
    field_set_type = ClangFormatFmtFieldSet
1✔
37
    tool_subsystem = ClangFormat  # type: ignore[assignment]
1✔
38
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
1✔
39

40

41
@rule(level=LogLevel.DEBUG)
1✔
42
async def clangformat_fmt(request: ClangFormatRequest.Batch, clangformat: ClangFormat) -> FmtResult:
1✔
43
    clangformat_pex, config_files = await concurrently(
1✔
44
        create_pex(clangformat.to_pex_request()),
45
        find_config_file(clangformat.config_request(request.snapshot.dirs)),
46
    )
47

48
    # Merge source files, config files, and clang-format pex process
49
    input_digest = await merge_digests(
1✔
50
        MergeDigests(
51
            [request.snapshot.digest, config_files.snapshot.digest, clangformat_pex.digest]
52
        )
53
    )
54

55
    argv = (
1✔
56
        "--style=file",  # Look for .clang-format files
57
        "--fallback-style=webkit",  # Use WebKit if there is no config file
58
        "-i",  # In-place edits
59
        "--Werror",  # Formatting warnings as errors
60
        *clangformat.args,  # User-added arguments
61
        *request.files,
62
    )
63
    result = await fallible_to_exec_result_or_raise(
1✔
64
        **implicitly(
65
            PexProcess(
66
                clangformat_pex,
67
                argv=argv,
68
                input_digest=input_digest,
69
                output_files=request.files,
70
                description=f"Run clang-format on {pluralize(len(request.files), 'file')}.",
71
                level=LogLevel.DEBUG,
72
            )
73
        ),
74
    )
75

76
    return await FmtResult.create(request, result)
1✔
77

78

79
def rules() -> Iterable[Rule | UnionRule]:
1✔
80
    return (
1✔
81
        *collect_rules(),
82
        *ClangFormatRequest.rules(),
83
    )
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