• 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

93.33
/src/python/pants/bsp/spec/task.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3
from __future__ import annotations
2✔
4

5
from dataclasses import dataclass
2✔
6
from enum import Enum
2✔
7
from typing import Any
2✔
8

9
from pants.bsp.spec.base import StatusCode, TaskId
2✔
10
from pants.bsp.spec.compile import CompileReport, CompileTask
2✔
11
from pants.bsp.spec.notification import BSPNotification
2✔
12

13
# -----------------------------------------------------------------------------------------------
14
# Task Notifications
15
# See https://build-server-protocol.github.io/docs/specification.html#compile-request
16
# -----------------------------------------------------------------------------------------------
17

18

19
class TaskDataKind(Enum):
2✔
20
    # `data` field must contain a CompileTask object.
21
    COMPILE_TASK = "compile-task"
2✔
22

23
    #  `data` field must contain a CompileReport object.
24
    COMPILE_REPORT = "compile-report"
2✔
25

26
    # `data` field must contain a TestTask object.
27
    TEST_TASK = "test-task"
2✔
28

29
    # `data` field must contain a TestReport object.
30
    TEST_REPORT = "test-report"
2✔
31

32
    # `data` field must contain a TestStart object.
33
    TEST_START = "test-start"
2✔
34

35
    # `data` field must contain a TestFinish object.
36
    TEST_FINISH = "test-finish"
2✔
37

38

39
@dataclass(frozen=True)
2✔
40
class TaskStartParams(BSPNotification):
2✔
41
    notification_name = "build/taskStart"
2✔
42

43
    # Unique id of the task with optional reference to parent task id
44
    task_id: TaskId
2✔
45

46
    # Timestamp of when the event started in milliseconds since Epoch.
47
    event_time: int | None = None
2✔
48

49
    # Message describing the task.
50
    message: str | None = None
2✔
51

52
    # Task-specific data.
53
    # Note: This field is serialized as two fields: `dataKind` (for type name) and `data`.
54
    data: CompileTask | None = None
2✔
55

56
    def to_json_dict(self) -> dict[str, Any]:
2✔
57
        result: dict[str, Any] = {"taskId": self.task_id.to_json_dict()}
1✔
58
        if self.event_time is not None:
1✔
59
            result["eventTime"] = self.event_time
1✔
60
        if self.message is not None:
1✔
61
            result["message"] = self.message
1✔
62
        if self.data is not None:
1✔
63
            if isinstance(self.data, CompileTask):
1✔
64
                result["dataKind"] = TaskDataKind.COMPILE_TASK.value
1✔
65
            else:
66
                raise AssertionError(
×
67
                    f"TaskStartParams contained an unexpected instance: {self.data}"
68
                )
69
            result["data"] = self.data.to_json_dict()
1✔
70
        return result
1✔
71

72

73
@dataclass(frozen=True)
2✔
74
class TaskProgressParams(BSPNotification):
2✔
75
    notification_name = "build/taskProgress"
2✔
76

77
    # Unique id of the task with optional reference to parent task id
78
    task_id: TaskId
2✔
79

80
    # Timestamp of when the progress event was generated in milliseconds since Epoch.
81
    event_time: int | None = None
2✔
82

83
    # Message describing the task progress.
84
    # Information about the state of the task at the time the event is sent.
85
    message: str | None = None
2✔
86

87
    # If known, total amount of work units in this task.
88
    total: int | None = None
2✔
89

90
    # If known, completed amount of work units in this task.
91
    progress: int | None = None
2✔
92

93
    # Name of a work unit. For example, "files" or "tests". May be empty.
94
    unit: str | None = None
2✔
95

96
    # TODO: `data` field is not currently represented. Once we know what types will be sent, then it can be bound.
97

98
    def to_json_dict(self) -> dict[str, Any]:
2✔
99
        result: dict[str, Any] = {"taskId": self.task_id.to_json_dict()}
1✔
100
        if self.event_time is not None:
1✔
101
            result["eventTime"] = self.event_time
1✔
102
        if self.message is not None:
1✔
103
            result["message"] = self.message
1✔
104
        if self.total is not None:
1✔
105
            result["total"] = self.total
×
106
        if self.progress is not None:
1✔
107
            result["progress"] = self.progress
×
108
        if self.unit is not None:
1✔
109
            result["unit"] = self.unit
×
110
        return result
1✔
111

112

113
@dataclass(frozen=True)
2✔
114
class TaskFinishParams(BSPNotification):
2✔
115
    notification_name = "build/taskFinish"
2✔
116

117
    # Unique id of the task with optional reference to parent task id
118
    task_id: TaskId
2✔
119

120
    # Timestamp of the event in milliseconds.
121
    event_time: int | None = None
2✔
122

123
    # Message describing the finish event.
124
    message: str | None = None
2✔
125

126
    # Task completion status.
127
    status: StatusCode = StatusCode.OK
2✔
128

129
    # Task-specific data.
130
    # Note: This field is serialized as two fields: `dataKind` (for type name) and `data`.
131
    data: CompileReport | None = None
2✔
132

133
    def to_json_dict(self) -> dict[str, Any]:
2✔
134
        result: dict[str, Any] = {
1✔
135
            "taskId": self.task_id.to_json_dict(),
136
            "status": self.status.value,
137
        }
138
        if self.event_time is not None:
1✔
139
            result["eventTime"] = self.event_time
1✔
140
        if self.message is not None:
1✔
141
            result["message"] = self.message
1✔
142
        if self.data is not None:
1✔
143
            if isinstance(self.data, CompileReport):
1✔
144
                result["dataKind"] = TaskDataKind.COMPILE_REPORT.value
1✔
145
            else:
146
                raise AssertionError(
×
147
                    f"TaskFinishParams contained an unexpected instance: {self.data}"
148
                )
149
            result["data"] = self.data.to_json_dict()
1✔
150
        return result
1✔
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