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

fix: added dependency on argo action #2798

Merged
merged 1 commit into from
Oct 24, 2024
Merged

Conversation

codechirag123
Copy link
Collaborator

@codechirag123 codechirag123 commented Oct 24, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new GitHub Actions workflow for enhanced database operations.
    • Added jobs for syncing with ArgoCD and sending notifications to Slack upon successful migrations.
  • Improvements

    • Established job dependencies to ensure that subsequent actions only occur if prior steps are successful, improving workflow reliability.

Copy link

changeset-bot bot commented Oct 24, 2024

⚠️ No Changeset found

Latest commit: 9a1b435

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes introduce a new GitHub Actions workflow titled "New Database Operations" in the .github/workflows/db-ops.yaml file. This workflow is triggered by a repository_dispatch event and includes several jobs: build-and-push-ee-image, update-helm-chart, sync-argo-app, and send-to-slack. Dependencies and conditional executions are established between these jobs to ensure that subsequent actions depend on the successful completion of prior steps.

Changes

File Change Summary
.github/workflows/db-ops.yaml - New workflow added: name: New Database Operations
- Job added: sync-argo-app
- Job added: send-to-slack
- Job dependency: sync-argo-app depends on update-helm-chart
- Job dependency: send-to-slack depends on both update-helm-chart and build-and-push-ee-image
- Conditional execution for sync-argo-app based on update-helm-chart success
- Conditional execution for send-to-slack based on update-helm-chart success

Possibly related PRs

  • Dev 318/workflow on demand migration #2637: This PR introduces a new GitHub Actions workflow in db-ops.yaml that is closely related to the main PR's workflow changes, particularly in managing database operations and updating Helm charts.
  • Dev 318/ci checkout submodule #2775: This PR modifies the db-ops.yaml workflow, including the build-and-push-ee-image job and the send-to-slack job, which are also present in the main PR, indicating a direct connection in the workflow's functionality and environment variable management.

Suggested reviewers

  • liorzam
  • alonp99
  • MayurDuduka

🐰 In the garden, we hop and play,
New workflows bloom, brightening the day.
With jobs that depend, like friends in a row,
Together we build, watch our progress grow!
🥕✨


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

🧹 Outside diff range and nitpick comments (3)
.github/workflows/db-ops.yaml (3)

Line range hint 9-13: Consider simplifying the SHORT_HASH environment variable logic.

The nested ternary operators make the SHORT_HASH logic hard to read and maintain. Consider using a more explicit approach with GitHub Actions expressions.

- SHORT_HASH: ${{ github.event.client_payload.environment == 'prod' && vars.PROD_WF_SHORT_SHA || github.event.client_payload.environment == 'sb' && vars.SB_WF_SHORT_SHA || vars.DEV_WF_SHORT_SHA }}
+ SHORT_HASH: ${{ 
+   github.event.client_payload.environment == 'prod' && vars.PROD_WF_SHORT_SHA ||
+   github.event.client_payload.environment == 'sb' && vars.SB_WF_SHORT_SHA ||
+   vars.DEV_WF_SHORT_SHA
+ }}
🧰 Tools
🪛 actionlint

146-146: receiver of object dereference "migration_env" must be type of object but got "string"

(expression)


Line range hint 143-162: Fix environment variable references and add timeout for ArgoCD sync.

There are several issues in the ArgoCD sync job:

  1. The environment reference is incorrect
  2. Missing timeout for the sync operation which is crucial for database operations

Apply these fixes:

    needs: update-helm-chart
    if: ${{ needs.update-helm-chart.result == 'success' }}
    runs-on: ubuntu-latest
-   environment: ${{ github.env.MIGRATION_ENV }}
+   environment: ${{ env.MIGRATION_ENV }}
    env:
-     stage: ${{ github.env.MIGRATION_ENV }}
+     stage: ${{ env.MIGRATION_ENV }}
    permissions:
      contents: read
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Run ArgoCD Action
        id: argocd_api
        uses: ./.github/actions/argocd-action
+       timeout-minutes: 10
        with:
          argocd_username: ${{ secrets.ARGOCD_USERNAME }}
          argocd_password: ${{ secrets.ARGOCD_PASSWORD }}
          argocd_server: ${{ secrets.ARGOCD_SERVER }}
          tg_svc_key: ${{ secrets.TWINGATE_SERVICE_KEY_SECRET_NAME }}
🧰 Tools
🪛 actionlint

146-146: receiver of object dereference "migration_env" must be type of object but got "string"

(expression)


Line range hint 164-182: Enhance Slack notification job dependencies and message.

The Slack notification should include the complete deployment status:

  1. Add dependency on the ArgoCD sync job
  2. Include ArgoCD sync status in the message

Apply these changes:

  send-to-slack:
    runs-on: ubuntu-latest
-   needs: [update-helm-chart,build-and-push-ee-image]
+   needs: [update-helm-chart,build-and-push-ee-image,sync-argo-app]
    if: ${{ needs.update-helm-chart.result == 'success' }}
    permissions:
      contents: read
      packages: write
    steps:
      - name: Send alert to Slack channel
        id: slack
        uses: slackapi/slack-github-action@v1.26.0
        with:
          channel-id: '${{ secrets.ARGO_SLACK_CHANNEL_ID }}'
-         slack-message: "Wf-service Migrations in ${{ env.MIGRATION_ENV }} with tag: ${{ env.SHORT_HASH }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ env.MIGRATION_ENV }} and build result: ${{ job.status }}. successfully updated the wf-service migration jobs helm values for ${{ env.MIGRATION_ENV }}."
+         slack-message: "Wf-service Migrations in ${{ env.MIGRATION_ENV }} with tag: ${{ env.SHORT_HASH }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ env.MIGRATION_ENV }}. Status: Build=${{ needs.build-and-push-ee-image.result }}, Helm=${{ needs.update-helm-chart.result }}, ArgoCD=${{ needs.sync-argo-app.result }}"
🧰 Tools
🪛 actionlint

146-146: receiver of object dereference "migration_env" must be type of object but got "string"

(expression)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4dec194 and 9a1b435.

📒 Files selected for processing (1)
  • .github/workflows/db-ops.yaml (1 hunks)
🔇 Additional comments (3)
.github/workflows/db-ops.yaml (3)

Line range hint 18-89: LGTM! The build job follows Docker best practices.

The implementation includes proper layer caching, multi-arch support, and secure credential handling.

🧰 Tools
🪛 actionlint

146-146: receiver of object dereference "migration_env" must be type of object but got "string"

(expression)


Line range hint 91-142: LGTM! The Helm chart update implementation is robust.

The job correctly handles environment-specific configurations and uses sparse checkout for efficiency.

🧰 Tools
🪛 actionlint

146-146: receiver of object dereference "migration_env" must be type of object but got "string"

(expression)


Line range hint 1-182: Verify similar database operation workflows.

Let's ensure there are no conflicting workflows for database operations.

✅ Verification successful

Based on the results, only one workflow file (.github/workflows/db-ops.yaml) contains the "run-test-migration" trigger, which is good as it prevents potential conflicts. However, let's verify if there are any other database-related operations in other workflow files to be completely certain.


Let's examine the database-related operations in the other two files to ensure there are no conflicting operations.


No conflicting database operations found across workflows

After analyzing the workflows, I can confirm that:

  1. db-ops.yaml is the only workflow that handles the run-test-migration trigger
  2. publish-workflows-service.yml and deploy-wf-service.yml only update image tags in Helm charts for database-related components but don't trigger actual database operations
  3. The workflows are complementary rather than conflicting, with clear separation of concerns:
    • db-ops.yaml: Handles test migrations
    • publish-workflows-service.yml: Handles publishing workflow service images
    • deploy-wf-service.yml: Handles deployment configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for similar database operation workflows
# Expected: No other workflows should handle database migrations to avoid conflicts

echo "Searching for other database operation workflows..."
rg -l --type yaml "run-test-migration" .github/workflows/

Length of output: 200


Script:

#!/bin/bash
# Search for database-related keywords in workflow files
echo "Searching for database-related operations in workflows..."
rg -l --type yaml -e "prisma|database|migration|db-|dbMigrate" .github/workflows/

Length of output: 326


Script:

#!/bin/bash
# Check the context of database operations in the other workflow files
echo "Checking publish-workflows-service.yml..."
rg -A 5 -B 5 -e "prisma|database|migration|db-|dbMigrate" .github/workflows/publish-workflows-service.yml

echo -e "\nChecking deploy-wf-service.yml..."
rg -A 5 -B 5 -e "prisma|database|migration|db-|dbMigrate" .github/workflows/deploy-wf-service.yml

Length of output: 4770

🧰 Tools
🪛 actionlint

146-146: receiver of object dereference "migration_env" must be type of object but got "string"

(expression)

@codechirag123 codechirag123 merged commit b4dfff6 into dev Oct 24, 2024
3 checks passed
@codechirag123 codechirag123 deleted the dev-318-fix-argo-action branch October 24, 2024 11:42
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.

2 participants