Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server post #24

Merged
merged 7 commits into from
Dec 2, 2024
Merged

Server post #24

merged 7 commits into from
Dec 2, 2024

Conversation

kris-hansen
Copy link
Owner

@kris-hansen kris-hansen commented Dec 1, 2024

PR Type:

Enhancement


PR Description:

  • Implemented support for STDIN input in server mode, allowing workflows to accept input via POST requests.
  • Enhanced server to list available YAML files with their supported HTTP methods (GET or GET,POST).
  • Added GitHub Actions for automated testing and building release binaries across multiple platforms.
  • Updated documentation to reflect new server capabilities and installation instructions.
  • Provided examples demonstrating server functionality and STDIN input usage.

PR Main Files Walkthrough:

files:
  • cmd/process.go: Added logic to check for and read data from STDIN, storing it for use in processing YAML files. If STDIN data is present, it is set as the initial output for the processor.
  • cmd/serve.go: Introduced a function to check if a YAML file uses STDIN as input. Modified the server to allow POST requests for such files and updated the list endpoint to show supported methods for each file.
  • utils/input/handler.go: Added a new input type for STDIN and a method to handle STDIN input, storing it in the handler's input list.
  • utils/processor/dsl.go: Added a method to set the last output of the processor, enabling initialization with STDIN data.
  • .github/workflows/release.yml: Created a GitHub Actions workflow for building and releasing binaries. It includes steps for testing, version bumping, and creating release artifacts for multiple platforms.
  • README.md: Updated to include new server capabilities, installation instructions for pre-built binaries, and details on using POST requests with the server.
  • examples/README.md: Added descriptions and usage instructions for new server examples, specifically focusing on STDIN input handling.
  • examples/server-examples/stdin-example.yaml: Provided a new example YAML file demonstrating the use of STDIN input, which can be processed via POST requests to the server.

User Description:

  • when running in serve mode, comanda now accepts input for those workflow yaml files which indicate STDIN as the first step input
  • adjusted the parser and handler so that this also unlocks 'pipe to comanda' in the command line - e.g., cat text.txt|commanda process stdin-example.yaml
  • added documentation for the server feature
  • added github actions for release builds
  • mentioned the builds in the README

@preston-ai preston-ai bot added enhancement New feature or request Review effort [1-5]: 3 labels Dec 1, 2024
Copy link

preston-ai bot commented Dec 1, 2024

PR Analysis

  • 🎯 Main theme: This PR enhances the server functionality by adding support for STDIN input, allowing workflows to accept input via POST requests. It also updates the server to list available YAML files with their supported HTTP methods and introduces GitHub Actions for automated testing and building release binaries.
  • 📝 PR summary: The PR implements support for STDIN input in server mode, enabling workflows to accept input through POST requests. It enhances the server to list YAML files with their supported HTTP methods and adds GitHub Actions for automated testing and building release binaries. Documentation and examples are updated to reflect these new capabilities.
  • 📌 Type of PR: Enhancement
  • 🏅 Score: 85
  • 🧪 Relevant tests added: False
  • Focused PR: yes, because the changes are centered around enhancing server capabilities with STDIN input and improving the build process.
  • ⏱️ Estimated effort to review [1-5]: 3, because the PR introduces significant changes to server functionality and build processes, requiring a detailed review of multiple files and logic.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR introduces valuable enhancements to the server functionality, particularly with the addition of STDIN input handling and POST request support. However, it would be beneficial to include relevant tests to ensure the new features work as expected and to prevent potential regressions in the future.

How to use

Instructions

To invoke the Preston AI, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.

func hasStdinInput(yamlContent []byte) bool {
// Parse YAML as a map to handle top-level keys as steps
var yamlMap map[string]map[string]interface{}
if err := yaml.Unmarshal(yamlContent, &yamlMap); err != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the hasStdinInput function, consider logging or handling the error from yaml.Unmarshal to provide better insights into potential parsing issues. [medium]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to make better parser feedback a focus on a coming soon PR - needs more focus throughout

@kris-hansen kris-hansen merged commit ee20a20 into main Dec 2, 2024
@kris-hansen kris-hansen deleted the server-post branch December 11, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant