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

Ci/setup #8

Merged
merged 12 commits into from
Aug 9, 2024
Merged

Ci/setup #8

merged 12 commits into from
Aug 9, 2024

Conversation

amimart
Copy link
Member

@amimart amimart commented Aug 9, 2024

Closes #7

Help this repository getting in shape for production ready setup.

Details

Configuration of the following CI workflows:

  • Lint;
  • Build;
  • Test;
  • Release;

Setup a Makefile covering lint, format, build, test and mock generation.

Some mock have been generated for the first interfaces.

@amimart amimart self-assigned this Aug 9, 2024
Copy link
Contributor

coderabbitai bot commented Aug 9, 2024

Walkthrough

The changes introduced enhance the CI/CD capabilities of the repository by implementing structured workflows for building, testing, and releasing a Go project. Key additions include automated linting, building, and testing processes, alongside a new release management strategy using Semantic Release. The integration of a Makefile simplifies common development tasks, while updates to Dependabot configurations optimize dependency management.

Changes

Files Change Summary
.github/dependabot.yml Added open-pull-requests-limit and assignees for dependency updates; introduced Go modules ecosystem configuration.
.github/workflows/*.yml Added build, linting, testing, and release workflows for the Go project, enhancing automation in CI/CD processes.
.golangci.yml Configured GolangCI linter with specific linters and settings to enforce coding standards.
.markdownlint.yaml Added options for header treatment and inline HTML in markdown files.
.releaserc.yml Configured for Semantic Release, managing versioning and changelog generation based on commit messages.
Makefile Established targets for linting, formatting, building, testing, and cleaning to streamline project management.
scripts/bump-module.sh Created an automation script for updating module paths based on semantic versioning rules.
testutil/*.go Introduced mock implementations for unit testing, enhancing test coverage and isolation.
version Introduced a versioning file with the initial version 0.0.0.

Assessment against linked issues

Objective Addressed Explanation
Setup CI with GitHub Actions Workflows (7)
Implement Makefile for development ease (7)
Improve code quality through linting (7)
Automate build and test processes (7)
Establish a release strategy (7)

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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@amimart amimart requested review from ccamel and bdeneux August 9, 2024 13:12
@amimart amimart marked this pull request as ready for review August 9, 2024 13:12
@amimart
Copy link
Member Author

amimart commented Aug 9, 2024

@ccamel @bdeneux The linter isn't happy because some elements are partially implemented, I propose let it go for now :)

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, codebase verification and nitpick comments (10)
scripts/bump-module.sh (1)

5-5: Consider validating the version file format.

The script assumes that the version file contains a valid semantic version. Consider adding validation to ensure the file format is correct before proceeding.

# Example validation
if ! [[ $major_version =~ ^[0-9]+$ ]]; then
  echo "Invalid version format in 'version' file"
  exit 1
fi
.github/workflows/test.yml (1)

25-34: Consider including shell scripts in the workflow trigger list.

The file ./scripts/bump-module.sh might affect test execution and should be considered for inclusion in the list of files that trigger the workflow.

  • Update the workflow to include relevant shell scripts.
Analysis chain

Review the list of files for triggering tests.

The workflow checks for changes in Go files, go.mod, go.sum, and the Makefile. Ensure that this list covers all files that might affect the test execution.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the list of files triggering test execution.

# Test: Check if additional files should trigger test execution.
rg --type go --files-with-matches 'package main' | grep -vE 'go\.mod|go\.sum|Makefile'

Length of output: 88


Script:

#!/bin/bash
# Description: Search for additional files that might affect test execution.

# Look for YAML, JSON, and shell script files that might be used in test configuration or execution.
fd --type f --extension yaml --extension yml --extension json --extension sh --exec echo "Potential test-related file: {}"

Length of output: 178

.releaserc.yml (1)

4-25: Review release rules for completeness.

The release rules cover various commit types and scopes. Ensure that these rules align with the project's release policy and consider if additional commit types or scopes are needed.

.golangci.yml (2)

5-5: Consider enabling more linters if needed.

While disabling all linters by default and enabling specific ones is a good practice, ensure that all necessary linters for your project's requirements are enabled. Review the list periodically to ensure comprehensive coverage.


66-66: Consider reviewing line-length limit.

The lll linter's line-length limit is set to 135. Ensure this aligns with your team's coding standards for readability.

Makefile (2)

4-4: Consider parameterizing the target folder.

The TARGET_FOLDER variable is hardcoded. Consider allowing it to be overridden by environment variables or command-line arguments for flexibility.


64-64: Ensure target folder creation is idempotent.

The test-go target creates the TARGET_FOLDER. Ensure this operation is idempotent to avoid errors if the folder already exists.

.github/workflows/lint.yml (3)

50-52: Consider reducing fetch depth.

Using fetch-depth: 0 can be resource-intensive. Consider using a shallow fetch if full history is not needed.

-        with:
-          fetch-depth: 0
+        # Consider using a shallow fetch if full history is not needed

95-97: Consider reducing fetch depth.

Similar to the lint-go job, using fetch-depth: 0 can be resource-intensive. Consider using a shallow fetch if full history is not needed.

-        with:
-          fetch-depth: 0
+        # Consider using a shallow fetch if full history is not needed

136-137: Document SHELLCHECK_OPTS usage.

Consider adding a comment to explain the purpose of the SHELLCHECK_OPTS environment variable for better clarity.

        env:
-          SHELLCHECK_OPTS: -e SC2034
+          SHELLCHECK_OPTS: -e SC2034 # Ignore warnings about unused variables
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c177d58 and 0ffde7d.

Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
Files selected for processing (13)
  • .github/dependabot.yml (1 hunks)
  • .github/workflows/build.yml (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
  • .github/workflows/test.yml (1 hunks)
  • .golangci.yml (1 hunks)
  • .markdownlint.yaml (1 hunks)
  • .releaserc.yml (1 hunks)
  • Makefile (1 hunks)
  • scripts/bump-module.sh (1 hunks)
  • testutil/auth_mocks.go (1 hunks)
  • testutil/dataverse_mocks.go (1 hunks)
  • version (1 hunks)
Files skipped from review due to trivial changes (3)
  • testutil/auth_mocks.go
  • testutil/dataverse_mocks.go
  • version
Additional comments not posted (18)
.markdownlint.yaml (1)

3-4: Markdown linting configuration approved.

The additions of first-line-h1: false and no-inline-html: false enhance the flexibility of markdown processing by allowing more control over header treatment and HTML usage.

.github/dependabot.yml (1)

7-20: Dependabot configuration approved.

The introduction of open pull request limits and the assignment of maintainers for review enhances dependency management efficiency. The addition of a gomod ecosystem is a valuable enhancement for Go projects.

.github/workflows/build.yml (1)

1-30: Build workflow configuration approved.

The new GitHub Actions workflow for building the Go project is well-structured. It effectively sets up the environment and uses concurrency to manage builds efficiently.

scripts/bump-module.sh (2)

1-3: Ensure portability across environments.

The use of #!/usr/bin/env bash is a good practice for portability across different systems. The set -eo pipefail command ensures that the script exits on errors and that pipelines fail if any command fails, which is a best practice for robustness.


7-29: Ensure compatibility with different sed implementations.

The script uses sed with different flags for macOS and other systems. This approach is correct, but ensure that all developers are aware of this requirement, as it could lead to issues if the environment changes.

Verification successful

Compatibility with sed Implementations Verified

The script correctly handles differences in sed syntax between macOS and other systems by using conditional logic based on the OS type. This ensures compatibility across different environments. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility of `sed` command across different environments.

# Test: Check if the script correctly identifies the OS and applies the right `sed` syntax.
uname -s

Length of output: 16


Script:

#!/bin/bash
# Search for all occurrences of `sed` in shell scripts to verify compatibility handling.
rg 'sed' --glob '*.sh' -A 2

Length of output: 730

.github/workflows/test.yml (3)

12-15: Concurrency control is well-implemented.

The concurrency setup ensures that only one workflow runs per branch at a time, canceling in-progress runs if a new one starts. This is a good practice to save resources and avoid conflicts.


52-60: Ensure Codecov token is securely managed.

The Codecov token is fetched from secrets, which is a best practice for security. Ensure that the secret is correctly set up in the repository settings.


1-11: Ensure branch specification matches project requirements.

The workflow triggers on pushes and pull requests to the main branch. Ensure this aligns with the project's branching strategy.

.releaserc.yml (3)

31-41: Ensure version file update is correctly configured.

The semantic-release-replace-plugin updates the version file. Verify that this file is correctly managed in the repository.


42-44: Ensure bump-module.sh script is executable.

The prepareCmd runs bump-module.sh. Ensure this script has execute permissions in the repository.

Verification successful

The bump-module.sh script is executable. No further action is needed regarding its execute permissions.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify execute permissions for `bump-module.sh`.

# Test: Check if the script is executable.
test -x scripts/bump-module.sh && echo "Executable" || echo "Not executable"

Length of output: 61


1-3: Verify branch configuration for releases.

The configuration specifies main as the release branch. Ensure this aligns with the project's release strategy.

Verification successful

Branch configuration for releases is correctly set.

The .releaserc.yml file specifies main as the release branch, which aligns with the project's release strategy. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify branch configuration for semantic release.

# Test: Check if the release branch is correctly set in the configuration.
rg --type yaml 'branches:\n  - main'

Length of output: 230


Script:

#!/bin/bash
# Description: Verify branch configuration for semantic release.

# Test: Check if the release branch is correctly set in the configuration with multiline support.
rg --multiline --type yaml 'branches:\n  - main' .releaserc.yml

Length of output: 84

.golangci.yml (1)

59-60: Review cyclomatic complexity threshold.

The cyclop linter's max complexity is set to 20. Consider whether this threshold aligns with your project's complexity requirements. A lower threshold might encourage simpler, more maintainable code.

.github/workflows/release.yml (3)

8-8: Review conditional execution for jobs.

The jobs are set to run only when the branch is main and the actor is bot-anik. Ensure this condition aligns with your release strategy and consider if other branches or actors should trigger the workflow.


30-30: Ensure OPS_TOKEN is securely managed.

The OPS_TOKEN secret is used for authentication. Verify that it is securely stored and managed to prevent unauthorized access.


35-36: Verify GPG key management.

The GPG key is imported for signing commits. Ensure the GPG key and passphrase are securely managed and rotated regularly.

Makefile (2)

28-32: Review Docker usage for linting.

The lint-go target uses Docker to run golangci-lint. Ensure that Docker is the best choice for your environment, as it may introduce overhead. Consider native execution if Docker is not necessary.


41-46: Review Docker usage for formatting.

The format-go target uses Docker to run gofumpt. Similar to linting, ensure Docker is the best choice for your environment.

.github/workflows/lint.yml (1)

65-72: Verify conditional execution logic.

Ensure that the conditional logic for checking if Go files have changed (steps.changed-go-files.outputs.any_changed == 'true') is functioning as expected. This condition is used multiple times and any issue could affect the job's execution.

Verification successful

Conditional execution logic is correctly implemented.

The conditional logic for checking if Go files have changed (steps.changed-go-files.outputs.any_changed == 'true') is correctly set up and used consistently in the workflow. The changed-go-files step is configured to track the appropriate files. Ensure that the tj-actions/changed-files action is functioning correctly to maintain this logic.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the conditional execution logic for changed Go files.

# Test: Check if the conditional logic correctly identifies changed Go files.
# Expect: Correct identification of changed files.
rg --type yaml 'steps\.changed-go-files\.outputs\.any_changed == .true.'

Length of output: 74


Script:

#!/bin/bash
# Search for the definition of 'changed-go-files' step and its outputs in the lint.yml file
rg 'changed-go-files' .github/workflows/lint.yml -A 5

Length of output: 908

Copy link
Contributor

@bdeneux bdeneux left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

👍

@amimart amimart merged commit f22c60b into main Aug 9, 2024
12 of 13 checks passed
@amimart amimart deleted the ci/setup branch August 9, 2024 14:09
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.

Production grade repository
3 participants