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(server): fix command failed #36

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Conversation

hexaforce
Copy link
Contributor

@hexaforce hexaforce commented Dec 5, 2024

Overview

fix command failed

What I've done

The build is failing, so I will remove the command options.

スクリーンショット 2024-12-05 13 29 23

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • Chores
    • Updated workflow configuration for building the server to refine release generation and Docker image tagging processes.
    • Improved logic for fetching the correct version of the reearth-web release based on input parameters.

@hexaforce hexaforce requested a review from rot1024 as a code owner December 5, 2024 04:33
Copy link

coderabbitai bot commented Dec 5, 2024

Walkthrough

The pull request modifies the workflow configuration for build-server in .github/workflows/build_server.yml. Key changes include the removal of the --rm-dist flag from the GoReleaser command, the introduction of a new environment variable TAG derived from the new_tag_short input, and the implementation of conditional logic for fetching the correct version of the reearth-web release. These adjustments enhance the workflow's control flow and logic for generating releases and building Docker images based on input parameters.

Changes

File Change Summary
.github/workflows/build_server.yml - Removed --rm-dist flag from GoReleaser command.
- Added TAG environment variable from new_tag_short input.
- Updated logic for fetching release version based on name or new_tag inputs.

Suggested reviewers

  • mkumbobeaty
  • airslice

Poem

🐇 In the garden where workflows bloom,
A tag is set, dispelling gloom.
With GoReleaser's dance, we take flight,
Docker images shine, oh what a sight!
So hop along, let changes ring,
For every tag, a new joy to bring! 🌼


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

netlify bot commented Dec 5, 2024

Deploy Preview for reearth-classic canceled.

Name Link
🔨 Latest commit 7c07dbf
🔍 Latest deploy log https://app.netlify.com/sites/reearth-classic/deploys/67512d012e7e6c00088b10db

@hexaforce hexaforce requested a review from pyshx December 5, 2024 04:33
@hexaforce hexaforce self-assigned this Dec 5, 2024
@hexaforce hexaforce changed the title fix command failed fix(server): fix command failed Dec 5, 2024
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 (2)
.github/workflows/build_server.yml (2)

Line range hint 94-114: Simplify conditional logic for better maintainability

The current implementation of version and tag logic, while functional, could be simplified for better maintainability.

Consider refactoring the script to use functions and clearer variable names:

- if [[ -n $TAG ]]; then
-   PLATFORMS=linux/amd64,linux/arm64
-   VERSION=$TAG
-   TAGS=$IMAGE_NAME:$TAG
-   if [[ ! $TAG =~ '-' ]]; then
-     TAGS+=,${IMAGE_NAME}:${TAG%.*}
-     TAGS+=,${IMAGE_NAME}:${TAG%%.*}
-     TAGS+=,${IMAGE_NAME}:latest
-   fi
- else
-   PLATFORMS=linux/amd64
-   VERSION=$SHA
-   TAGS=$IMAGE_NAME:$NAME
- fi
+ # Function to generate tag list
+ generate_tags() {
+   local base_tag=$1
+   local tags="$IMAGE_NAME:$base_tag"
+   
+   # Add additional tags for stable releases
+   if [[ ! $base_tag =~ '-' ]]; then
+     tags+=",${IMAGE_NAME}:${base_tag%.*}"        # Major.Minor
+     tags+=",${IMAGE_NAME}:${base_tag%%.*}"       # Major
+     tags+=",${IMAGE_NAME}:latest"
+   fi
+   echo "$tags"
+ }
+ 
+ # Set build configuration
+ PLATFORMS=$([ -n "$TAG" ] && echo "linux/amd64,linux/arm64" || echo "linux/amd64")
+ VERSION=${TAG:-$SHA}
+ TAGS=$([ -n "$TAG" ] && generate_tags "$TAG" || echo "$IMAGE_NAME:$NAME")

This refactoring:

  • Improves readability with a dedicated function for tag generation
  • Makes the platform selection more concise
  • Maintains the same functionality while being easier to maintain

Line range hint 115-121: Simplify complex version selection logic

The current version selection using nested ternary operators is hard to read and maintain.

Consider simplifying the version selection:

- version: tags/${{ github.event.inputs.name && github.event.inputs.name != 'blank' && github.event.inputs.name || github.event.inputs.new_tag }}
- file: reearth-web_${{ github.event.inputs.name && github.event.inputs.name != 'blank' && github.event.inputs.name || github.event.inputs.new_tag }}.tar.gz
+ env:
+   RELEASE_VERSION: ${{ github.event.inputs.name != 'blank' && github.event.inputs.name || github.event.inputs.new_tag }}
+ version: tags/${{ env.RELEASE_VERSION }}
+ file: reearth-web_${{ env.RELEASE_VERSION }}.tar.gz

This change:

  • Reduces duplication
  • Improves readability
  • Makes debugging easier
  • Reduces the chance of inconsistencies
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between eccf842 and 7c07dbf.

📒 Files selected for processing (1)
  • .github/workflows/build_server.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/build_server.yml (1)

43-43: Verify impact of removing --rm-dist flag

While removing the --rm-dist flag may fix the immediate build failure, this could lead to:

  • Mixing of old and new artifacts in the dist directory
  • Accumulation of artifacts over multiple builds
  • Potential confusion about artifact origins

Let's verify the impact:

Consider adding an explicit cleanup step before the GoReleaser action:

- name: Clean dist directory
  run: rm -rf server/dist
  if: success() || failure()    # Run on both success and failure
✅ Verification successful

Removing --rm-dist flag is safe in this context

The workflow already handles artifacts appropriately:

  • Build artifacts are stored in a specific path server/dist/reearth_*.*
  • The workflow includes a verification step that lists dist contents (ls -l server/dist)
  • GoReleaser is configured to use a specific distribution and tag

The removal of --rm-dist flag won't cause issues because:

  • Each workflow run starts with a fresh environment
  • Artifacts are properly scoped to the server/dist directory
  • The build process is isolated per workflow execution
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any existing issues or discussions about --rm-dist
rg -i "rm-dist|clean dist" .github/
# Check for any cleanup steps in other workflows
fd -t f . .github/workflows/ --exec grep -l "clean" {} \;

Length of output: 98


Script:

#!/bin/bash
# Let's check the goreleaser configuration and related files
fd -t f "\.ya?ml$" . -E ".git" --exec grep -l "goreleaser|dist" {} \;

# Check the content of goreleaser config if it exists
fd "\.goreleaser\.ya?ml$" . -E ".git" --exec cat {} \;

# Look for any cleanup or dist-related tasks in workflow files
rg "(?i)(clean|dist|goreleaser)" .github/workflows/

Length of output: 807

@pyshx pyshx merged commit b564122 into main Dec 5, 2024
14 of 16 checks passed
@pyshx pyshx deleted the fix/workflows-build-server branch December 5, 2024 04:49
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