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

Feat: Adding ci/cd pipeline using dagger #37

Merged
merged 21 commits into from
Sep 3, 2024

Conversation

Mehul-Kumar-27
Copy link
Collaborator

@Mehul-Kumar-27 Mehul-Kumar-27 commented Aug 3, 2024

  • Part of Create Dagger CI/CD  #35
  • build satellite and ground control binaries
  • Release process for satellite and ground control, each independent of the other.
  • Run unit test
  • Also adds README.md for dagger installation.

Summary by CodeRabbit

  • New Features

    • Introduced a new CI system for the "ground control" and "satellite" components, automating the build, testing, and release processes.
    • Added a new job to the CI/CD pipeline for enhanced build management.
  • Improvements

    • Enhanced error handling and conditional execution in the main application flow.
    • Improved clarity and robustness of the CI/CD workflow with structured job definitions.
    • Comprehensive documentation for setting up and using the Dagger CI/CD pipeline.
    • Enhanced Docker management capabilities for improved container operations.
    • Streamlined build process with updated installation steps and job configurations.

@github-actions github-actions bot added the golang label Aug 3, 2024
Copy link

coderabbitai bot commented Aug 3, 2024

Walkthrough

The recent changes enhance the CI/CD workflow by modifying GitHub Actions jobs and introducing new functionalities for the Harbor Satellite and Ground Control components. The updates streamline the build process, improve job organization, and provide comprehensive documentation for users.

Changes

File(s) Change Summary
.github/workflows/build.yaml Renamed job dagger-build to dagger-build-satellite; added dagger-build-ground-control job; improved job execution conditions and streamlined steps for clarity.
ci/*.go Implemented HarborSatellite struct; enhanced methods for building and releasing binaries; introduced utility functions for managing Docker containers.
ci/README.md Added comprehensive documentation for setting up and using the Dagger CI/CD pipeline tailored for the Harbor Satellite project, including installation and usage instructions.
ci/utils.go Introduced methods for managing Docker containers, including Attach for starting Docker daemons and Service for configuring Docker services.
.goreleaser.yaml & ground-control/.goreleaser.yaml Added GoReleaser configuration files to automate the release process, specifying versioning, build settings, and archive formats.

Poem

🐰 In fields of code where rabbits play,
New jobs and structs have come to stay.
With builds and tests, we hop with glee,
CI flows like a gentle stream,
In harmony, we dream and scheme! 🌼✨

Tip

We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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

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

Outside diff range, codebase verification and nitpick comments (3)
ci/config/config.go (1)

6-6: Use consistent naming conventions.

The field Github_Repository uses an inconsistent naming convention compared to other fields. Consider renaming it to GithubRepository for consistency.

-	Github_Repository string
+	GithubRepository string
.github/workflows/build.yaml (2)

14-14: Clarify the condition for running jobs.

The comment explains the condition for running jobs but can be made more concise.

-    # unless you specify the success on the event,
-    # this job will also run if the lint workflow was skipped(which is also the case if the condition for the file extension type is false).
+    # This job runs only if the lint workflow concluded successfully.

38-39: Remove redundant Docker installation verification.

Verifying Docker installation can be redundant as errors during installation will be caught.

-      - name: Verify Docker installation
-        run: docker --version
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ec1e82c and efab9b4.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (6)
  • .github/workflows/build.yaml (1 hunks)
  • ci/config/config.go (1 hunks)
  • ci/ground_control/ground_control.go (1 hunks)
  • ci/main.go (2 hunks)
  • ci/satellite/satellite.go (1 hunks)
  • go.mod (2 hunks)
Additional comments not posted (19)
ci/main.go (1)

30-35: Approve the configuration struct initialization.

The initialization of the Config struct is correct and aligns with the defined struct.

.github/workflows/build.yaml (5)

55-55: Clarify the condition for running jobs.

The comment explains the condition for running jobs but can be made more concise.

-    # unless you specify the success on the event,
-    # this job will also run if the lint workflow was skipped(which is also the case if the condition for the file extension type is false).
+    # This job runs only if the lint workflow concluded successfully.

69-74: Combine steps for updating and installing CA certificates.

The steps for updating and installing CA certificates can be combined for brevity.

-      - name: Update CA certificates
+      - name: Update and install CA certificates
        run: |
          sudo apt-get update
          sudo apt-get install -y ca-certificates
          sudo update-ca-certificates

75-77: Combine steps for installing curl.

The steps for installing curl can be combined for brevity.

-      - name: Install curl
+      - name: Install curl and Docker
        run: |
          sudo apt-get install -y curl
          curl -fsSL https://get.docker.com -o get-docker.sh
          sudo sh get-docker.sh

83-84: Remove redundant Docker installation verification.

Verifying Docker installation can be redundant as errors during installation will be caught.

-      - name: Verify Docker installation
-        run: docker --version

24-29: Combine steps for updating and installing CA certificates.

The steps for updating and installing CA certificates can be combined for brevity.

-      - name: Update CA certificates
+      - name: Update and install CA certificates
        run: |
          sudo apt-get update
          sudo apt-get install -y ca-certificates
          sudo update-ca-certificates

Likely invalid or redundant comment.

ci/satellite/satellite.go (4)

27-33: LGTM!

The NewSatelliteCI method correctly initializes the SatelliteCI struct.


35-49: LGTM!

The StartSatelliteCI method correctly orchestrates the CI process and handles errors appropriately.


51-65: LGTM!

The ExecuteTests method correctly runs Go tests and handles errors appropriately.


Line range hint 91-130:
LGTM!

The ReleaseBinary method correctly handles the release process and logs errors appropriately.

ci/ground_control/ground_control.go (4)

27-33: LGTM!

The NewGroundControlCI method correctly initializes the GroundControlCI struct.


35-50: LGTM!

The StartGroundControlCI method correctly orchestrates the CI process and handles errors appropriately.


52-66: LGTM!

The ExecuteTests method correctly runs Go tests and handles errors appropriately.


93-130: LGTM!

The ReleaseBinary method correctly handles the release process and logs errors appropriately.

go.mod (5)

18-18: LGTM!

The addition of github.com/google/go-github/v39 is appropriate for interacting with the GitHub API.


21-21: LGTM!

The addition of github.com/stretchr/testify is appropriate for writing unit tests.


22-22: LGTM!

The addition of golang.org/x/oauth2 is appropriate for OAuth2 authentication.


400-400: LGTM!

The movement of go.uber.org/zap to an indirect requirement is appropriate as it is no longer directly used in the main application code.


22-22: LGTM!

The removal of gopkg.in/natefinch/lumberjack.v2 is appropriate as it indicates an update or replacement of the logging strategy.

ci/main.go Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
.github/workflows/build.yaml Outdated Show resolved Hide resolved
ci/satellite/satellite.go Outdated Show resolved Hide resolved
ci/ground_control/ground_control.go Outdated Show resolved Hide resolved
@Mehul-Kumar-27
Copy link
Collaborator Author

@Vad1mo , I would be grateful if you could review this.

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

Outside diff range, codebase verification and nitpick comments (1)
.github/workflows/build.yaml (1)

24-28: Combine steps for updating CA certificates.

The steps for updating CA certificates can be combined for brevity.

-      - name: Update CA certificates
-        run: |
-          sudo apt-get update
-          sudo apt-get install -y ca-certificates
-          sudo update-ca-certificates
+      - name: Update CA certificates
+        run: |
+          sudo apt-get update && sudo apt-get install -y ca-certificates && sudo update-ca-certificates
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between efab9b4 and 3ad87bb.

Files selected for processing (2)
  • .github/workflows/build.yaml (1 hunks)
  • ci/main.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ci/main.go
Additional comments not posted (14)
.github/workflows/build.yaml (14)

10-10: Job name change is appropriate.

Renaming the job to dagger-build-satellite clearly indicates its purpose.


14-14: Good use of conditional execution.

The if statement ensures that the job only runs if the previous workflow run was successful.


19-22: Ensure compatibility with Go versions.

Specifying go-version: '>=1.22' ensures compatibility with newer versions of Go.


30-34: Combine steps for installing curl and Docker.

The steps for installing curl and Docker can be combined for brevity.

-      - name: Install curl and Docker
-        run: |
-          sudo apt-get install -y curl
-          curl -fsSL https://get.docker.com -o get-docker.sh
-          sudo sh get-docker.sh
+      - name: Install curl and Docker
+        run: |
+          sudo apt-get install -y curl && curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh

36-37: Verify Docker installation is a good practice.

Verifying Docker installation ensures that Docker is correctly installed.


45-51: Environment variables usage is appropriate.

Using environment variables for the build step ensures that necessary information is available.


53-53: New job name is clear and descriptive.

Adding the job dagger-build-ground-control clearly indicates its purpose.


57-57: Good use of conditional execution.

The if statement ensures that the job only runs if the previous workflow run was successful.


62-65: Ensure compatibility with Go versions.

Specifying go-version: '>=1.22' ensures compatibility with newer versions of Go.


67-71: Combine steps for updating CA certificates.

The steps for updating CA certificates can be combined for brevity.

-      - name: Update CA certificates
-        run: |
-          sudo apt-get update
-          sudo apt-get install -y ca-certificates
-          sudo update-ca-certificates
+      - name: Update CA certificates
+        run: |
+          sudo apt-get update && sudo apt-get install -y ca-certificates && sudo update-ca-certificates

73-77: Combine steps for installing curl and Docker.

The steps for installing curl and Docker can be combined for brevity.

-      - name: Install curl and Docker
-        run: |
-          sudo apt-get install -y curl
-          curl -fsSL https://get.docker.com -o get-docker.sh
-          sudo sh get-docker.sh
+      - name: Install curl and Docker
+        run: |
+          sudo apt-get install -y curl && curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh

79-80: Verify Docker installation is a good practice.

Verifying Docker installation ensures that Docker is correctly installed.


82-86: Consider using a versioned URL for Dagger CLI installation.

Using a versioned URL for installing Dagger CLI ensures that a specific version is installed, which can help avoid issues with future updates.

-      - name: Install Dagger CLI
-        run: |
-          cd /usr/local
-          curl -L https://dl.dagger.io/dagger/install.sh | sudo sh
-          cd -
+      - name: Install Dagger CLI
+        run: |
+          cd /usr/local
+          curl -L https://dl.dagger.io/dagger/install.sh | sudo sh
+          cd -
+        env:
+          DAGGER_VERSION: '0.3.0' # Example version

88-94: Environment variables usage is appropriate.

Using environment variables for the build step ensures that necessary information is available.

.github/workflows/build.yaml Outdated Show resolved Hide resolved
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: 1

Outside diff range, codebase verification and nitpick comments (1)
.github/workflows/build.yaml (1)

24-28: Combine steps for installing CA certificates.

The steps for updating and installing CA certificates can be combined for brevity.

-      - name: Update CA certificates
-        run: |
-          sudo apt-get update
-          sudo apt-get install -y ca-certificates
-          sudo update-ca-certificates
+      - name: Update CA certificates
+        run: |
+          sudo apt-get update && sudo apt-get install -y ca-certificates && sudo update-ca-certificates
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3ad87bb and 5d9d16e.

Files selected for processing (3)
  • .github/workflows/build.yaml (1 hunks)
  • ci/ground_control/ground_control.go (1 hunks)
  • ci/satellite/satellite.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ci/ground_control/ground_control.go
Additional comments not posted (18)
.github/workflows/build.yaml (14)

30-34: Combine steps for installing curl and Docker.

The steps for installing curl and Docker can be combined for brevity.


39-43: Consider using a versioned URL for Dagger CLI installation.

Using a versioned URL for installing Dagger CLI ensures that a specific version is installed, which can help avoid issues with future updates.


53-57: Ensure the if condition is correct.

The job runs only if the previous workflow run was successful. Verify that this is the intended behavior.


60-60: Use the latest version of actions/checkout.

Ensure that the latest stable version of actions/checkout is used.


63-65: Use the latest version of actions/setup-go.

Ensure that the latest stable version of actions/setup-go is used.


68-71: Combine steps for installing CA certificates.

The steps for updating and installing CA certificates can be combined for brevity.


73-77: Combine steps for installing curl and Docker.

The steps for installing curl and Docker can be combined for brevity.


82-86: Consider using a versioned URL for Dagger CLI installation.

Using a versioned URL for installing Dagger CLI ensures that a specific version is installed, which can help avoid issues with future updates.


88-94: Ensure environment variables are correctly set.

Verify that the environment variables are correctly set and used in the build process.


2-4: Ensure the workflow triggers are appropriate.

The workflow is triggered by the completion of the Lint workflow. Verify that this is the intended behavior.

Verification successful

The workflow triggers are correctly set up.

The build.yaml workflow is triggered by the completion of the Lint workflow, which matches the intended behavior.

  • .github/workflows/build.yaml
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the workflow triggers.

# Test: Search for the workflow definitions. Expect: Only occurrences of the `Lint` workflow.
rg --type yaml -A 5 $'workflows: [Lint]'

Length of output: 41


Script:

#!/bin/bash
# Description: List all workflow files and inspect their triggers.

# Step 1: List all YAML files in the .github/workflows/ directory.
workflow_files=$(fd .yaml .github/workflows/)

# Step 2: For each workflow file, print the file name and the first 10 lines to check the triggers.
for file in $workflow_files; do
  echo "File: $file"
  head -n 10 "$file"
  echo
done

Length of output: 1224


14-14: Ensure the if condition is correct.

The job runs only if the previous workflow run was successful. Verify that this is the intended behavior.

Verification successful

The if condition is correct.

The job is configured to run only if the previous workflow run was successful, as intended.

  • .github/workflows/build.yaml:
    • Line 14: if: ${{ github.event.workflow_run.conclusion == 'success' }}
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `if` condition in the workflow.

# Test: Search for the `if` condition usage. Expect: Only occurrences of the `success` condition.
rg --type yaml -A 5 $'if: ${{ github.event.workflow_run.conclusion == \'success\' }}'

Length of output: 239


Script:

#!/bin/bash
# Description: Verify the `if` condition in the workflow.

# Test: Search for the `if` condition usage. Expect: Only occurrences of the `success` condition.
rg --type yaml -A 5 "if: \${{ github.event.workflow_run.conclusion == 'success' }}"

Length of output: 239


Script:

#!/bin/bash
# Description: Verify the `if` condition in the workflow.

# Test: Search for the `if` condition usage. Expect: Only occurrences of the `success` condition.
grep -F -r "if: \${{ github.event.workflow_run.conclusion == 'success' }}" .github/workflows/

Length of output: 288


20-22: Use the latest version of actions/setup-go.

Ensure that the latest stable version of actions/setup-go is used.


17-17: Use the latest version of actions/checkout.

Ensure that the latest stable version of actions/checkout is used.


45-51: Ensure environment variables are correctly set.

Verify that the environment variables are correctly set and used in the build process.

Verification successful

Environment variables are correctly set and used.

The environment variables GITHUB_TOKEN, GITHUB_USERNAME, GITHUB_REPOSITORY, and GITHUB_SHA are correctly set in the .github/workflows/build.yaml file.

  • .github/workflows/build.yaml:
    • GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    • GITHUB_USERNAME: ${{ github.repository_owner }}
    • GITHUB_REPOSITORY: ${{ github.repository }}
    • GITHUB_SHA: ${{ github.sha }}
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the environment variables in the build process.

# Test: Search for the environment variables usage. Expect: Only occurrences of the correct variables.
rg --type yaml -A 5 $'env:\n  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n  GITHUB_USERNAME: ${{ github.repository_owner }}\n  GITHUB_REPOSITORY: ${{ github.repository }}\n  GITHUB_SHA: ${{ github.sha }}'

Length of output: 647


Script:

#!/bin/bash
# Description: Verify the environment variables in the build process.

# Test: Search for the environment variables usage. Expect: Only occurrences of the correct variables.
rg --type yaml -A 5 $'env:\n  GITHUB_TOKEN: \\${{ secrets.GITHUB_TOKEN }}\n  GITHUB_USERNAME: \\${{ github.repository_owner }}\n  GITHUB_REPOSITORY: \\${{ github.repository }}\n  GITHUB_SHA: \\${{ github.sha }}'

Length of output: 656


Script:

#!/bin/bash
# Description: Verify the environment variables in the build process.

# Test: Search for the individual environment variables usage. Expect: Occurrences of the correct variables.
rg --type yaml -A 2 'GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}'
rg --type yaml -A 2 'GITHUB_USERNAME: \${{ github.repository_owner }}'
rg --type yaml -A 2 'GITHUB_REPOSITORY: \${{ github.repository }}'
rg --type yaml -A 2 'GITHUB_SHA: \${{ github.sha }}'

Length of output: 833


Script:

#!/bin/bash
# Description: Verify the environment variables in the build process.

# Test: Search for the individual environment variables usage using fixed-string search.
grep -F -r 'GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}' .github/workflows/
grep -F -r 'GITHUB_USERNAME: ${{ github.repository_owner }}' .github/workflows/
grep -F -r 'GITHUB_REPOSITORY: ${{ github.repository }}' .github/workflows/
grep -F -r 'GITHUB_SHA: ${{ github.sha }}' .github/workflows/

Length of output: 939

ci/satellite/satellite.go (4)

27-33: LGTM!

The NewSatelliteCI method correctly initializes a new instance of the SatelliteCI struct.


35-48: LGTM!

The StartSatelliteCI method correctly executes tests, builds the satellite binary, and releases the binary.


67-94: LGTM! Consider adding more detailed logging.

The BuildSatellite method correctly builds the binary and handles errors appropriately. However, adding more detailed logging could help with debugging and monitoring the build process.


96-133: LGTM!

The ReleaseBinary method correctly releases the binary to GitHub and handles errors appropriately.

ci/satellite/satellite.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@bupd bupd left a comment

Choose a reason for hiding this comment

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

Useful Links:

Changes needed:

  • Implement dagger functions
  • Invoke the dagger pipeline as a single process which contains all the business logic.
  • By doing this, we have a multiple dagger functions build test release.
  • which we can invoke with dagger github action.

.github/workflows/build.yaml Outdated Show resolved Hide resolved
.github/workflows/build.yaml Outdated Show resolved Hide resolved
ci/ground_control/ground_control.go Outdated Show resolved Hide resolved
ci/satellite/satellite.go Outdated Show resolved Hide resolved
@Mehul-Kumar-27
Copy link
Collaborator Author

Useful Links:

Changes needed:

  • Implement dagger functions
  • Invoke the dagger pipeline as a single process which contains all the business logic.
  • By doing this, we have a multiple dagger functions build test release.
  • which we can invoke with dagger github action.

Thanks @bupd , for reviewing the PR. I am working on the required changes.

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

Outside diff range, codebase verification and nitpick comments (4)
ci/utils.go (2)

10-28: Consider adding comments for better readability.

The function Attach is well-defined but can be improved by adding comments to explain the steps.

+  // Attach a Docker service to the container and set the DOCKER_HOST environment variable

30-55: Consider adding comments for better readability.

The function Service is well-defined but can be improved by adding comments to explain the steps.

+  // Get a Docker service container running dockerd
ci/satellite.go (2)

11-24: Consider adding comments for better readability.

The function StartSatelliteCi is well-defined but can be improved by adding comments to explain the steps.

+  // Build and release the satellite component

26-51: Consider adding comments for better readability.

The function ExecuteTestsForSatellite is well-defined but can be improved by adding comments to explain the steps.

+  // Execute tests for the satellite component
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5d9d16e and 7a41bfe.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (10)
  • .github/workflows/build.yaml (1 hunks)
  • ci/.gitattributes (1 hunks)
  • ci/.gitignore (1 hunks)
  • ci/ground_control.go (1 hunks)
  • ci/main.go (1 hunks)
  • ci/release.sh (1 hunks)
  • ci/satellite.go (1 hunks)
  • ci/utils.go (1 hunks)
  • dagger.json (1 hunks)
  • go.mod (5 hunks)
Files skipped from review due to trivial changes (3)
  • ci/.gitattributes
  • ci/.gitignore
  • dagger.json
Files skipped from review as they are similar to previous changes (1)
  • go.mod
Additional context used
golangci-lint
ci/ground_control.go

27-27: undefined: dag

(typecheck)

ci/main.go

22-22: undefined: dag

(typecheck)


27-27: undefined: dag

(typecheck)

Shellcheck
ci/release.sh

[warning] 6-6: This $? refers to echo/printf, not a previous command. Assign to variable to avoid it being overwritten.

(SC2320)


[warning] 87-87: UPLOAD appears unused. Verify use (or export if used externally).

(SC2034)

Additional comments not posted (7)
.github/workflows/build.yaml (4)

10-14: LGTM! The job declaration and permissions are correctly set.

The job dagger-build-satellite is defined with appropriate permissions for reading contents and writing packages.


15-17: Uncomment or revise the job execution condition.

The condition for job execution is commented out. Ensure the job runs only when the lint workflow succeeds.

-    # if: ${{ github.event.workflow_run.conclusion == 'success' }}
+    if: ${{ github.event.workflow_run.conclusion == 'success' }}

19-20: LGTM! The step for checking out the repository is correctly defined.

The step uses actions/checkout@v4 to check out the repository.


22-33: LGTM! The step for calling the Dagger function is correctly defined.

The step uses dagger/dagger-for-github@v5 with appropriate parameters for building and publishing.

ci/release.sh (1)

10-32: LGTM!

The function correctly prints the help message.

ci/main.go (2)

37-39: Ensure proper exit after logging errors.

Currently, the program does not exit after logging the error when the app name is not provided.

-	}
+		os.Exit(1)

45-48: Handle errors without panicking.

Instead of panicking, consider handling errors gracefully to improve the robustness of the CI/CD pipeline.

-			panic(err)
+			slog.Error("Panic executing Satellite CI: " + err.Error())
+			os.Exit(1)

ci/ground_control.go Show resolved Hide resolved
ci/ground_control.go Show resolved Hide resolved
ci/ground_control.go Outdated Show resolved Hide resolved
ci/release.sh Outdated Show resolved Hide resolved
ci/release.sh Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
@Mehul-Kumar-27 Mehul-Kumar-27 changed the title feat: Adding ci/cd pipeline using dagger WIP feat: Adding ci/cd pipeline using dagger Aug 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, codebase verification and nitpick comments (4)
.github/workflows/build.yaml (4)

10-11: Combine steps for installing curl and Docker.

The steps for installing curl and Docker can be combined for brevity.

-      - name: Install curl
+      - name: Install curl and Docker
        run: |
          sudo apt-get install -y curl
          curl -fsSL https://get.docker.com -o get-docker.sh
          sudo sh get-docker.sh

23-28: Consider using a versioned URL for Dagger CLI installation.

Using a versioned URL for installing Dagger CLI ensures that a specific version is installed, which can help avoid issues with future updates.

-      - name: Install Dagger CLI
-        run: |
-          cd /usr/local
-          curl -L https://dl.dagger.io/dagger/install.sh | sudo sh
-          cd -
+      - name: Install Dagger CLI
+        run: |
+          cd /usr/local
+          curl -L https://dl.dagger.io/dagger/install.sh | sudo sh
+          cd -
+        env:
+          DAGGER_VERSION: '0.3.0' # Example version

38-39: Combine steps for installing curl and Docker.

The steps for installing curl and Docker can be combined for brevity.

-      - name: Install curl
+      - name: Install curl and Docker
        run: |
          sudo apt-get install -y curl
          curl -fsSL https://get.docker.com -o get-docker.sh
          sudo sh get-docker.sh

51-56: Consider using a versioned URL for Dagger CLI installation.

Using a versioned URL for installing Dagger CLI ensures that a specific version is installed, which can help avoid issues with future updates.

-      - name: Install Dagger CLI
-        run: |
-          cd /usr/local
-          curl -L https://dl.dagger.io/dagger/install.sh | sudo sh
-          cd -
+      - name: Install Dagger CLI
+        run: |
+          cd /usr/local
+          curl -L https://dl.dagger.io/dagger/install.sh | sudo sh
+          cd -
+        env:
+          DAGGER_VERSION: '0.3.0' # Example version
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7a41bfe and 71c8f5f.

Files selected for processing (1)
  • .github/workflows/build.yaml (1 hunks)

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Aug 6, 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: 1

Outside diff range, codebase verification and nitpick comments (4)
ci/README.md (4)

7-7: Fix grammatical issue: Add missing article.

Add "the" before "Harbor Satellite" for clarity.

- Follow the steps below to set up Dagger:
+ Follow the steps below to set up Dagger for the Harbor Satellite:
Tools
LanguageTool

[uncategorized] ~7-~7: Possible missing article found.
Context: ...llite Follow the steps below to set up Dagger: ### 1. Install Dagger CLI Choose you...

(AI_HYDRA_LEO_MISSING_THE)


25-25: Fix indentation issue.

Correct the indentation for the unordered list item.

- - ```sh
+ ```sh
Tools
Markdownlint

25-25: Expected: 0; Actual: 1
Unordered list indentation

(MD007, ul-indent)


60-60: Fix heading level issue.

Correct the heading level to maintain consistency.

- #### Example: Building Satellite Binaries
+ ### Example: Building Satellite Binaries
Tools
Markdownlint

60-60: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


62-62: Fix indentation issue.

Correct the indentation for the unordered list item.

- - ```sh
+ ```sh
Tools
Markdownlint

62-62: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 71c8f5f and 0d3a746.

Files selected for processing (4)
  • ci/README.md (1 hunks)
  • ci/main.go (1 hunks)
  • ci/release.sh (1 hunks)
  • ci/satellite.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ci/satellite.go
Additional context used
LanguageTool
ci/README.md

[uncategorized] ~7-~7: Possible missing article found.
Context: ...llite Follow the steps below to set up Dagger: ### 1. Install Dagger CLI Choose you...

(AI_HYDRA_LEO_MISSING_THE)

Markdownlint
ci/README.md

60-60: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


25-25: Expected: 0; Actual: 1
Unordered list indentation

(MD007, ul-indent)


62-62: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)

Shellcheck
ci/release.sh

[warning] 6-6: This $? refers to echo/printf, not a previous command. Assign to variable to avoid it being overwritten.

(SC2320)


[warning] 88-88: UPLOAD appears unused. Verify use (or export if used externally).

(SC2034)

golangci-lint
ci/main.go

54-54: undefined: dag

(typecheck)


84-84: undefined: dag

(typecheck)

Additional comments not posted (10)
ci/README.md (2)

29-35: LGTM!

The instructions for generating Go code are clear and accurate.


37-51: LGTM!

The instructions for the folder structure are clear and accurate.

ci/release.sh (3)

11-33: LGTM!

The usage instructions are clear and accurate.


40-45: LGTM!

The environment variable checks are clear and accurate.


88-88: Fix unused variable issue.

The variable UPLOAD appears unused. Verify its use or remove it if it's not needed.

Tools
Shellcheck

[warning] 88-88: UPLOAD appears unused. Verify use (or export if used externally).

(SC2034)

ci/main.go (5)

20-46: LGTM!

The Start method is clear and includes proper error handling and logging.


48-50: LGTM!

The Build method is clear and accurate.


54-67: Fix undefined identifier issue.

The identifier dag is undefined. It should be dagger.

Tools
golangci-lint

54-54: undefined: dag

(typecheck)


84-89: Fix undefined identifier issue.

The identifier dag is undefined. It should be dagger.

Tools
golangci-lint

84-84: undefined: dag

(typecheck)


54-67: Fix undefined identifier issue.

The identifier dag is undefined. It should be dagger.

Tools
golangci-lint

54-54: undefined: dag

(typecheck)

ci/release.sh Outdated Show resolved Hide resolved
@Mehul-Kumar-27
Copy link
Collaborator Author

Hey @bupd,

I've made some changes to the build and release process. Could you please review them when you get time ?

I'm also facing some difficulties when running tests for the satellite project. It would be great if you could help me out.

The issue is that the tests require Docker to be running on the host that executes them. When I create a container using Docker, I keep encountering the error message: is docker running?. It seems that Docker either fails to start or isn't detected during the test execution within the container.

Here's what I've tried so far:

  • Running the tests by installing Docker within the container itself.
  • Attaching Docker as a service to the container running the tests. However, it still doesn't detect the DOCKER_HOST.
    Let me know if you have any suggestions or if you can assist with this.

CC: @Vad1mo

@Vad1mo
Copy link
Contributor

Vad1mo commented Aug 7, 2024

I'll a look into it early next week

@Vad1mo Vad1mo self-requested a review August 13, 2024 14:13
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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0d3a746 and 5741796.

Files selected for processing (2)
  • ci/main.go (1 hunks)
  • ci/satellite.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ci/satellite.go
Additional context used
golangci-lint
ci/main.go

55-55: undefined: dag

(typecheck)


85-85: undefined: dag

(typecheck)

Additional comments not posted (2)
ci/main.go (2)

21-47: LGTM! Error handling and logging are well-implemented.

The Start method effectively manages CI process initiation with clear logging and exit strategies.


49-51: LGTM! Delegation to the build function is clear.

The Build method is concise and effectively delegates to the build function.

ci/main.go Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@bupd bupd left a comment

Choose a reason for hiding this comment

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

To successfully merge this PR, it must implement the following features:

  • Separate build capability for Satellite and Ground Control binaries.
  • Ability to test binaries on the host machine.
  • Individual release process for both Satellite and Ground Control.
  • Option to run tests individually for either Satellite or Ground Control.
  • Conduct a test release for both Satellite and Ground Control components.

Meeting the above criteria will qualify this PR for merging.

ci/README.md Show resolved Hide resolved
ci/README.md Outdated Show resolved Hide resolved
ci/main.go Outdated Show resolved Hide resolved
ci/satellite.go Outdated Show resolved Hide resolved
ci/release.sh Outdated Show resolved Hide resolved
ci/ground_control.go Outdated Show resolved Hide resolved
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5741796 and eb9bda2.

Files selected for processing (7)
  • .gitignore (1 hunks)
  • .goreleaser.yaml (1 hunks)
  • ci/ground_control.go (1 hunks)
  • ci/main.go (1 hunks)
  • ci/satellite.go (1 hunks)
  • ground-control/.goreleaser.yaml (1 hunks)
  • internal/version/version.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • .gitignore
  • ground-control/.goreleaser.yaml
Files skipped from review as they are similar to previous changes (1)
  • ci/satellite.go
Additional context used
golangci-lint
ci/ground_control.go

12-12: undefined: dag

(typecheck)

ci/main.go

36-36: undefined: dag

(typecheck)


62-62: undefined: dag

(typecheck)

Additional comments not posted (5)
ci/ground_control.go (2)

12-12: Duplicate Comment: Fix undefined identifier issue.

The identifier dag is undefined. It should be dagger.

Tools
golangci-lint

12-12: undefined: dag

(typecheck)


15-18: Duplicate Comment: Improve error handling.

Consider providing more context in error messages and using fmt.Errorf to wrap errors for better traceability.

.goreleaser.yaml (1)

10-10: Verify environment variable settings.

Ensure that environment variables such as APP_NAME are correctly set in the CI/CD environment to avoid build and release issues.

ci/main.go (2)

36-36: Duplicate Comment: Fix undefined identifier issue.

The identifier dag is undefined. It should be dagger.

Tools
golangci-lint

36-36: undefined: dag

(typecheck)


62-62: Duplicate Comment: Fix undefined identifier issue.

The identifier dag is undefined. It should be dagger.

Tools
golangci-lint

62-62: undefined: dag

(typecheck)

internal/version/version.go Show resolved Hide resolved
.goreleaser.yaml Outdated Show resolved Hide resolved
@bupd
Copy link
Collaborator

bupd commented Aug 24, 2024

@Mehul-Kumar-27 please do a test release on your repo to confirm.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eb9bda2 and 8bb9651.

Files selected for processing (4)
  • .github/workflows/build.yaml (1 hunks)
  • ci/README.md (1 hunks)
  • ci/main.go (1 hunks)
  • ci/utils.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ci/utils.go
Additional context used
golangci-lint
ci/main.go

33-33: undefined: dag

(typecheck)

LanguageTool
ci/README.md

[uncategorized] ~7-~7: Possible missing article found.
Context: ...llite Follow the steps below to set up Dagger: ### 1. Install Dagger CLI Choose you...

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~69-~69: You might be missing the article “an” here.
Context: ...provided. The above function also takes argument --release-type which would tell the r...

(AI_EN_LECTOR_MISSING_DETERMINER_AN)


[uncategorized] ~69-~69: The abbreviation “i.e.” (= that is) requires two periods.
Context: ... the release what kind of release it is i.e major, minor or path, The default value...

(I_E)

Markdownlint
ci/README.md

60-60: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


25-25: Expected: 0; Actual: 1
Unordered list indentation

(MD007, ul-indent)


62-62: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


67-67: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


72-72: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)

Additional comments not posted (2)
ci/main.go (1)

22-25: Review the Build method implementation.

The Build method is a wrapper around a private method build. Ensure that the build method is correctly implemented and handles errors appropriately.

.github/workflows/build.yaml (1)

10-82: Review the GitHub Actions configurations for consistency and correctness.

The new job configurations utilize the dagger/dagger-for-github@v5 action, which simplifies the build and release processes.

The changes streamline the workflow and improve the clarity of the build and release steps. Ensure that the environment variables and conditions are correctly set to prevent unauthorized access and ensure the workflow only runs under the correct conditions.

-    if: ${{ github.event.workflow_run.conclusion == 'success' }}
+    if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }}

ci/main.go Outdated Show resolved Hide resolved
ci/README.md Show resolved Hide resolved
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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8bb9651 and b4756a2.

Files selected for processing (3)
  • .goreleaser.yaml (1 hunks)
  • ci/main.go (1 hunks)
  • ground-control/.goreleaser.yaml (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • .goreleaser.yaml
  • ground-control/.goreleaser.yaml
Additional context used
golangci-lint
ci/main.go

34-34: undefined: dag

(typecheck)

Additional comments not posted (1)
ci/main.go (1)

5-19: Imports and constants are appropriately defined.

The import statements and constants are well-defined and support the functionality of the CI/CD operations described.

ci/main.go Show resolved Hide resolved
ci/main.go Show resolved Hide resolved
@Mehul-Kumar-27
Copy link
Collaborator Author

@Mehul-Kumar-27 please do a test release on your repo to confirm.

@bupd , I have test the release on my repo. The release and build commands are ready for the review. Please go through them and tell me if some additional changes are required.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b4756a2 and 5a839e6.

Files selected for processing (2)
  • ci/satellite.go (1 hunks)
  • ci/utils.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ci/utils.go
Additional context used
golangci-lint
ci/satellite.go

12-12: undefined: dag

(typecheck)

ci/satellite.go Show resolved Hide resolved
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5a839e6 and 86381c8.

Files selected for processing (1)
  • .github/workflows/build.yaml (1 hunks)
Additional comments not posted (5)
.github/workflows/build.yaml (5)

11-43: LGTM!

The dagger-build-satellite job is well-structured and follows best practices for using Dagger in GitHub Actions. The job name clearly indicates its purpose, and the permissions are appropriately set. The steps are logically organized and use the recommended actions and syntax. The job also uses environment variables to pass the necessary tokens and information.


45-77: LGTM!

The modifications to the build-ground-control job are consistent with the changes made to the dagger-build-satellite job. The job name remains unchanged, but the steps and permissions have been updated to align with the new workflow structure. The steps follow the same pattern as the dagger-build-satellite job, ensuring consistency in the CI/CD process. The job also uses environment variables to pass the necessary tokens and information.


3-9: LGTM!

The on trigger for the workflow is set up correctly. Triggering the workflow after the completion of the "Lint" workflow ensures that the code has passed the linting stage before proceeding with the build and release process. The workflow_dispatch trigger allows for manual execution of the workflow when needed.


1-77: Skipping similar comments.

The current changes have addressed the suggestions from the previous reviews. The workflow now uses the Dagger GitHub Action for building and releasing the binaries, and the steps for installing curl have been removed, as they are no longer needed with the use of the Dagger GitHub Action.


1-77: Workflow changes are consistent with the AI-generated summary.

The AI-generated summary accurately describes the changes made to the workflow. The summary mentions the addition of the dagger-build-satellite job and the modifications to the build-ground-control job. It also highlights the modular approach in the CI/CD process, allowing for separate handling of the satellite and ground control components. The workflow changes are consistent with the summary, which provides a clear and concise overview of the modifications made.

@Vad1mo Vad1mo changed the title WIP feat: Adding ci/cd pipeline using dagger Feat: Adding ci/cd pipeline using dagger Sep 3, 2024
@Vad1mo Vad1mo merged commit 02ba374 into container-registry:main Sep 3, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation golang
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants