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

build(ci): optional jobs must report success to merge PR #993

Merged
merged 11 commits into from
Dec 12, 2024

Conversation

lklimek
Copy link
Collaborator

@lklimek lklimek commented Dec 9, 2024

Issue being fixed or feature implemented

When some Github Actions checks are marked as mandatory checks, but they don't get invoked (eg. the PR didn't modify files that trigger the check), they never pass and we need to force merge.

What was done?

Instead of adding on: pull_request: paths:, we use technote-space/get-diff-action@v6 to always run the workflow, and fail after first few steps.

Some disadvantage is that these tests are marked "green". Unfortunately, GHA does not implement neutral outcome, see actions/runner#2347.

How Has This Been Tested?

GHA

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Enhanced workflow checks for generated code to run consistently regardless of specific file changes.
    • Updated jobs to include new steps for fetching changes in Go and Proto files.
    • Retained error handling for generated code checks.
    • Simplified triggering conditions for end-to-end tests and linting workflows.
    • Streamlined testing process by ensuring steps execute only when relevant changes are detected.
    • Improved documentation and clarity of protocol definitions in the ABCI protocol.

Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

Warning

Rate limit exceeded

@lklimek has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f18a8c5 and 9b47506.

📒 Files selected for processing (1)
  • .github/workflows/check-generated.yml (2 hunks)

Walkthrough

The changes in the workflow configuration files enhance the checks for generated code by removing the paths specification under the pull_request trigger across multiple workflows. This allows checks to run regardless of specific file changes. New steps utilizing the technote-space/get-diff-action@v6 have been added to several jobs, which fetch changes for Go, Proto, and Docker files. The execution of these checks is now conditional on the presence of the GIT_DIFF environment variable, while error handling for generated code updates is retained.

Changes

File Change Summary
.github/workflows/check-generated.yml Modified to remove paths specification, enabling checks for generated code regardless of specific file changes. Added steps to use technote-space/get-diff-action@v6 for fetching changes, with execution conditional on GIT_DIFF. Error handling retained.
.github/workflows/e2e.yml Updated to remove path restrictions for triggering on pull requests. Added Dockerfile patterns to get-diff-action and clarified handling of Go module files. Conditional execution for several steps based on GIT_DIFF.
.github/workflows/lint.yml Removed specific path filters for pull_request trigger. Introduced conditional execution based on changes in Go files and configuration files. Added steps for using get-diff-action.
.github/workflows/tests.yml Removed paths specification for triggering on pull requests. Conditional execution for setup and testing steps based on GIT_DIFF. Updated get-diff-action to include Makefile.
proto/tendermint/abci/types.proto Modified request and response message types, added comments for clarity, and introduced reserved fields in Request and ResponseFinalizeBlock. Enhanced documentation for RequestPrepareProposal and RequestProcessProposal.
test/e2e/node/main.go Adjusted comments in startAppServer function for clarity; no changes to logic or error handling.

Possibly related PRs

Suggested reviewers

  • QuantumExplorer
  • shumkov

Poem

In a world of code, where bunnies hop,
Checks now run, they never stop!
With mocks and Protos, all in line,
Our workflow's bright, it truly shines.
So here's to changes, swift and neat,
A joyful dance, oh what a treat! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
.github/workflows/pr-precheck.yml (2)

4-10: Consider enhancing the workflow trigger configuration.

The current trigger configuration could be improved in several ways:

  1. Consider adding branch filters to limit execution
  2. Add handling for when the trigger workflow is skipped
  3. Consider security implications of workflow_run event

Add branch filters and additional workflow triggers:

 on:
   workflow_run:
     workflows:
       - "Check generated code"
+      # Add other optional job workflows here
+    branches:
+      - main
+      - 'v[0-9]+.x'  # version branches
     types:
       - completed

12-24: Consider adding operational robustness features.

To improve the reliability and observability of the workflow:

  1. Add retry mechanism for transient failures
  2. Configure appropriate timeouts
  3. Implement notification mechanism for persistent failures

Consider adding these configurations:

 jobs:
   wait-for-optional-jobs:
     runs-on: ubuntu-latest
+    timeout-minutes: 10
+    strategy:
+      retry:
+        max-attempts: 3
+        wait-duration: 60s
     steps:
+      - name: Configure notifications
+        uses: actions/github-script@v6
+        with:
+          script: |
+            const channel = '#ci-alerts';
+            const message = `Optional jobs failed in ${process.env.GITHUB_REPOSITORY}`;
+            // Add notification logic here
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0198f18 and e51a523.

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

12-24: 🛠️ Refactor suggestion

Enhance error reporting and job status handling.

The current implementation lacks detailed error reporting and robust status handling:

  1. Error messages don't specify which jobs failed
  2. No detailed status information is collected
  3. No artifact or summary creation for failures

Consider this improved implementation:

 jobs:
   wait-for-optional-jobs:
     runs-on: ubuntu-latest
     steps:
-      - name: Check status of optional jobs
+      - name: Check detailed status of optional jobs
         shell: bash
         run: |
-          if [[ "${{ github.event.workflow_run.conclusion }}" == "success" || "${{ github.event.workflow_run.conclusion }}" == "skipped" ]]; then
-            echo "All optional jobs passed or were skipped."
-          else
-            echo "Some optional jobs failed."
-            exit 1
-          fi
+          # Get detailed job status using GitHub API
+          JOBS_STATUS=$(gh api \
+            "/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/jobs" \
+            --jq '.jobs[] | select(.conclusion != "success" and .conclusion != "skipped") | .name')
+          
+          if [ ! -z "$JOBS_STATUS" ]; then
+            echo "::error::The following optional jobs failed:"
+            echo "$JOBS_STATUS" | while read job; do
+              echo "::error::  - $job"
+            done
+            exit 1
+          else
+            echo "::notice::All optional jobs completed successfully or were skipped"
+          fi
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This implementation:

  1. Uses GitHub API to get detailed job status
  2. Provides specific information about failed jobs
  3. Uses workflow commands for better error visibility
  4. Properly handles authentication

Let's verify the GitHub API endpoint availability:

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 and nitpick comments (3)
.github/workflows/check-generated.yml (3)

29-32: Consider pinning the diff action to a specific SHA.

While using @v6 is acceptable, pinning to a specific SHA would provide better security and reproducibility.

-      - uses: technote-space/get-diff-action@v6
+      - uses: technote-space/[email protected]

35-35: Document the mockery version requirement.

Consider adding a comment explaining why this specific version (2.49.1) of mockery is required, or move it to a central version management location.


Line range hint 29-69: Well-designed conditional execution strategy.

The addition of diff detection and conditional execution is a good architectural choice that:

  1. Improves CI efficiency by skipping unnecessary checks
  2. Maintains reliability by still running when relevant files change
  3. Provides clear error messages for maintainability

The implementation is consistent between mocks and proto checks, which is good for maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e51a523 and 9af716e.

📒 Files selected for processing (1)
  • .github/workflows/check-generated.yml (2 hunks)
🔇 Additional comments (3)
.github/workflows/check-generated.yml (3)

26-28: LGTM! Optimal checkout configuration.

The minimal fetch depth is correctly set for git diff operations while optimizing checkout speed.


63-67: Same version pinning consideration applies here.


69-69: 🛠️ Refactor suggestion

Pin the gogo protobuf version.

Using @latest for gogo protobuf could lead to inconsistent builds. Consider pinning to a specific version.

-          go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest
+          go install github.com/gogo/protobuf/[email protected]

Likely invalid or redundant comment.

@lklimek lklimek added this to the v1.3 milestone Dec 9, 2024
@lklimek lklimek changed the title build(ci): report status of optional jobs build(ci): optional jobs must report success to merge PR Dec 9, 2024
@lklimek
Copy link
Collaborator Author

lklimek commented Dec 9, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
.github/workflows/tests.yml (1)

Line range hint 47-53: Consider adding explicit success step when no changes detected

While the workflow will pass when GIT_DIFF is empty (as no steps will run), it might be helpful to add an explicit step that runs when there are no relevant changes to provide clearer feedback in the GitHub UI.

      - name: Run Go Tests
        if: env.GIT_DIFF
        env:
          CGO_LDFLAGS: "-L/usr/local/lib -ldashbls -lrelic_s -lmimalloc-secure -lgmp"
          CGO_CXXFLAGS: "-I/usr/local/include"
        run: |
          make test-group-${{ matrix.part }} NUM_SPLIT=6
+
+     - name: Skip tests - no relevant changes
+       if: "!env.GIT_DIFF"
+       run: echo "No Go files or dependencies were modified - skipping tests"
.github/workflows/lint.yml (1)

Line range hint 54-63: Consider adding explicit success step for skipped linting

Similar to the tests workflow, consider adding an explicit step to provide clear feedback when linting is skipped due to no relevant changes.

      - uses: golangci/[email protected]
        if: env.GIT_DIFF
        with:
          version: v1.61
          args: --timeout 10m
          github-token: ${{ secrets.github_token }}
          only-new-issues: true
+
+     - name: Skip linting - no relevant changes
+       if: "!env.GIT_DIFF"
+       run: echo "No Go files or linter configurations were modified - skipping linting"
.github/workflows/e2e.yml (2)

Line range hint 46-90: Refactor repeated condition into job-level condition

The condition "github.event_name != 'pull_request' || env.GIT_DIFF != ''" is repeated multiple times. Consider moving it to the job level using a job condition.

  e2e-test:
    runs-on: ubuntu-latest
+   if: "github.event_name != 'pull_request' || env.GIT_DIFF != ''"
    strategy:
      fail-fast: true
      matrix:
        testnet: ["dashcore", "rotate"]
    steps:
      # ... other steps ...
      - uses: ./.github/actions/bls
        name: Install BLS library
-       if: "github.event_name != 'pull_request' || env.GIT_DIFF != ''"

      - name: Build runner and tests
        working-directory: test/e2e
        run: make -j2 runner tests
-       if: "github.event_name != 'pull_request' || env.GIT_DIFF != ''"

      # ... other steps with the same condition ...

Also consider adding an explicit success message when skipped:

+     - name: Skip E2E tests - no relevant changes
+       if: "github.event_name == 'pull_request' && !env.GIT_DIFF"
+       run: echo "No Go files, Dockerfile, or dependencies were modified - skipping E2E tests"

Line range hint 1-90: Architecture Review: Consistent and effective implementation

The implementation effectively solves the problem of optional jobs not reporting success when no relevant files are changed. The approach using technote-space/get-diff-action is consistent across all workflows and provides a clean solution to:

  1. Detect relevant file changes
  2. Skip unnecessary workflow steps
  3. Report success when no relevant changes are found

While the current implementation works, consider the following architectural improvements:

  1. Create a reusable workflow for the common get-diff-action setup
  2. Add explicit success messages for better visibility
  3. Use job-level conditions where possible to reduce repetition
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9af716e and 3465528.

📒 Files selected for processing (5)
  • .github/workflows/e2e.yml (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/tests.yml (1 hunks)
  • proto/tendermint/abci/types.proto (1 hunks)
  • test/e2e/node/main.go (1 hunks)
🔇 Additional comments (5)
.github/workflows/tests.yml (1)

18-28: LGTM: Appropriate file pattern configuration

The get-diff-action configuration correctly identifies relevant Go files while excluding test files, and includes essential build configuration files.

.github/workflows/lint.yml (1)

29-39: LGTM: Comprehensive linting file pattern configuration

The get-diff-action configuration appropriately includes:

  • Go source files
  • Linter configurations
  • Go module files
.github/workflows/e2e.yml (1)

38-44: LGTM: Appropriate file pattern configuration for E2E tests

The get-diff-action configuration correctly includes:

  • Dockerfile changes
  • Go source files
  • Go module files
test/e2e/node/main.go (1)

108-108: LGTM! Minor comment formatting change.

The removal of the period from the comment is a minor cosmetic change that doesn't affect functionality.

proto/tendermint/abci/types.proto (1)

17-17: LGTM! Important documentation addition.

The added comment provides a crucial reference to protobuf custom types documentation, which helps developers avoid common pitfalls when implementing custom types. This is particularly important for maintaining protocol compatibility and avoiding serialization issues.

.github/workflows/tests.yml Outdated Show resolved Hide resolved
@lklimek lklimek enabled auto-merge (squash) December 11, 2024 11:11
@lklimek lklimek merged commit a4e894b into v1.4-dev Dec 12, 2024
20 checks passed
@lklimek lklimek deleted the ci/wait-optional branch December 12, 2024 09:12
@lklimek lklimek modified the milestones: v1.3, v1.4 Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants