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

Trigger tests #677

Merged
merged 6 commits into from
Dec 3, 2024
Merged

Trigger tests #677

merged 6 commits into from
Dec 3, 2024

Conversation

DimitrijeDragasevic
Copy link
Contributor

@DimitrijeDragasevic DimitrijeDragasevic commented Nov 28, 2024

Motivation

Added the final trigger for e2e tests:

Changes:

  1. Download the version map
  2. Read it and send it to andromeda-armour
  3. Added wait time before triggering
  4. Trigger e2e

Summary by CodeRabbit

  • New Features
    • Introduced a new workflow for triggering subsequent processes based on schema updates.
  • Improvements
    • Simplified job dependencies for better workflow control.
    • Enhanced error handling for improved reliability in workflow execution.

Copy link
Contributor

coderabbitai bot commented Nov 28, 2024

Walkthrough

The pull request modifies the .github/workflows/deploy.yml file by updating the trigger-schema-parser job to eliminate its dependency on the build_schemas job. A new job, trigger-armour-workflow, is introduced, which depends on the completion of the trigger-schema-parser job. This new job includes steps for waiting on schema updates, managing a version map, and dispatching another workflow based on the kernel_address input. Additionally, error handling is implemented to address potential mismatches in kernel configurations.

Changes

File Change Summary
.github/workflows/deploy.yml - Added job: trigger-armour-workflow
- Updated trigger-schema-parser to remove dependency on build_schemas

Possibly related PRs

  • Ci workflow #673: The changes in this PR involve significant updates to the .github/workflows/deploy.yml file, including the introduction of the trigger-schema-parser job, which is directly related to the modifications made in the main PR regarding job dependencies and workflow logic.

Suggested labels

ci: skip-changelog

Suggested reviewers

  • joemonem
  • SlayerAnsh

🐰 In the meadow, where workflows play,
A new job hops in, brightening the day.
Schema parsing now takes a lighter stride,
With Armour's trigger, we take great pride.
Errors handled, logic refined,
In our CI garden, harmony we find! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
.github/workflows/deploy.yml (1)

203-238: Enhance error handling and security in workflow dispatch

The workflow dispatch implementation could be improved in several areas:

  1. The error message in case of kernel mismatch could be more descriptive
  2. Consider validating the version map format before sending
  3. Add retry logic for the workflow dispatch in case of temporary failures
       script: |
         const kernelAddress = '${{ inputs.kernel_address }}';
         const testnetKernels = '${{ vars.TESTNET_KERNELS }}';
         const testnetStagingKernels = '${{ vars.TESTNET_STAGING_KERNELS }}';
         
         // Read the version map
         const fs = require('fs');
         const versionMap = fs.readFileSync('version_map.json', 'utf8');
+        
+        // Validate version map format
+        try {
+          const parsedMap = JSON.parse(versionMap);
+          if (!parsedMap || typeof parsedMap !== 'object') {
+            throw new Error('Invalid version map format');
+          }
+        } catch (error) {
+          core.setFailed(`Invalid version map: ${error.message}`);
+          return;
+        }
         
         let workflowFile;
         if (kernelAddress === testnetKernels) {
           workflowFile = 'develop.yml';
         } else if (kernelAddress === testnetStagingKernels) {
           workflowFile = 'staging.yml';
         } else {
-          core.setFailed('Error: Kernel not found in known configurations');
+          core.setFailed(`Error: Kernel ${kernelAddress} not found in known configurations. Expected either ${testnetKernels} or ${testnetStagingKernels}`);
           return;
         }
         
+        const maxRetries = 3;
+        let attempt = 0;
+        
         try {
-          await github.rest.actions.createWorkflowDispatch({
-            owner: 'andromedaprotocol',
-            repo: 'andromeda-armour',
-            workflow_id: workflowFile,
-            ref: 'main',
-            inputs: {
-              version_map: versionMap
-            }
-          });
+          while (attempt < maxRetries) {
+            try {
+              await github.rest.actions.createWorkflowDispatch({
+                owner: 'andromedaprotocol',
+                repo: 'andromeda-armour',
+                workflow_id: workflowFile,
+                ref: 'main',
+                inputs: {
+                  version_map: versionMap
+                }
+              });
+              break;
+            } catch (error) {
+              attempt++;
+              if (attempt === maxRetries) throw error;
+              await new Promise(resolve => setTimeout(resolve, 1000 * attempt));
+            }
+          }
         } catch (error) {
           core.setFailed(`Failed to trigger Armor workflow: ${error.message}`);
         }
🧰 Tools
🪛 yamllint (1.35.1)

[error] 211-211: trailing spaces

(trailing-spaces)


[error] 215-215: trailing spaces

(trailing-spaces)


[error] 225-225: trailing spaces

(trailing-spaces)


[error] 238-238: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1f3b0d4 and b5ce223.

📒 Files selected for processing (1)
  • .github/workflows/deploy.yml (2 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/deploy.yml

[warning] 114-114: wrong indentation: expected 4 but found 6

(indentation)


[error] 181-181: trailing spaces

(trailing-spaces)


[error] 190-190: trailing spaces

(trailing-spaces)


[error] 201-201: trailing spaces

(trailing-spaces)


[error] 211-211: trailing spaces

(trailing-spaces)


[error] 215-215: trailing spaces

(trailing-spaces)


[error] 225-225: trailing spaces

(trailing-spaces)


[error] 238-238: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.github/workflows/deploy.yml (1)

114-114: Verify schema availability after dependency removal

The job no longer depends on build_schemas. Ensure that the schemas are still available through the artifact from the deploy job.

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 114-114: wrong indentation: expected 4 but found 6

(indentation)

Comment on lines +185 to +189
run: |
echo "Waiting 6 minutes for schema updates to propagate..."
sleep 360
echo "Wait complete, proceeding with Armor workflow trigger"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider implementing a more robust wait mechanism

The hard-coded 6-minute wait time is brittle and could lead to race conditions if schema updates take longer. Consider:

  • Implementing a polling mechanism to check for schema availability
  • Making the wait time configurable via workflow inputs
  • Adding a timeout to prevent indefinite waiting

@@ -111,7 +111,7 @@
./andromeda-deploy

trigger-schema-parser:
needs: [deploy, build_schemas]
needs: [deploy]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix job indentation

The needs field is incorrectly indented. It should be at the same level as runs-on.

-      needs: [deploy]
+    needs: [deploy]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
needs: [deploy]
needs: [deploy]
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 114-114: wrong indentation: expected 4 but found 6

(indentation)

Comment on lines +197 to +201
- name: Extract version map
run: |
cd artifacts
cat version_map.json
cp version_map.json ../version_map.json
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for version map extraction

The version map extraction lacks error handling. If the file is missing or malformed, the workflow will fail without a clear error message.

 - name: Extract version map
   run: |
     cd artifacts
+    if [ ! -f version_map.json ]; then
+      echo "Error: version_map.json not found"
+      exit 1
+    fi
+    if ! jq . version_map.json >/dev/null 2>&1; then
+      echo "Error: Invalid JSON in version_map.json"
+      exit 1
+    fi
     cat version_map.json
     cp version_map.json ../version_map.json  
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Extract version map
run: |
cd artifacts
cat version_map.json
cp version_map.json ../version_map.json
- name: Extract version map
run: |
cd artifacts
if [ ! -f version_map.json ]; then
echo "Error: version_map.json not found"
exit 1
fi
if ! jq . version_map.json >/dev/null 2>&1; then
echo "Error: Invalid JSON in version_map.json"
exit 1
fi
cat version_map.json
cp version_map.json ../version_map.json
🧰 Tools
🪛 yamllint (1.35.1)

[error] 201-201: trailing spaces

(trailing-spaces)

@joemonem joemonem added the ci: skip-changelog Skips the changelog check in CI label Dec 2, 2024
@DimitrijeDragasevic DimitrijeDragasevic merged commit 3ada7ab into development Dec 3, 2024
11 of 12 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 5, 2024
@crnbarr93 crnbarr93 deleted the triggerTests branch December 11, 2024 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci: skip-changelog Skips the changelog check in CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants