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

[OTE-894] Pipeline test main replica #2547

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jerryfan01234
Copy link
Contributor

@jerryfan01234 jerryfan01234 commented Oct 28, 2024

Changelist

[Describe or list the changes made in this PR]

Test Plan

need to merge to main to test that the workflow triggers actually work.

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features
    • Introduced new GitHub Actions workflows for deployment:
      • Deploy indexer to staging triggered on pull request closure.
      • Snapshot indexer staging scheduled to run at specified times throughout the year.

@jerryfan01234 jerryfan01234 requested a review from a team as a code owner October 28, 2024 19:40
Copy link

linear bot commented Oct 28, 2024

Copy link
Contributor

coderabbitai bot commented Oct 28, 2024

Walkthrough

Two new GitHub Actions workflow files have been introduced: pipeline-indexer-staging-promotion.yml and pipeline-indexer-testnet-promotion.yml. The former is triggered upon the closure of pull requests and runs a job that outputs "Hello World" when a pull request is merged with the base reference pipeline-main-replica. The latter is scheduled to run at specific times throughout the year and also includes a job that outputs "Hello World".

Changes

File Path Change Summary
.github/workflows/pipeline-indexer-staging-promotion.yml New workflow added: Deploy indexer to staging.
.github/workflows/pipeline-indexer-testnet-promotion.yml New workflow added: Snapshot indexer staging.

Poem

In the meadow where bunnies play,
New workflows hop in, hip-hip-hooray!
"Hello World!" they cheer with glee,
Automating tasks, oh so free!
With every merge and every time,
Our code dances, oh so sublime! 🐇✨


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: 6

🧹 Outside diff range and nitpick comments (4)
.github/workflows/pipeline-indexer-testnet-promotion.yml (2)

4-6: Enhance schedule documentation with UTC time

While the comment explains ET times, it would be clearer to document the UTC time (16:00) since that's what the cron expression uses and GitHub Actions runs on UTC.

-    # 12pm ET from Mar to Oct, 1pm ET from Nov to Feb due to daylight saving
+    # Runs daily at 16:00 UTC (12pm ET Mar-Oct, 1pm ET Nov-Feb)

8-13: Implement required pipeline functionality

The current implementation is a placeholder that only outputs "Hello World". For a promotion pipeline, consider implementing:

  1. Environment protection rules
  2. Actual deployment steps
  3. Error handling and retries
  4. Success/failure notifications
  5. Deployment verification steps

Would you like me to help create a more robust pipeline implementation with these features? I can provide a detailed example that includes:

  • Environment protection
  • Deployment steps
  • Error handling
  • Slack notifications
  • Health checks
🧰 Tools
🪛 yamllint

[error] 10-10: trailing spaces

(trailing-spaces)


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

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

.github/workflows/pipeline-indexer-staging-promotion.yml (2)

1-2: Add workflow documentation

Consider adding inline documentation to explain:

  • Purpose of the workflow
  • Required secrets and permissions
  • Expected behavior
  • Troubleshooting steps

Add a comment block like:

name: Deploy indexer to staging

# This workflow automates the deployment of the indexer service to the staging environment.
# It runs automatically when PRs are merged into the pipeline-indexer-staging branch.
#
# Required secrets:
# - AWS_ROLE_ARN: ARN of the AWS role for deployment
# - SLACK_CHANNEL_ID: Slack channel for notifications
#
# Required environment variables:
# - AWS_REGION: Target AWS region for deployment

15-15: Add newline at end of file

Add a newline character at the end of the file to comply with YAML best practices.

🧰 Tools
🪛 yamllint

[error] 15-15: 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

Files that changed from the base of the PR and between 0e185fd and 2f0b7c8.

📒 Files selected for processing (2)
  • .github/workflows/pipeline-indexer-staging-promotion.yml (1 hunks)
  • .github/workflows/pipeline-indexer-testnet-promotion.yml (1 hunks)
🧰 Additional context used
🪛 yamllint
.github/workflows/pipeline-indexer-staging-promotion.yml

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

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

.github/workflows/pipeline-indexer-testnet-promotion.yml

[error] 10-10: trailing spaces

(trailing-spaces)


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

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

jobs:
deploy:
runs-on: ubuntu-latest

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 YAML formatting issues

There are two minor formatting issues:

  1. Line 10: Remove trailing spaces
  2. Line 13: Add newline at end of file
    runs-on: ubuntu-latest
-        
+
    steps:
      - name: Echo Hello World
-        run: echo "Hello World"
+        run: echo "Hello World"
+

Also applies to: 13-13

🧰 Tools
🪛 yamllint

[error] 10-10: trailing spaces

(trailing-spaces)

@@ -0,0 +1,13 @@
name: Snapshot indexer staging
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

Resolve naming inconsistency between workflow name and filename

The workflow name "Snapshot indexer staging" doesn't match the filename "pipeline-indexer-testnet-promotion.yml" which mentions testnet. This could cause confusion about whether this workflow is for staging or testnet environment.

-name: Snapshot indexer staging
+name: Pipeline indexer testnet promotion
📝 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: Snapshot indexer staging
name: Pipeline indexer testnet promotion

Comment on lines +1 to +13
name: Snapshot indexer staging

on:
schedule:
# 12pm ET from Mar to Oct, 1pm ET from Nov to Feb due to daylight saving
- cron: '0 16 * * *'
jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Echo Hello World
run: echo "Hello World"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add environment, permissions, and manual trigger to the promotion workflow

The workflow requires several critical security and usability improvements:

  1. Missing environment configuration unlike other deployment workflows that use environment protection
  2. No defined permissions scope which is a security best practice
  3. Only scheduled trigger without manual option which limits operational flexibility

Required changes:

  • Add environment: staging to the job
  • Add permissions block to limit scope
  • Add workflow_dispatch trigger for manual runs
  • Consider using the reusable workflow pattern like other deployment workflows
🔗 Analysis chain

Verify workflow triggers and permissions

Since this is a promotion pipeline that likely involves deployments, we should verify:

  1. If the workflow has appropriate permissions
  2. If environment protection rules are in place
  3. If the schedule trigger is sufficient (consider adding manual trigger)

Let me check the content of the related workflows to better understand the environment configurations and permissions.


Let me check the content of the deployment workflows to understand the complete context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for environment configurations and other workflow permissions
echo "Checking for environment configurations..."
rg -l "environment:" .github/workflows/
echo "Checking for workflow permissions..."
rg -l "permissions:" .github/workflows/

Length of output: 444


Script:

#!/bin/bash
# Check content of workflows with environment configurations
echo "Content of indexer-reusable-build-and-push-ecs-service.yml:"
cat .github/workflows/indexer-reusable-build-and-push-ecs-service.yml

echo -e "\nContent of indexer-build-and-push-lambda.yml:"
cat .github/workflows/indexer-build-and-push-lambda.yml

# Check if there are any other promotion or deployment workflows
echo -e "\nChecking for other promotion workflows:"
rg -l "promotion|deploy" .github/workflows/

Length of output: 4509


Script:

#!/bin/bash
# Check content of deployment workflows
echo "Content of deploy-to-dev.yml:"
cat .github/workflows/deploy-to-dev.yml

echo -e "\nContent of pipeline-indexer-testnet-promotion.yml:"
cat .github/workflows/pipeline-indexer-testnet-promotion.yml

# Check if there are any environment protection rules in other workflows
echo -e "\nChecking for environment protection rules:"
rg "environment:" -A 5 -B 5 .github/workflows/

Length of output: 10312

🧰 Tools
🪛 yamllint

[error] 10-10: trailing spaces

(trailing-spaces)


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

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

Comment on lines 1 to 15
name: Deploy indexer to staging

on:
pull_request:
types:
- closed

jobs:
on-merge:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'pipeline-indexer-staging'
runs-on: ubuntu-latest

steps:
- name: Echo Hello World
run: echo "Hello World"
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

Implementation required: Add actual deployment steps

The current workflow only contains a placeholder "Hello World" step. For a production deployment workflow, consider implementing:

  • Checkout code
  • Authentication to deployment environment
  • Build/validation steps
  • Actual deployment commands
  • Post-deployment health checks
  • Deployment notifications

Here's a suggested structure:

name: Deploy indexer to staging

on:
  pull_request:
    types:
      - closed

permissions:
  contents: read
  deployments: write

jobs:
  on-merge:
    if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'pipeline-indexer-staging'
    runs-on: ubuntu-latest
    environment: staging
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
          aws-region: ${{ vars.AWS_REGION }}
          
      - name: Deploy to staging
        run: |
          # Add deployment commands here
          
      - name: Verify deployment
        run: |
          # Add health check commands here
          
      - name: Notify deployment status
        if: always()
        uses: slackapi/slack-github-action@v1.24.0
        with:
          channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
          slack-message: "Deployment to staging ${{ job.status }}"
🧰 Tools
🪛 yamllint

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

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

Comment on lines 8 to 12
jobs:
on-merge:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'pipeline-indexer-staging'
runs-on: ubuntu-latest

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

Security: Add permissions and environment protection

The workflow lacks important security configurations:

  • No explicit permissions defined
  • No environment protection rules
  • No secrets management
  • No deployment approval requirements

Consider adding:

  1. Explicit permissions block
  2. Environment protection rules
  3. Required approval workflows
  4. Secrets management

@jerryfan01234 jerryfan01234 force-pushed the pipeline-test-main-replica branch from 2f0b7c8 to f9e50ab Compare October 28, 2024 20:31
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: 5

🧹 Outside diff range and nitpick comments (1)
.github/workflows/pipeline-indexer-staging-promotion.yml (1)

1-2: Add workflow documentation

Since this is a deployment workflow, consider adding a description using the # comment syntax to document:

  • The workflow's purpose
  • Required permissions/secrets
  • Expected behavior
  • Related workflows
 name: Deploy indexer to staging
+# Description: This workflow promotes the indexer to staging environment
+# Triggered: When PRs are merged to pipeline-main-replica
+# Required permissions: TBD
+# Related workflows: pipeline-indexer-testnet-promotion.yml
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2f0b7c8 and f9e50ab.

📒 Files selected for processing (2)
  • .github/workflows/pipeline-indexer-staging-promotion.yml (1 hunks)
  • .github/workflows/pipeline-indexer-testnet-promotion.yml (1 hunks)
🧰 Additional context used
🪛 yamllint
.github/workflows/pipeline-indexer-staging-promotion.yml

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

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

.github/workflows/pipeline-indexer-testnet-promotion.yml

[error] 10-10: trailing spaces

(trailing-spaces)


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

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

🔇 Additional comments (2)
.github/workflows/pipeline-indexer-staging-promotion.yml (2)

13-15: ⚠️ Potential issue

Replace placeholder with actual deployment steps

While the "Hello World" step aligns with the PR's objective to test pipeline triggers, the production version will need:

  1. Code checkout
  2. Authentication steps
  3. Build/validation
  4. Deployment commands
  5. Health checks
  6. Status notifications

Note: This issue was previously raised in the past review comments. The placeholder is acceptable for testing triggers, but please ensure to implement the suggested production deployment steps in a follow-up PR.

🧰 Tools
🪛 yamllint

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

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


3-7: Verify the trigger configuration

The workflow triggers on PR closure, but consider:

  1. Adding branch protection to pipeline-main-replica
  2. Implementing required PR approvals
  3. Adding required status checks

Comment on lines +11 to +13
steps:
- name: Echo Hello World
run: echo "Hello World"
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

Implement required promotion pipeline steps

The current implementation appears to be a placeholder. A promotion pipeline typically requires several essential steps:

Consider implementing these critical steps:

    steps:
      - uses: actions/checkout@v4
      
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
          aws-region: ${{ secrets.AWS_REGION }}
      
      - name: Promote indexer
        run: |
          # Add promotion logic here
          set -e
          # Example:
          # - Verify current deployment
          # - Update deployment tags
          # - Deploy to target environment
          # - Run health checks
      
      - name: Notify status
        if: always()
        uses: slackapi/slack-github-action@v1.24.0
        with:
          channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
          slack-message: "Indexer promotion to testnet ${{ job.status }}"

Would you like me to help create a complete implementation of the promotion pipeline?

🧰 Tools
🪛 yamllint

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

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

Comment on lines +4 to +6
schedule:
# 12pm ET from Mar to Oct, 1pm ET from Nov to Feb due to daylight saving
- cron: '0 16 * * *'
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

Verify cron schedule timezone calculation

The cron expression 0 16 * * * (16:00 UTC) doesn't align with the stated times:

  • March-October: 16:00 UTC = 12:00 EDT (UTC-4)
  • November-February: 16:00 UTC = 11:00 EST (UTC-5), not 13:00 EST as commented

To run at 12pm ET (March-October) and 1pm ET (November-February), use:

-    - cron: '0 16 * * *'
+    - cron: '0 17 * * *'  # 1pm ET (Nov-Feb) / 12pm ET (Mar-Oct)
📝 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
schedule:
# 12pm ET from Mar to Oct, 1pm ET from Nov to Feb due to daylight saving
- cron: '0 16 * * *'
schedule:
# 12pm ET from Mar to Oct, 1pm ET from Nov to Feb due to daylight saving
- cron: '0 17 * * *'

Comment on lines +8 to +9
deploy:
runs-on: ubuntu-latest
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

Rename job to match its current purpose

The job name 'deploy' implies deployment functionality, but the job currently only outputs "Hello World". This could be misleading for other developers.

If this is a placeholder:

-  deploy:
+  placeholder:

If this will be a deployment job, please implement proper deployment steps including:

  • Checkout code
  • Authentication
  • Deployment commands
  • Error handling
  • Status notifications

Committable suggestion was skipped due to low confidence.


steps:
- name: Echo Hello World
run: echo "Hello World"
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

Add newline at end of file

Add a newline character at the end of the file to comply with YAML best practices.

       - name: Echo Hello World
         run: echo "Hello World"
+

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 yamllint

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

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

Comment on lines +8 to +12
jobs:
on-merge:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'pipeline-main-replica'
runs-on: ubuntu-latest

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

Add security configurations and environment protection

The job configuration needs security enhancements:

  1. Explicit permissions block
  2. Environment protection rules
  3. Concurrency limits to prevent parallel deployments
 jobs:
   on-merge:
     if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'pipeline-main-replica'
     runs-on: ubuntu-latest
+    environment: staging
+    concurrency: staging_deployment
+    permissions:
+      contents: read
+      deployments: write
📝 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
jobs:
on-merge:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'pipeline-main-replica'
runs-on: ubuntu-latest
jobs:
on-merge:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'pipeline-main-replica'
runs-on: ubuntu-latest
environment: staging
concurrency: staging_deployment
permissions:
contents: read
deployments: write

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

Successfully merging this pull request may close these issues.

2 participants