Browse documentation

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

View source

__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,
)

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

AttachmentError

Namespace: Greenlight\Core\Artifact

Greenlight raises this error for invalid attachment input or an attachment storage failure.

final class AttachmentError extends \RuntimeException

View source

unavailable()

public static function unavailable(): self

View source

sealed()

public static function sealed(): self

View source

invalidName()

public static function invalidName(string $name): self

View source

invalidMediaType()

public static function invalidMediaType(string $mediaType): self

View source

invalidValue()

public static function invalidValue(string $message): self

View source

source()

public static function source(string $path, string $reason): self

View source

limit()

public static function limit(string $message): self

View source

storage()

public static function storage(string $message): self

View source

AttachmentKind

Namespace: Greenlight\Core\Artifact

The form of attachment content that a caller supplies.

enum AttachmentKind: string

View source

Value

case Value = 'value';

View source

Text

case Text = 'text';

View source

Binary

case Binary = 'binary';

View source

File

case File = 'file';

View source

AttachmentRetention

Namespace: Greenlight\Core\Artifact

Determines if Greenlight retains an attachment from a successful test attempt.

enum AttachmentRetention: string

View source

OnFailure

case OnFailure = 'on-failure';

View source

Always

case Always = 'always';

View source

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

View source

value()

public function value(
    string $name,
    mixed $value,
    AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;

View source

text()

public function text(
    string $name,
    string $text,
    string $mediaType = 'text/plain; charset=utf-8',
    AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;

View source

bytes()

public function bytes(
    string $name,
    string $bytes,
    string $mediaType = 'application/octet-stream',
    AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;

View source

file()

public function file(
    string $name,
    string $sourcePath,
    ?string $mediaType = null,
    AttachmentRetention $retention = AttachmentRetention::OnFailure,
): void;

View source