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: remove nix from gh workflows #21572

Merged
merged 4 commits into from
Sep 11, 2024
Merged

ci: remove nix from gh workflows #21572

merged 4 commits into from
Sep 11, 2024

Conversation

auricom
Copy link
Contributor

@auricom auricom commented Sep 6, 2024

Description

Objective is to remove nix, that was required for rocksdb libraries.
This will help reducing complexity and streamline the ci experience.

rocksdb libraries are now installed directly on public ubuntu runners, then cached to improve execution time.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a script to automate the installation of the RocksDB database library, streamlining setup for developers.
    • Added version control for RocksDB in the build and test workflows, enhancing consistency.
  • Bug Fixes

    • Improved caching mechanisms for RocksDB libraries, reducing build times and optimizing resource usage.
  • Documentation

    • Updated workflows to clarify the integration and management of RocksDB libraries.
  • Refactor

    • Simplified workflow steps for linting and testing, enhancing clarity and efficiency.

Copy link
Contributor

coderabbitai bot commented Sep 6, 2024

Walkthrough

Walkthrough

This pull request introduces a shell script for automating the installation of the RocksDB database library on Unix-like systems, along with modifications to GitHub Actions workflows for build, linting, and testing processes. It includes version control for RocksDB, enhances caching strategies, and simplifies the setup and execution of tests. Additionally, it updates the Go version used in the workflows and modifies linting scripts to accommodate the new RocksDB integration.

Changes

Files Change Summary
.github/scripts/install-rocksdb.sh Added a script to automate the installation of RocksDB, including checks for the ROCKSDB_VERSION, dependency installation, repository cloning, version checkout, compilation, and installation.
.github/workflows/build.yml Introduced ROCKSDB_VERSION environment variable, enhanced caching for RocksDB libraries, simplified build conditions, and updated job steps for better efficiency.
.github/workflows/lint.yml Added ROCKSDB_VERSION, improved caching for RocksDB libraries, replaced nix commands with make lint, and set permissions for cache directories.
.github/workflows/test.yml Added ROCKSDB_VERSION, removed nix commands, updated Go version, and streamlined test execution with caching for RocksDB libraries.
scripts/go-lint-all.bash Modified linting logic to check for ROCKSDB instead of NIX, affecting the LINT_TAGS variable.
scripts/go-mod-tidy-all.sh Removed logic related to updating gomod2nix.toml, focusing solely on updating go.mod files in the current directory.

Possibly related PRs

Suggested labels

C:server/v2, C:collections, C:x/bank, C:x/evidence, C:x/upgrade, C:x/slashing, C:x/distribution, C:x/mint, C:x/params, C:x/authz, C:x/group, C:x/nft, C:x/epochs, C:x/protocolpool, C:x/consensus, C:core/testing, C:orm, C:server/v2 appmanager, C:server/v2 cometbft


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.

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.

@@ -14,8 +15,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
Copy link
Member

Choose a reason for hiding this comment

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

YES, thank you!!
We would be able to remove so much boilerplate from scripts, ci etc..

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Sep 6, 2024
@auricom auricom force-pushed the claude/gomod2nix branch 2 times, most recently from 8b90c9d to 8b071f1 Compare September 6, 2024 11:44
path: /usr/local/lib
key: ${{ runner.os }}-rocksdb-${{ matrix.go-arch }}
- name: install rocksdb
if: env.GIT_DIFF && steps.cache-rocksdb.outputs.cache-hit != 'true'
Copy link
Contributor Author

@auricom auricom Sep 9, 2024

Choose a reason for hiding this comment

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

As rocksdb compilation lasts ~8mn on public runners, it will be executed only when cache is invalidated by github (should be once every 7 days OR when changing rocksdb version)

Comment on lines 43 to 47
sudo apt update && sudo apt-get install -y zlib1g-dev libbz2-dev libzstd-dev build-essential
git clone https://github.com/facebook/rocksdb.git /home/runner/rocksdb
cd /home/runner/rocksdb || exit 1
git checkout "v$ROCKSDB_VERSION"
sudo make -j "$(nproc --all)" shared_lib && sudo ldconfig
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rocksdb is now installed directly on public runners. it is made available on /usr/local/lib

@auricom auricom force-pushed the claude/gomod2nix branch 2 times, most recently from 6dd64be to 54cfe68 Compare September 9, 2024 08:26
@auricom auricom marked this pull request as ready for review September 9, 2024 14:03
@auricom auricom requested review from facundomedica and a team as code owners September 9, 2024 14:03
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: 4

Outside diff range, codebase verification and nitpick comments (3)
.github/workflows/lint.yml (1)

33-34: Fix Permissions for Cache: Potential Security Implications

Setting permissions with sudo chown to allow the current user to access system directories can have security implications. Consider using a safer approach or ensuring that this change is well-documented and understood by all stakeholders.

Tools
actionlint

34-34: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)

.github/workflows/test.yml (2)

793-794: Fix Permissions for Cache: Potential Security Implications

As noted in the lint workflow, setting permissions with sudo chown to allow the current user to access system directories can have security implications. Consider using a safer approach or ensuring that this change is well-documented and understood by all stakeholders.

Tools
actionlint

794-794: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)


849-849: Fix Permissions for Cache: Potential Security Implications

As noted in previous workflows, setting permissions with sudo chown to allow the current user to access system directories can have security implications. Consider using a safer approach or ensuring that this change is well-documented and understood by all stakeholders.

Tools
actionlint

849-849: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5028893 and 02efb47.

Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
Files selected for processing (6)
  • .github/scripts/install-rocksdb.sh (1 hunks)
  • .github/workflows/build.yml (3 hunks)
  • .github/workflows/lint.yml (3 hunks)
  • .github/workflows/test.yml (5 hunks)
  • scripts/go-lint-all.bash (1 hunks)
  • scripts/go-mod-tidy-all.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • scripts/go-mod-tidy-all.sh
Additional context used
actionlint
.github/workflows/build.yml

32-32: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)

.github/workflows/lint.yml

34-34: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)

.github/workflows/test.yml

794-794: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)


849-849: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)

Additional comments not posted (22)
.github/scripts/install-rocksdb.sh (1)

2-2: Good use of set -e for error handling.

This command ensures that the script will exit immediately if a command exits with a non-zero status, which is a good practice in shell scripts to prevent cascading failures.

scripts/go-lint-all.bash (1)

9-9: Conditional logic for ROCKSDB environment variable.

The script now checks if the ROCKSDB environment variable is set and appends ,rocksdb to LINT_TAGS if true. This is a sensible change that allows conditional inclusion of RocksDB-related linting tags based on the environment configuration. Ensure that the ROCKSDB variable is properly set in environments where RocksDB-specific linting is required.

.github/workflows/build.yml (3)

16-18: Addition of ROCKSDB_VERSION environment variable.

The introduction of the ROCKSDB_VERSION environment variable is a good practice for managing the version of RocksDB used across different builds. This ensures consistency and traceability of the build environment.


31-53: Enhanced caching and installation steps for RocksDB.

The workflow now includes steps to fix permissions, restore RocksDB libraries from cache, and install RocksDB if not cached. These steps are crucial for optimizing build times and ensuring that the RocksDB installation is handled correctly across builds. However, ensure that the cache keys are correctly configured to avoid potential issues with cache invalidation.

key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-${{ matrix.go-arch }}
Tools
actionlint

32-32: shellcheck reported issue in this script: SC2046:warning:1:12: Quote this to prevent word splitting

(shellcheck)


62-63: Simplified conditional logic for building with RocksDB backend.

The conditional logic to build with the RocksDB backend has been simplified to only check if the architecture is amd64. This makes the workflow easier to understand and maintain. Ensure that this condition correctly reflects the project's requirements for building with RocksDB.

.github/workflows/lint.yml (8)

13-13: Environment Variable Added: ROCKSDB_VERSION

The addition of the ROCKSDB_VERSION environment variable is a good practice for managing library versions centrally, which simplifies updates and ensures consistency across CI jobs.


36-42: Restore RocksDB Libraries Cache: Well-Implemented

This step efficiently handles the caching of RocksDB libraries, which should speed up the CI process by avoiding unnecessary reinstalls. The use of specific cache keys based on the OS and RocksDB version is a good practice.


44-46: Conditional Installation of RocksDB: Good Use of Conditional Steps

The conditional logic to check the cache hit status before proceeding with the installation is a smart way to optimize CI runtime. This ensures that RocksDB is only installed when necessary.


48-54: Saves RocksDB Libraries Cache: Effective Caching Strategy

This step effectively saves the RocksDB libraries to the cache after a successful installation, which is crucial for optimizing future runs. The configuration is consistent and uses the same key structure as the restore step.


59-59: Simplified Lint Command: Direct Call to Make

Replacing nix develop -c make lint with make lint simplifies the workflow and reduces the complexity previously introduced by Nix. This change aligns with the PR's goal of simplifying the CI process.


61-61: Environment Variable Modification: NIX to ROCKSDB

Changing the environment variable from NIX to ROCKSDB reflects the shift from Nix-based setups to direct management of RocksDB, supporting the PR's objectives.


88-88: Environment Variable Consistency: ROCKSDB

The consistent use of the ROCKSDB environment variable across different steps helps maintain clarity and ensures that all parts of the workflow are aligned with the new setup.


84-84: Repeated Lint Command: Ensure Necessity

The lint command is repeated in multiple steps. Ensure that this repetition is necessary and that each instance serves a specific purpose, possibly related to different conditions or setups.

Verification successful

Repeated Lint Command: Justified by Different Conditions

The repetition of the make lint command in the workflow file is justified by the different conditions and environment setups associated with each instance. Each command serves a specific purpose, tailored to different scenarios in the CI process.

  • The first instance is configured with ROCKSDB: 1.
  • The second instance is conditional on steps.lint_long.outcome == 'skipped' and uses GIT_DIFF and LINT_DIFF: 1.
  • The third instance combines GIT_DIFF, LINT_DIFF: 1, and ROCKSDB: 1.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the necessity of repeated lint commands.

# Test: Search for repeated lint commands. Expect: Justification for each repetition.
rg --type yaml -A 5 $'make lint' .github/workflows/lint.yml

Length of output: 549

.github/workflows/test.yml (9)

17-17: Environment Variable Added: ROCKSDB_VERSION

The addition of the ROCKSDB_VERSION environment variable is consistent with the changes in the lint workflow and is a good practice for managing library versions centrally.


795-802: Restore RocksDB Libraries Cache: Well-Implemented

This step efficiently handles the caching of RocksDB libraries, which should speed up the CI process by avoiding unnecessary reinstalls. The use of specific cache keys based on the OS and RocksDB version is a good practice.


804-806: Conditional Installation of RocksDB: Good Use of Conditional Steps

The conditional logic to check the cache hit status before proceeding with the installation is a smart way to optimize CI runtime. This ensures that RocksDB is only installed when necessary.


808-814: Saves RocksDB Libraries Cache: Effective Caching Strategy

This step effectively saves the RocksDB libraries to the cache after a successful installation, which is crucial for optimizing future runs. The configuration is consistent and uses the same key structure as the restore step.


819-819: Test Command: Direct Call to Go Test

The direct invocation of go test with specific tags and coverage options simplifies the testing process and aligns with the PR's goal of simplifying the CI setup by removing Nix.


850-857: Restore RocksDB Libraries Cache: Well-Implemented

This step efficiently handles the caching of RocksDB libraries, which should speed up the CI process by avoiding unnecessary reinstalls. The use of specific cache keys based on the OS and RocksDB version is a good practice.


859-861: Conditional Installation of RocksDB: Good Use of Conditional Steps

The conditional logic to check the cache hit status before proceeding with the installation is a smart way to optimize CI runtime. This ensures that RocksDB is only installed when necessary.


863-869: Saves RocksDB Libraries Cache: Effective Caching Strategy

This step effectively saves the RocksDB libraries to the cache after a successful installation, which is crucial for optimizing future runs. The configuration is consistent and uses the same key structure as the restore step.


874-874: Test Command: Direct Call to Go Test

The direct invocation of go test with specific tags and coverage options simplifies the testing process and aligns with the PR's goal of simplifying the CI setup by removing Nix.

.github/scripts/install-rocksdb.sh Outdated Show resolved Hide resolved
.github/scripts/install-rocksdb.sh Outdated Show resolved Hide resolved
.github/scripts/install-rocksdb.sh Show resolved Hide resolved
.github/scripts/install-rocksdb.sh Show resolved Hide resolved
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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 02efb47 and 22c9201.

Files selected for processing (1)
  • .github/scripts/install-rocksdb.sh (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/scripts/install-rocksdb.sh

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

ACK. It removes complexity in CI, love it!

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

are we sure we want to remove nix it was used to keep all deps the same version across environments for rocksdb, is that still useful?

@julienrbrt
Copy link
Member

julienrbrt commented Sep 9, 2024

are we sure we want to remove nix it was used to keep all deps the same version across environments for rocksdb, is that still useful?

If we hard-code the rocksdb version in the script, that is essentially the same thing.
@auricom is gonna add a workflow to bump the dep automatically too (while currently that wasn't the case).
My issue was that no one had enough context to fix it when there were issues (issue with gomod2nix, bumping to latest go version). Additionally, it felt overkilled to have this in our scripts, CI, SDK and simapp, just for one dep.
This PR is more readable, faster and doesn't add a whole new package manager for one dep.

@julienrbrt julienrbrt added this pull request to the merge queue Sep 11, 2024
Merged via the queue into main with commit c536c0f Sep 11, 2024
67 checks passed
@julienrbrt julienrbrt deleted the claude/gomod2nix branch September 11, 2024 08:19
mergify bot pushed a commit that referenced this pull request Sep 11, 2024
(cherry picked from commit c536c0f)

# Conflicts:
#	.github/workflows/lint.yml
julienrbrt added a commit that referenced this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release Type: Build Type: CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants