Skip to content

feat(update-offer): add action to update existing SPCTL offers with new configuration#19

Open
DmitrySmv wants to merge 4 commits intov1from
feature/SP-6620
Open

feat(update-offer): add action to update existing SPCTL offers with new configuration#19
DmitrySmv wants to merge 4 commits intov1from
feature/SP-6620

Conversation

@DmitrySmv
Copy link
Contributor

@DmitrySmv DmitrySmv commented Jun 19, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a new GitHub Action to update an existing SPCTL offer using a provided configuration file, with input validation and environment checks.
    • Added comprehensive documentation with usage examples and developer instructions.

@coderabbitai
Copy link

coderabbitai bot commented Jun 19, 2025

"""

Walkthrough

A new composite GitHub Action named "Update offer" has been introduced. It takes inputs for an SPCTL config file, offer ID, and a new configuration file, validates the configuration, and updates an existing SPCTL offer using the provided files and parameters.

Changes

File(s) Change Summary
actions/update-offer/action.yml Added a new GitHub Action to update an SPCTL offer with inputs and Node.js 20 runtime configuration.
actions/update-offer/index.js Added script to validate inputs, parse JSON config, and execute the spctl offers update command.
actions/update-offer/package.json Added Node.js project metadata and dependencies for the update-offer action.
actions/update-offer/README.md Added documentation for the update-offer action including usage, inputs, and developer instructions.
.gitignore Added .gitignore to exclude node_modules directory.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Actions Runner
    participant SPCTL CLI

    User->>GitHub Actions Runner: Trigger "Update offer" action with inputs
    GitHub Actions Runner->>GitHub Actions Runner: Check SPCTL environment
    GitHub Actions Runner->>GitHub Actions Runner: Validate configuration file (existence, JSON)
    alt Validation fails
        GitHub Actions Runner->>User: Exit with error
    else Validation succeeds
        GitHub Actions Runner->>SPCTL CLI: Run `spctl offers update` with offer ID and config files
        SPCTL CLI-->>GitHub Actions Runner: Update result
        GitHub Actions Runner->>User: Output success message
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Store the solution configuration close to the solution code (SP-6620)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

🐇
In the garden of code where the offers grow,
A new action hops in, quick as a doe.
It checks and it updates, with JSON in tow,
Keeping configs close—just as we know!
With every commit, solutions bloom bright,
The rabbit approves: "All is right!"
🌱✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5bd9bc9 and b6225b5.

⛔ Files ignored due to path filters (1)
  • actions/update-offer/dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • actions/update-offer/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • actions/update-offer/package.json

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
actions/update-offer/action.yml (1)

44-52: Fix the SPCTL update invocation.

The command ./spctl offers update value ${{ inputs.offer_id }} incorrectly injects the literal value and invokes a local binary. It should call the installed spctl directly and omit value.

Apply this diff:

-        ./spctl offers update value ${{ inputs.offer_id }} --configuration ${{ inputs.configuration_file_path }} --config ${{ inputs.spctl_config_file }}
+        spctl offers update ${{ inputs.offer_id }} \
+          --configuration "${{ inputs.configuration_file_path }}" \
+          --config "${{ inputs.spctl_config_file }}"
🧹 Nitpick comments (4)
actions/update-offer/action.yml (4)

1-3: Ensure consistent quoting style.

You use single quotes for name but double quotes for description. For better readability and consistency, standardize on one quoting style (e.g., double quotes) throughout the YAML.


5-13: Harmonize input naming and validate SPCTL config.

  1. The inputs spctl_config_file vs configuration_file_path could be unified (e.g., both ending in _file or _path) for consistency.
  2. Consider adding a validation step for the spctl_config_file (analogous to the configuration file) to catch missing or invalid config early.

23-43: Scope validation is clear—but consider stricter shell settings.

The file existence and JSON checks are well-structured. To catch unbound variables or pipeline errors, you might add at the top of the script:

set -euxo pipefail

This ensures the step fails fast on undefined variables or pipeline failures.


15-52: Consider exposing outputs from this composite action.

It may be useful to define outputs (e.g., the offer_id or a success flag) so downstream steps can reference the updated offer.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86ef837 and eef0bc0.

📒 Files selected for processing (1)
  • actions/update-offer/action.yml (1 hunks)
🔇 Additional comments (1)
actions/update-offer/action.yml (1)

18-22: Check SPCTL action usage is correct.

The existing check-spctl@v1 step looks good and properly passes the spctl_config_file input.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
actions/update-offer/index.js (1)

16-21: Enhance JSON validation with structure checking.

While basic JSON validation is good, consider validating the expected structure/schema of the configuration file to catch configuration errors early.

 try {
-  JSON.parse(fs.readFileSync(configFilePath, 'utf8'));
+  const config = JSON.parse(fs.readFileSync(configFilePath, 'utf8'));
+  // Add basic structure validation
+  if (!config || typeof config !== 'object') {
+    throw new Error('Configuration must be a valid JSON object');
+  }
   core.info('✅ File content is valid JSON.');
 } catch (error) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eef0bc0 and 9b7ad18.

⛔ Files ignored due to path filters (1)
  • actions/update-offer/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • .gitignore (1 hunks)
  • actions/update-offer/action.yml (1 hunks)
  • actions/update-offer/index.js (1 hunks)
  • actions/update-offer/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .gitignore
  • actions/update-offer/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • actions/update-offer/action.yml
🔇 Additional comments (2)
actions/update-offer/index.js (2)

1-3: LGTM! Clean imports setup.

The required dependencies are properly imported for GitHub Actions functionality.


35-37: LGTM! Proper error handling implementation.

The error handling correctly uses core.setFailed() to report failures to the GitHub Actions runtime.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
actions/update-offer/README.md (2)

57-60: Ensure consistent casing for the spctl utility
The step title uses "SPCTL" in all caps, while elsewhere the utility is referenced as spctl. Use backticks and a consistent lowercase form (e.g., spctl) for clarity.


75-81: Refine repeated sentence openings
Multiple consecutive sentences start with "This". Consider merging or rephrasing to improve readability. For example:

Building the action is essential after code changes: use `@vercel/ncc` to compile your code and dependencies into the `dist` directory, since `node_modules` isn’t checked in.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b7ad18 and 5bd9bc9.

⛔ Files ignored due to path filters (2)
  • actions/update-offer/dist/index.js is excluded by !**/dist/**
  • actions/update-offer/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • actions/update-offer/README.md (1 hunks)
  • actions/update-offer/action.yml (1 hunks)
  • actions/update-offer/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • actions/update-offer/action.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • actions/update-offer/package.json
🧰 Additional context used
🪛 LanguageTool
actions/update-offer/README.md

[style] ~77-~77: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...e file located in the dist directory. This is necessary because the node_modules...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (1)
actions/update-offer/README.md (1)

1-6: Clear and concise action overview
The introduction accurately summarizes the purpose and usage of the action.

@marchuk-vlad
Copy link
Collaborator

I think it will be better to use bash like all our other actions.
Let's use node action if we need something complex that will be hard to implement in bash.

@serega-k @Idris0v
What do you think?

@DmitrySmv
Copy link
Contributor Author

I think it will be better to use bash like all our other actions. Let's use node action if we need something complex that will be hard to implement in bash.

@serega-k @Idris0v What do you think?

@marchuk-vlad @Idris0v @serega-k
This PR now serves only as a Node.js GitHub Action example.
I replaced the GitHub Action with a direct spctl call:
https://github.com/Super-Protocol/solutions/pull/113/files#diff-735e5d0b6c84ae341deef821c27f8f24f5f42b8a9cc94c9cd7e2f8c939c747b9R166

@serega-k
Copy link

I think it will be better to use bash like all our other actions. Let's use node action if we need something complex that will be hard to implement in bash.

@serega-k @Idris0v What do you think?

I have nothing against using a Node.js action, but in this case, I agree with @marchuk-vlad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants