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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 61 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
./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)

runs-on: ubuntu-latest
steps:
- name: Set Branch Based on Kernel
Expand Down Expand Up @@ -176,4 +176,63 @@ jobs:
git push
else
echo "No changes to commit"
fi
fi

trigger-armour-workflow:
needs: [trigger-schema-parser]
runs-on: ubuntu-latest
steps:
- name: Wait for schema updates
run: |
echo "Waiting 6 minutes for schema updates to propagate..."
sleep 360
Comment on lines +185 to +189
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

echo "Wait complete, proceeding with Armor workflow trigger"

- name: Download version-map
uses: actions/download-artifact@v4
with:
name: contracts
path: "artifacts"

- name: Extract version map
run: |
cd artifacts
cat version_map.json
Comment on lines +197 to +201
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)

cp version_map.json ../version_map.json

- name: Trigger Armor Workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CI_PAT }}
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');

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');
return;
}

try {
await github.rest.actions.createWorkflowDispatch({
owner: 'andromedaprotocol',
repo: 'andromeda-armour',
workflow_id: workflowFile,
ref: 'main',
inputs: {
version_map: versionMap
}
});
} catch (error) {
core.setFailed(`Failed to trigger Armor workflow: ${error.message}`);
}
Loading