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

Staging workflow #4053

Merged
merged 4 commits into from
Nov 15, 2024
Merged

Staging workflow #4053

merged 4 commits into from
Nov 15, 2024

Conversation

jyoti18021990
Copy link
Contributor

@jyoti18021990 jyoti18021990 commented Nov 15, 2024

Title

Changes πŸ‘·β€β™€οΈ

- item 1

How to test πŸ§ͺ

- step 1 ...

Summary by CodeRabbit

  • New Features

    • Introduced a new automated workflow for building and deploying the Summer Service in a staging environment.
    • Supports manual dispatch and triggers on pushes to the dev branch.
    • Includes end-to-end testing initiation post-deployment.
  • Improvements

    • Enhanced deployment process with caching for faster builds and validations for required secrets.

Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

This pull request introduces a new GitHub Actions workflow file named build-push-deploy-staging.yaml. It automates the build and deployment process for the Summer Service in a staging environment, triggered by pushes to the dev branch or manual dispatch. The workflow includes steps for checking out the code, setting up the environment, validating secrets, caching dependencies, building the application, configuring AWS credentials, and updating the ECS service, among other tasks.

Changes

File Path Change Summary
.github/workflows/build-push-deploy-staging.yaml Added a new GitHub Actions workflow for automating the build and deployment of the Summer Service in a staging environment.

Possibly related PRs

Poem

🐰 In the meadow, a new workflow blooms,
For Summer Service, it sweeps away glooms.
With builds and deployments, all set to go,
In staging it dances, putting on a show!
Secrets checked, images built with delight,
Our rabbit team hops, ready for flight! 🌼


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

🧹 Outside diff range and nitpick comments (4)
.github/workflows/build-push-deploy-staging.yaml (4)

31-63: Improve shell script robustness in secrets validation

While the validation logic is good, the shell script could be more robust.

Apply these improvements:

- secret_value=$(printenv $secret)
+ secret_value=$(printenv "$secret")

Also consider adding quotes around variable expansions in other places:

if [[ -z "${secret_value}" ]]; then
🧰 Tools
πŸͺ› actionlint

49-49: shellcheck reported issue in this script: SC2086:info:4:27: Double quote to prevent globbing and word splitting

(shellcheck)


70-84: Consider optimizing cache configuration

The current cache setup is functional but could be more efficient.

Consider adding a restore-keys fallback to potentially reuse cache from previous builds:

  with:
    path: '**/node_modules'
    key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
+   restore-keys: |
+     ${{ runner.os }}-node-

130-148: Improve Docker build script robustness

The Docker build script needs proper variable quoting.

Apply these improvements:

- docker build -f Dockerfile.staging \
-                    --cache-from=$ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \
-                    -t $ECR_REGISTRY/$ECR_REPO_NAME:$SHA_TAG \
-                    -t $ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \
-                    -t $ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \
+ docker build -f Dockerfile.staging \
+                    --cache-from="${ECR_REGISTRY}/${ECR_REPO_NAME}:${LATEST_TAG}" \
+                    -t "${ECR_REGISTRY}/${ECR_REPO_NAME}:${SHA_TAG}" \
+                    -t "${ECR_REGISTRY}/${ECR_REPO_NAME}:${LATEST_TAG}" \
+                    -t "${ECR_REGISTRY}/${ECR_REPO_NAME}:${ENVIRONMENT_TAG}" \
🧰 Tools
πŸͺ› actionlint

137-137: shellcheck reported issue in this script: SC2086:info:5:27: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:5:41: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:5:56: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:6:17: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:6:31: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:6:46: Double quote to prevent globbing and word splitting

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:10:13: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:10:27: Double quote to prevent globbing and word splitting

(shellcheck)


159-170: Add error handling to E2E test trigger

While the implementation works, it could benefit from error handling.

Consider adding error handling:

  curl -L \
+   --fail \
    -X POST \
    -H "Accept: application/vnd.github+json" \
    -H "Authorization: Bearer ${{ env.E2E_TESTS_PAT }}" \
    -H "X-GitHub-Api-Version: 2022-11-28" \
    https://api.github.com/repos/OasisDEX/e2e-tests/actions/workflows/ci_e2e_tests.yml/dispatches \
-   -d "{\"ref\":\"main\", \"inputs\":{\"run_id\":\"${{ github.run_id }}\", \"repository\":\"${{ github.repository }}\"}}"
+   -d "{\"ref\":\"main\", \"inputs\":{\"run_id\":\"${{ github.run_id }}\", \"repository\":\"${{ github.repository }}\"}}" || {
+     echo "Failed to trigger E2E tests"
+     exit 1
+   }
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 602e9a4 and 45d4147.

πŸ“’ Files selected for processing (1)
  • .github/workflows/build-push-deploy-staging.yaml (1 hunks)
🧰 Additional context used
πŸͺ› actionlint
.github/workflows/build-push-deploy-staging.yaml

49-49: shellcheck reported issue in this script: SC2086:info:4:27: Double quote to prevent globbing and word splitting

(shellcheck)


67-67: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


137-137: shellcheck reported issue in this script: SC2086:info:5:27: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:5:41: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:5:56: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:6:17: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:6:31: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:6:46: Double quote to prevent globbing and word splitting

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


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

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:10:13: Double quote to prevent globbing and word splitting

(shellcheck)


137-137: shellcheck reported issue in this script: SC2086:info:10:27: Double quote to prevent globbing and word splitting

(shellcheck)


151-151: shellcheck reported issue in this script: SC2086:info:1:34: Double quote to prevent globbing and word splitting

(shellcheck)


151-151: shellcheck reported issue in this script: SC2086:info:1:114: Double quote to prevent globbing and word splitting

(shellcheck)

πŸ”‡ Additional comments (4)
.github/workflows/build-push-deploy-staging.yaml (4)

1-15: LGTM! Well-structured workflow triggers and environment setup

The workflow configuration properly separates staging environment concerns and securely handles sensitive values through secrets.


16-30: LGTM! Appropriate job configuration and environment setup

Good practices observed:

  • Explicit Node.js version pinning
  • Proper permissions configuration
  • Latest Ubuntu runner

85-119: LGTM! Well-configured build process

The build step is properly configured with:

  • Appropriate NODE_OPTIONS for memory management
  • Comprehensive environment variable setup
  • Next.js build caching

120-129: LGTM! Secure AWS authentication setup

Good use of OIDC for AWS authentication, which is a security best practice.

Comment on lines +64 to +69
- name: Extract commit hash
id: vars
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

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

Update deprecated GitHub Actions syntax

The set-output command is deprecated.

Replace with the new syntax:

- echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+ echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
πŸ“ 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 commit hash
id: vars
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Extract commit hash
id: vars
shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
🧰 Tools
πŸͺ› actionlint

67-67: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)

@jyoti18021990 jyoti18021990 merged commit 5a1ba64 into dev Nov 15, 2024
26 checks passed
@jyoti18021990 jyoti18021990 deleted the new-staging branch November 15, 2024 18:06
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.

1 participant