cispacempt
v0.0.6
Published
Fast, open-source, local-and-cloud, CI/CD by CodespaceMPT.
Readme
CodespaceMPT CI
CodespaceMPT CI (CISpaceMPT) is a fast, efficient, and scalable Continuous Integration (CI) server that automates the execution of scripts in various stages of your CI pipeline. It is designed to integrate seamlessly with your repository, run defined commands, and log detailed results.
Installation
How It Works
CI Script Structure
Your CI pipeline is defined in a JSON-based script. Each CI script contains several stages, each with its own set of commands to run. Below is an example of how to structure the CI script:
{
"stages": {
"build": {
"scripts": [
"npm install",
"npm run build"
]
},
"test": {
"scripts": [
"npm test"
]
}
}
}- stages: Defines the different stages of the CI pipeline.
- scripts: Lists the commands to be executed in each stage.
Execution Flow
- Clone Repository: The CI server clones the repository and checks out the required branch.
- Parse Directory: The file system of the repository is recursively traversed (excluding
node_modules), capturing the directory structure and content. - Stage Execution: For each stage defined in the CI script, the server executes the specified commands sequentially.
- Log Results: The output (stdout, stderr) from each command is captured and logged along with any errors and exit codes.
- Time Tracking: The duration of the CI process is calculated and logged.
- Clean-up: Once the pipeline is complete, temporary directories are deleted.
Example Usage
Here’s how you can use the parse function to execute a CI script:
const ci = require('cispacempt');
// Sample CI script
const ciScript = {
stages: {
"build": {
scripts: [
"npm install",
"npm run build"
]
},
"test": {
scripts: [
"npm test"
]
}
}
};
// Repository name
const repoName = "my-repo";
// File system content to be used during execution
const fileSystem = {/* your repository's file system in a json */};
ci.parse(ciScript, repoName, fileSystem, true)
.then(result => {
console.log("CI Log Result:", result);
})
.catch(err => {
console.error("CI process failed:", err);
});Output
The parse function returns an object containing the CI process result:
{
"output": "CI logs for each stage",
"timestamp": "2025-04-14 12:00:00",
"fileSys": { /* Parsed file system after ci */ },
"ci_duration": "10.23", // Duration in seconds
"exitCode": 0 // Exit code (0 for success, non-zero for failure)
}- output: Logs from each stage.
- timestamp: The timestamp of when the CI process was run.
- fileSys: A JSON object representing the repository’s file structure.
- ci_duration: Total time taken for the CI process (in seconds).
- exitCode: The exit code from the final stage (0 if all commands succeed).
Clean-Up
After the execution, temporary directories are automatically cleaned up to save disk space.
License
This project is licensed under the MIT License - see the LICENSE file for details.
