Artifact API
This reference lists attachment values, retention rules, and attachment operations.
These signatures are the public API.
Attachment
Namespace: Greenlight\Core\Artifact
Fixed metadata for one retained test attachment.
readonly class Attachment implements WireSerializable
__construct()
public function __construct(
public string $name,
public AttachmentKind $kind,
public string $mediaType,
public int $sizeBytes,
public string $sha256,
public int $attempt,
public string $path,
public AttachmentRetention $retention = AttachmentRetention::OnFailure,
)
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
AttachmentError
Namespace: Greenlight\Core\Artifact
Greenlight raises this error for invalid attachment input or an attachment storage failure.
final class AttachmentError extends \RuntimeException
unavailable()
public static function unavailable(): self
sealed()
public static function sealed(): self
invalidName()
public static function invalidName(string $name): self
invalidMediaType()
public static function invalidMediaType(string $mediaType): self
invalidValue()
public static function invalidValue(string $message): self
source()
public static function source(string $path, string $reason): self
limit()
public static function limit(string $message): self
storage()
public static function storage(string $message): self
AttachmentKind
Namespace: Greenlight\Core\Artifact
The form of attachment content that a caller supplies.
enum AttachmentKind: string
Value
case Value = 'value';
Text
case Text = 'text';
Binary
case Binary = 'binary';
File
case File = 'file';
AttachmentRetention
Namespace: Greenlight\Core\Artifact
Determines if Greenlight retains an attachment from a successful test attempt.
enum AttachmentRetention: string
OnFailure
case OnFailure = 'on-failure';
Always
case Always = 'always';
Attachments
Namespace: Greenlight\Core\Artifact
Adds structured values, text, binary data, and files to one test attempt.
Implementations copy input immediately. The attachment store saves content separately. Test results contain only metadata and published paths.
interface Attachments
value()
public function value(
string $name,
mixed $value,
AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;
text()
public function text(
string $name,
string $text,
string $mediaType = 'text/plain; charset=utf-8',
AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;
bytes()
public function bytes(
string $name,
string $bytes,
string $mediaType = 'application/octet-stream',
AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;
file()
public function file(
string $name,
string $sourcePath,
?string $mediaType = null,
AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;