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

Changes to CI #701

Merged
merged 2 commits into from
Dec 6, 2024
Merged

Changes to CI #701

merged 2 commits into from
Dec 6, 2024

Conversation

DimitrijeDragasevic
Copy link
Contributor

@DimitrijeDragasevic DimitrijeDragasevic commented Dec 5, 2024

Implementation

Changes:
Made test kernels envs to be lists, if provided kernel is not in those two, skip last two steps
Updated andromeda armour trigger, to trigger only smoke tests

Testing

https://github.com/andromedaprotocol/andromeda-core/actions/runs/12182462497

Summary by CodeRabbit

  • New Features

    • Enhanced workflow control with new output variables for better job execution management.
    • Improved kernel address validation logic for more flexible matching.
  • Bug Fixes

    • Enhanced error handling related to kernel address validation.
  • Chores

    • Minor adjustments to improve clarity and maintainability of workflow scripts.

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

The changes in this pull request primarily focus on enhancing the GitHub Actions workflow defined in .github/workflows/deploy.yml. Key modifications include the restructuring of the trigger-schema-parser job to include output variables for workflow continuation based on kernel address checks. The job now supports flexible matching against arrays of kernel addresses. Additionally, the trigger-armour-workflow job has been updated to conditionally execute based on the output of the trigger-schema-parser job, improving the clarity and maintainability of the workflow.

Changes

File Change Summary
.github/workflows/deploy.yml - Restructured trigger-schema-parser job to include output variable should_continue.
- Enhanced kernel address checking logic to iterate over arrays for flexible matching.
- Updated trigger-armour-workflow job to conditionally run based on should_continue.
- Modified logic for determining workflow file to trigger using arrays for kernel address checks.
- Added grep input in workflow dispatch call for Armor workflow.
- Added job output schema_url in build_schemas job.

Possibly related PRs

  • ci: changes to contract builds #605: Modifies the .github/workflows/release.yml file, related to the changes in .github/workflows/deploy.yml.
  • Ci workflow #673: Updates .github/workflows/deploy.yml, adding new jobs and modifying existing ones, similar to the main PR.
  • Trigger tests #677: Updates .github/workflows/deploy.yml, specifically modifying trigger-schema-parser and introducing trigger-armour-workflow.
  • ci: fix release schema build #695: Addresses the release workflow in .github/workflows/release.yml, relevant to changes in schema validation and deployment.

Suggested labels

ci: skip-changelog, ci: skip-build

Suggested reviewers

  • cowboy0015
  • joemonem
  • SlayerAnsh

🐰 In the workflow's dance, we hop and play,
With kernel checks that brighten the day.
Outputs now guide us, clear as can be,
In the land of GitHub, we code with glee!
So let’s trigger the armor, let’s make it right,
With each little change, our future is bright! 🌟


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.

@crnbarr93 crnbarr93 added ci: skip-changelog Skips the changelog check in CI ci: skip-build Skip artifact uploads labels Dec 5, 2024
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: 2

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

166-178: Enhance error handling in schema processing

While the schema processing steps are well-structured, let's add better error handling:

  echo "Installing dependencies..."
- pnpm install
+ pnpm install || {
+   echo "Failed to install dependencies"
+   exit 1
+ }
  echo "Processing schema..."
- npm run start
+ npm run start || {
+   echo "Failed to process schema"
+   exit 1
+ }
  echo "Flattening schema..."
- npm run flatten
+ npm run flatten || {
+   echo "Failed to flatten schema"
+   exit 1
+ }
  echo "Exporting schema..."
- npm run export
+ npm run export || {
+   echo "Failed to export schema"
+   exit 1
+ }

198-202: Consider making the wait duration configurable

The hard-coded 6-minute wait might need adjustment based on schema update patterns.

+ env:
+   SCHEMA_WAIT_DURATION: ${{ vars.SCHEMA_WAIT_DURATION || 360 }}
  steps:
    - name: Wait for schema updates
      run: |
        echo "Waiting 6 minutes for schema updates to propagate..."
-       sleep 360
+       sleep ${SCHEMA_WAIT_DURATION}
        echo "Wait complete, proceeding with Armor workflow trigger"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 257309c and 0dd0a3c.

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

120-120: shellcheck reported issue in this script: SC2086:info:7:30: Double quote to prevent globbing and word splitting

(shellcheck)


120-120: shellcheck reported issue in this script: SC2086:info:8:36: Double quote to prevent globbing and word splitting

(shellcheck)


120-120: shellcheck reported issue in this script: SC2086:info:15:38: Double quote to prevent globbing and word splitting

(shellcheck)


120-120: shellcheck reported issue in this script: SC2086:info:16:36: Double quote to prevent globbing and word splitting

(shellcheck)


120-120: shellcheck reported issue in this script: SC2086:info:22:33: Double quote to prevent globbing and word splitting

(shellcheck)

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

113-117: LGTM: Well-structured job output definition

The addition of the should_continue output variable provides clear control flow for downstream jobs.


224-227: LGTM: Well-implemented smoke test integration

The addition of the @smoke_test grep pattern and version map integration aligns well with the PR objectives for streamlining the testing process.

Also applies to: 245-246

Comment on lines +229 to 236
if (testnetKernelsList.includes(kernelAddress)) {
workflowFile = 'develop.yml';
} else if (kernelAddress === testnetStagingKernels) {
} else if (testnetStagingKernelsList.includes(kernelAddress)) {
workflowFile = 'staging.yml';
} else {
core.setFailed('Error: Kernel not found in known configurations');
return;
}
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

Enhance workflow file selection error handling

  let workflowFile;
  if (testnetKernelsList.includes(kernelAddress)) {
    workflowFile = 'develop.yml';
  } else if (testnetStagingKernelsList.includes(kernelAddress)) {
    workflowFile = 'staging.yml';
  } else {
-   core.setFailed('Error: Kernel not found in known configurations');
+   core.setFailed(`Error: Kernel ${kernelAddress} not found in known configurations. Available kernels: Testnet [${testnetKernelsList}], Staging [${testnetStagingKernelsList}]`);
    return;
  }
📝 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
if (testnetKernelsList.includes(kernelAddress)) {
workflowFile = 'develop.yml';
} else if (kernelAddress === testnetStagingKernels) {
} else if (testnetStagingKernelsList.includes(kernelAddress)) {
workflowFile = 'staging.yml';
} else {
core.setFailed('Error: Kernel not found in known configurations');
return;
}
if (testnetKernelsList.includes(kernelAddress)) {
workflowFile = 'develop.yml';
} else if (testnetStagingKernelsList.includes(kernelAddress)) {
workflowFile = 'staging.yml';
} else {
core.setFailed(`Error: Kernel ${kernelAddress} not found in known configurations. Available kernels: Testnet [${testnetKernelsList}], Staging [${testnetStagingKernelsList}]`);
return;
}

Comment on lines +121 to +143
KERNEL_ADDRESS="${{ inputs.kernel_address }}"
IFS=',' read -ra TESTNET_KERNELS_ARR <<< "${{ vars.TESTNET_KERNELS }}"
IFS=',' read -ra TESTNET_STAGING_KERNELS_ARR <<< "${{ vars.TESTNET_STAGING_KERNELS }}"

for kernel in "${TESTNET_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=develop" >> $GITHUB_OUTPUT
elif [[ "${KERNEL_ADDRESS}" == "${TESTNET_STAGING_KERNELS}" ]]; then
echo "branch=testnet-staging" >> $GITHUB_OUTPUT
else
echo "Error: Kernel not found in known configurations"
exit 1
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done

- name: Checkout Schema Parser
uses: actions/checkout@v4
with:
repository: andromedaprotocol/schema-parser
ref: ${{ steps.check-kernel.outputs.branch }}
token: ${{ secrets.CI_PAT }}

- name: Download Schemas
uses: actions/download-artifact@v4
with:
name: temp-schemas
path: "packages/schema-parser/schema"

- uses: pnpm/action-setup@v4
with:
version: 8

- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'

- name: Process Schema
working-directory: packages/schema-parser
run: |
set -eo pipefail
echo "Installing dependencies..."
pnpm install
echo "Processing schema..."
npm run start
echo "Flattening schema..."
npm run flatten
echo "Exporting schema..."
npm run export

- name: Commit and Push Changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

if [[ -n $(git status --porcelain) ]]; then
git add .
git commit -m "chore: Update schema for kernel: ${{ inputs.kernel_address }}"
git push
else
echo "No changes to commit"
for kernel in "${TESTNET_STAGING_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=testnet-staging" >> $GITHUB_OUTPUT
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done

echo "Skip: Kernel not found in known configurations"
echo "should_continue=false" >> $GITHUB_OUTPUT

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

Enhance shell script robustness and error handling

While the array-based kernel checking is well-designed, let's improve the shell script robustness:

- KERNEL_ADDRESS="${{ inputs.kernel_address }}"
+ KERNEL_ADDRESS="${{ inputs.kernel_address || '' }}"
  
- IFS=',' read -ra TESTNET_KERNELS_ARR <<< "${{ vars.TESTNET_KERNELS }}"
- IFS=',' read -ra TESTNET_STAGING_KERNELS_ARR <<< "${{ vars.TESTNET_STAGING_KERNELS }}"
+ if [[ -z "${{ vars.TESTNET_KERNELS }}" ]] || [[ -z "${{ vars.TESTNET_STAGING_KERNELS }}" ]]; then
+   echo "Error: Required kernel environment variables are not set"
+   exit 1
+ fi
+ 
+ IFS=',' read -ra TESTNET_KERNELS_ARR <<< "${{ vars.TESTNET_KERNELS }}"
+ IFS=',' read -ra TESTNET_STAGING_KERNELS_ARR <<< "${{ vars.TESTNET_STAGING_KERNELS }}"
+ 
+ if [[ -z "${KERNEL_ADDRESS}" ]]; then
+   echo "Error: Kernel address is required"
+   echo "should_continue=false" >> $GITHUB_OUTPUT
+   exit 1
+ fi
📝 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
KERNEL_ADDRESS="${{ inputs.kernel_address }}"
IFS=',' read -ra TESTNET_KERNELS_ARR <<< "${{ vars.TESTNET_KERNELS }}"
IFS=',' read -ra TESTNET_STAGING_KERNELS_ARR <<< "${{ vars.TESTNET_STAGING_KERNELS }}"
for kernel in "${TESTNET_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=develop" >> $GITHUB_OUTPUT
elif [[ "${KERNEL_ADDRESS}" == "${TESTNET_STAGING_KERNELS}" ]]; then
echo "branch=testnet-staging" >> $GITHUB_OUTPUT
else
echo "Error: Kernel not found in known configurations"
exit 1
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done
- name: Checkout Schema Parser
uses: actions/checkout@v4
with:
repository: andromedaprotocol/schema-parser
ref: ${{ steps.check-kernel.outputs.branch }}
token: ${{ secrets.CI_PAT }}
- name: Download Schemas
uses: actions/download-artifact@v4
with:
name: temp-schemas
path: "packages/schema-parser/schema"
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- name: Process Schema
working-directory: packages/schema-parser
run: |
set -eo pipefail
echo "Installing dependencies..."
pnpm install
echo "Processing schema..."
npm run start
echo "Flattening schema..."
npm run flatten
echo "Exporting schema..."
npm run export
- name: Commit and Push Changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if [[ -n $(git status --porcelain) ]]; then
git add .
git commit -m "chore: Update schema for kernel: ${{ inputs.kernel_address }}"
git push
else
echo "No changes to commit"
for kernel in "${TESTNET_STAGING_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=testnet-staging" >> $GITHUB_OUTPUT
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "Skip: Kernel not found in known configurations"
echo "should_continue=false" >> $GITHUB_OUTPUT
KERNEL_ADDRESS="${{ inputs.kernel_address || '' }}"
if [[ -z "${{ vars.TESTNET_KERNELS }}" ]] || [[ -z "${{ vars.TESTNET_STAGING_KERNELS }}" ]]; then
echo "Error: Required kernel environment variables are not set"
exit 1
fi
IFS=',' read -ra TESTNET_KERNELS_ARR <<< "${{ vars.TESTNET_KERNELS }}"
IFS=',' read -ra TESTNET_STAGING_KERNELS_ARR <<< "${{ vars.TESTNET_STAGING_KERNELS }}"
if [[ -z "${KERNEL_ADDRESS}" ]]; then
echo "Error: Kernel address is required"
echo "should_continue=false" >> $GITHUB_OUTPUT
exit 1
fi
for kernel in "${TESTNET_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=develop" >> $GITHUB_OUTPUT
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done
for kernel in "${TESTNET_STAGING_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=testnet-staging" >> $GITHUB_OUTPUT
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "Skip: Kernel not found in known configurations"
echo "should_continue=false" >> $GITHUB_OUTPUT

@crnbarr93 crnbarr93 merged commit 8ab21c6 into development Dec 6, 2024
17 of 19 checks passed
@crnbarr93 crnbarr93 deleted the skipSchema branch December 6, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci: skip-build Skip artifact uploads ci: skip-changelog Skips the changelog check in CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants