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

edited staging workflow #2247

Merged
merged 1 commit into from
Nov 19, 2024
Merged

edited staging workflow #2247

merged 1 commit into from
Nov 19, 2024

Conversation

Psalmz777
Copy link
Contributor

@Psalmz777 Psalmz777 commented Nov 19, 2024

Summary of Changes (What does this PR do?)

  • Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done
  • This change ready to hit production in its current state
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included issue number in the "Closes #ISSUE-NUMBER" part of the "What are the relevant tickets?" section to link the issue.
  • I've updated corresponding documentation for the changes in this PR.
  • I have written unit and/or e2e tests for my change(s).

How should this be manually tested?

  • Please include the steps to be done inorder to setup and test this PR.

What are the relevant tickets?

Screenshots (optional)

Summary by CodeRabbit

  • New Features

    • Enhanced deployment workflow for multiple frontend applications triggered by pull request merges.
    • Conditional building and deployment of applications based on modified files.
  • Bug Fixes

    • Minor correction in the website2 README file by removing an extraneous period in the "Getting Started" section.

Copy link

coderabbitai bot commented Nov 19, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request enhance the GitHub Actions workflow for deploying multiple frontend applications when pull requests to the staging branch are merged. A new job structure is introduced, including a check job to determine which applications need building based on modified files. Each application has a dedicated job for building and pushing Docker images, along with updating Helm values and Kubernetes configurations. Additionally, a minor update is made to the website2/README.md file to correct a formatting issue.

Changes

File Path Change Summary
.github/workflows/deploy-frontends-to-staging.yml Added jobs for handling deployment of multiple frontend applications and enhanced logic for checking modified files.
website2/README.md Removed an extraneous period in the "Getting Started" section header.

Possibly related PRs

  • Website2 deployment1 #2241: This PR adds a new job for deploying website2 in the .github/workflows/deploy-frontends-to-staging.yml, which is directly related to the changes made in the main PR regarding the deployment of multiple frontend applications.
  • Edited deploy to staging and readme for website2 #2243: This PR also introduces a new job for website2 in the same workflow file, enhancing the deployment process for website2, which aligns with the main PR's focus on deploying multiple frontends.
  • website: proxy url and docker file updates #2245: This PR updates the website2 job in the .github/workflows/deploy-frontends-to-staging.yml to include additional build arguments, which is relevant to the changes made in the main PR regarding the deployment logic for frontend applications.

Suggested labels

ready for review

Suggested reviewers

  • Baalmart

🎉 In the land of code, where workflows thrive,
New jobs were added, keeping projects alive.
With Docker images and flags that gleam,
Deployments now flow like a well-oiled dream.
A period vanished, just a small tweak,
In the README's header, it’s neat and sleek! 🌟


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 or @coderabbitai title 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

@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/deploy-frontends-to-staging.yml (3)

Line range hint 3-8: Consider optimizing the workflow trigger

The current trigger configuration can be simplified by using pull_request_target instead of pull_request with explicit types field, as we only care about merged PRs.

on:
-  pull_request:
+  pull_request_target:
    branches:
      - staging
-    types:
-      - closed

Line range hint 41-127: Enhance change detection reliability

The current implementation has a few potential improvements:

  1. Using HEAD^ might miss changes if the PR contains multiple commits
  2. The workflow-trigger mechanism could be replaced with a more explicit approach

Consider these improvements:

      - name: check modified frontends
        id: check_files
        run: |
          echo "=============== list modified files ==============="
-         git diff --name-only HEAD^ HEAD
+         git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}

          echo "========== check paths of modified files =========="
-         git diff --name-only HEAD^ HEAD > files.txt
+         git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > files.txt

Also, consider replacing the workflow-trigger file mechanism with GitHub Actions inputs or environment variables for more explicit control.


Line range hint 1-24: Consider workflow optimization and security improvements

A few suggestions to enhance the workflow:

  1. Consider using composite actions to reduce duplication across jobs
  2. Add timeout-minutes to jobs to prevent hanging deployments
  3. Consider adding environment protection rules for staging

Example composite action structure:

# .github/actions/deploy-frontend/action.yml
name: 'Deploy Frontend'
inputs:
  app-name:
    required: true
  env-secret:
    required: true
runs:
  using: "composite"
  steps:
    - name: Setup
      # Common setup steps...
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 152a09b and fb4c00c.

📒 Files selected for processing (2)
  • .github/workflows/deploy-frontends-to-staging.yml (1 hunks)
  • website2/README.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • website2/README.md
🔇 Additional comments (2)
.github/workflows/deploy-frontends-to-staging.yml (2)

343-343: ⚠️ Potential issue

Fix potential line continuation issue

There appears to be a line continuation issue in the Docker build command for website2. The backslash at the end of line 343 seems to be on a new line, which could cause build failures.

-          --build-arg NEXT_PUBLIC_OPENCAGE_API_KEY=${{ secrets.WEBSITE_NEXT_PUBLIC_OPENCAGE_API_KEY }} \
-
-          --build-arg NEXT_PUBLIC_API_TOKEN=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_API_TOKEN }} \
+          --build-arg NEXT_PUBLIC_OPENCAGE_API_KEY=${{ secrets.WEBSITE_NEXT_PUBLIC_OPENCAGE_API_KEY }} \
+          --build-arg NEXT_PUBLIC_API_TOKEN=${{ secrets.WEBSITE_STAGE_NEXT_PUBLIC_API_TOKEN }} \

Likely invalid or redundant comment.


Line range hint 1-607: Verify deployment order dependencies

While the workflow functions correctly, consider adding explicit job dependencies to ensure proper deployment order when multiple applications are updated simultaneously.

✅ Verification successful

No explicit deployment order dependencies found, but some services share API integrations

The analysis reveals that while there are API integrations between services (like analytics being consumed by the platform and website), the current parallel deployment strategy is appropriate because:

  1. Services maintain API version compatibility
  2. Each service deployment is independent and includes its own configuration
  3. Cross-service communication happens through stable API endpoints

The existing workflow correctly handles this by:

  • Using separate jobs for each service
  • Maintaining independent configuration management
  • Deploying services in parallel when changes affect multiple services

Note: The workflow-trigger file already implements a safety mechanism by triggering all deployments when global changes are needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential deployment order dependencies in the codebase

# Look for import statements or API calls between applications
rg -g '*.{js,jsx,ts,tsx}' -B 2 -A 2 'import.*from.*@airqo' || true
rg -g '*.{js,jsx,ts,tsx}' -B 2 -A 2 'fetch\(.*airqo' || true

Length of output: 129


Script:

#!/bin/bash
# Let's check for API dependencies between applications by looking for URLs and endpoints

# Search for API calls or URLs containing service names
echo "=== Checking for cross-service API calls ==="
rg -g '*.{js,jsx,ts,tsx,json}' -i '(netmanager|platform|calibrate|analytics|inventory|docs|reports).*api' || true

# Check for environment variables referencing other services
echo "=== Checking environment files for service dependencies ==="
fd -e env -e env.example -e env.sample -X cat {} 2>/dev/null || true

# Check package.json files for dependencies between apps
echo "=== Checking package.json files for dependencies ==="
fd package.json -x cat {} | grep -i "airqo" || true

# Check docker-compose files for service dependencies
echo "=== Checking Docker/K8s files for service dependencies ==="
fd -e yaml -e yml -g '*docker-compose*' -g '*values*.y*ml' -X cat {} 2>/dev/null || true

Length of output: 5891

Copy link
Contributor

New Website2 changes available for preview here

@Baalmart Baalmart merged commit 7456384 into staging Nov 19, 2024
31 checks passed
@Baalmart Baalmart deleted the Website2-deployment3 branch November 19, 2024 18:06
@Baalmart Baalmart mentioned this pull request Nov 19, 2024
3 tasks
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