cloudbuild-task-contracts
v0.1.185-beta
Published
Abstractions that most/all cloud build services can fulfill in order to allow the development of tasks for submission to the various cloud build marketplaces while maintaining primarily just one codebase.
Downloads
8
Readme
cloudbuild-task-contracts
This package defines a common abstraction around potentially any cloud build (PR/CI build system) that defines special 'tasks' that may take inputs and perform built-in operations.
This abstraction allows a task to be written just once against the abstraction and then built for many CI systems.
Example adapter packages include support for:
- GitHub Actions
- Azure Pipelines
- Local runner which lets you run/test your task locally (with no CI system at all).
Example usage
Write your task's function without a dependency on GitHub Actions, Azure Pipelines, or any other CI specific NPM package, leveraging this abstraction package:
import { CloudTask } from 'cloudbuild-task-contracts';
export function run(cloudTask: CloudTask) {
const name = cloudTask.inputs.getInput('name');
cloudTask.log.error(`That is not an acceptable name: ${name}.`);
cloudTask.result.setFailed('Invalid input parameter.');
}
The above is just a small sampling of the APIs available through this abstraction.
When it's time to run this task within a particular CI system, it's trivially easy. For example, running the above task as a GitHub Action is as simple as this:
import { factory } from 'cloudbuild-task-github-actions';
import { run } from './MyPortableTask';
run(factory);