Class WorkflowFileWriter<T>
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
TThe workflow type this writer handles, which must implement IWorkflowType.
- Inheritance
-
objectWorkflowFileWriter<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
fileSystemIRootedFileSystemThe file system service for file operations.
loggerILogger<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
workflowWorkflowModelThe workflow model to compare against the existing file.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<bool>
trueif 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
workflowWorkflowModelThe workflow model to generate.
cancellationTokenCancellationTokenA 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
workflowWorkflowModelThe workflow model to write.
Returns
- string