Table of Contents

Class WorkflowFileWriter<T>

Namespace
Invex.Atom.Workflows.Writer
Assembly
Invex.Atom.Workflows.dll

An abstract base class for generating platform-specific workflow files (e.g., for GitHub Actions or Azure DevOps).

public abstract class WorkflowFileWriter<T> : IWorkflowWriter<T>, IWorkflowWriter where T : IWorkflowType

Type Parameters

T

The workflow type this writer handles, which must implement IWorkflowType.

Inheritance
object
WorkflowFileWriter<T>
Implements

Remarks

This class provides a template for writing structured workflow files, handling file I/O, change detection, and indentation. Concrete implementations must override WriteWorkflow(WorkflowModel) to define the specific file format and FileExtension to specify the file extension.

Constructors

WorkflowFileWriter(IRootedFileSystem, ILogger<WorkflowFileWriter<T>>)

An abstract base class for generating platform-specific workflow files (e.g., for GitHub Actions or Azure DevOps).

protected WorkflowFileWriter(IRootedFileSystem fileSystem, ILogger<WorkflowFileWriter<T>> logger)

Parameters

fileSystem IRootedFileSystem

The file system service for file operations.

logger ILogger<WorkflowFileWriter<T>>

The logger for diagnostics.

Remarks

This class provides a template for writing structured workflow files, handling file I/O, change detection, and indentation. Concrete implementations must override WriteWorkflow(WorkflowModel) to define the specific file format and FileExtension to specify the file extension.

Properties

FileExtension

Gets the file extension for the generated workflow file (e.g., "yml").

protected abstract string FileExtension { get; }

Property Value

string

FileLocation

Gets the root directory where workflow files should be generated. Defaults to the Atom root directory.

protected virtual RootedPath FileLocation { get; }

Property Value

RootedPath

TabSize

Gets the number of spaces to use for each indentation level. Defaults to 2.

protected virtual int TabSize { get; }

Property Value

int

Methods

CheckForOutdatedWorkflow(WorkflowModel, CancellationToken)

Checks if the existing workflow file is outdated and needs to be regenerated.

public virtual Task<bool> CheckForOutdatedWorkflow(WorkflowModel workflow, CancellationToken cancellationToken = default)

Parameters

workflow WorkflowModel

The workflow model to compare against the existing file.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<bool>

true if the workflow file is missing or outdated; otherwise, false.

Generate(WorkflowModel, CancellationToken)

Generates a workflow file from the provided model, writing it only if the content has changed.

public Task Generate(WorkflowModel workflow, CancellationToken cancellationToken = default)

Parameters

workflow WorkflowModel

The workflow model to generate.

cancellationToken CancellationToken

A cancellation token.

Returns

Task

WriteWorkflow(WorkflowModel)

When overridden in a derived class, writes the content of the workflow file using the provided helper methods.

protected abstract string WriteWorkflow(WorkflowModel workflow)

Parameters

workflow WorkflowModel

The workflow model to write.

Returns

string