Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): do not run rpcimportable on forks #3089

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Nov 4, 2024

Try #3087 again

Also simplify e2e expression.

Making this PR from my fork this time to actually test it.

Summary by CodeRabbit

  • New Features

    • Enhanced execution criteria for the rpcimportable job in the CI workflow, allowing it to run under broader conditions.
    • Simplified conditional logic for Docker Hub login in the reusable E2E workflow, enabling login under more scenarios.
  • Bug Fixes

    • Improved reliability of job executions in the CI workflows by adjusting conditions for running specific jobs.

@gartnera gartnera added the no-changelog Skip changelog CI check label Nov 4, 2024
Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

📝 Walkthrough

Walkthrough

The pull request introduces modifications to the GitHub Actions workflows in two files: .github/workflows/ci.yml and .github/workflows/reusable-e2e.yml. The changes primarily focus on updating the conditional execution criteria for specific jobs within these workflows. The rpcimportable job in ci.yml now has a broader execution condition, while the Docker Hub login step in reusable-e2e.yml has a simplified conditional logic. The structure and steps of the other jobs remain unchanged.

Changes

File Change Summary
.github/workflows/ci.yml Updated the rpcimportable job's execution condition to allow running if the event is not a pull request or if it originates from zeta-chain/node.
.github/workflows/reusable-e2e.yml Altered the Docker Hub login step's condition to permit login if the event is not a pull request or if it is a pull request from the specified repository.

Possibly related PRs

  • fix(ci): do not run rpcimportable on forks #3087: The changes in this PR directly modify the same rpcimportable job in the .github/workflows/ci.yml file, focusing on its conditional execution based on the repository type, which is closely related to the changes made in the main PR.

Suggested reviewers

  • lumtis
  • skosito
  • swift1337

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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

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-actions github-actions bot added the ci Changes to CI pipeline or github actions label Nov 4, 2024
@gartnera gartnera marked this pull request as ready for review November 4, 2024 18:06
@gartnera gartnera requested a review from a team as a code owner November 4, 2024 18:06
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 (1)
.github/workflows/reusable-e2e.yml (1)

43-43: LGTM! Security-conscious condition for Docker Hub authentication.

The condition correctly restricts Docker Hub access to trusted contexts (direct pushes or PRs from the main repository), which is a security best practice for CI/CD workflows.

Consider adding a comment to improve readability:

-        if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node'
+        # Allow Docker Hub login only for direct pushes or PRs from the main repository
+        if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 08eeb7f and c34acdb.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/reusable-e2e.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/ci.yml (1)

101-101: LGTM! The conditional execution is properly secured.

The condition github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node' correctly prevents running the rpcimportable job on fork PRs while still allowing it to run:

  1. On direct pushes/merges to the main repository
  2. On PRs from the main repository
  3. In the merge queue

This is a security-conscious approach as it prevents potentially unsafe executions from forks while maintaining the validation where needed.

Let's verify the condition works as expected:

✅ Verification successful

Conditional execution for rpcimportable job is correctly configured

The verification confirms:

  • The rpcimportable job appears only in ci.yml, ensuring consistent fork handling across workflows
  • No conflicting conditions interfere with the job's execution logic
  • The condition at line 101 is the primary control for this job's execution

The implementation aligns with security best practices by restricting fork PR executions while maintaining the required CI/CD flow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the workflow triggers correctly in different scenarios

# Test: Check if this job runs in other workflow files
# Expect: This should be the only occurrence to ensure consistent fork handling
rg -g '*.yml' -g '*.yaml' 'rpcimportable' .github/workflows/

# Test: Verify no other conditions might interfere with this logic
# Expect: No conflicting conditions for this job
ast-grep --pattern 'if: $_' .github/workflows/ci.yml

Length of output: 863

.github/workflows/reusable-e2e.yml (1)

43-43: Verify consistent security conditions across workflows.

Let's ensure this security pattern is consistently applied across all workflow files that interact with Docker Hub.

✅ Verification successful

Security condition is consistently applied across Docker Hub authentications

The security condition github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node' is correctly and consistently applied to Docker Hub login actions. The only Docker Hub authentication in the codebase is in the reusable workflow file, and it properly implements this security check to prevent unauthorized access from fork pull requests.

The GitHub Container Registry login doesn't require this condition as it uses GITHUB_TOKEN which is automatically scoped to the correct repository context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Docker Hub login actions and their conditions across all workflow files
echo "Searching for Docker Hub login actions in workflow files..."
fd -e yml -e yaml . .github/workflows/ --exec rg -A 5 'docker/login-action'

Length of output: 667


Script:

#!/bin/bash
# Get the full context of workflow files containing Docker login actions
echo "Full context of workflow files with Docker login:"
fd -e yml -e yaml . .github/workflows/ --exec rg -C 20 'docker/login-action'

# Also search for any other Docker-related authentication steps
echo -e "\nSearching for other Docker-related authentication patterns:"
fd -e yml -e yaml . .github/workflows/ --exec rg -C 10 'docker.*login|docker.*auth|registry.*login|registry.*auth'

Length of output: 2838


Script:

#!/bin/bash
# List all workflow files to ensure we haven't missed any
echo "All workflow files in the repository:"
fd -e yml -e yaml . .github/workflows/

# Get the content of each workflow file that might contain Docker-related steps
echo -e "\nContent of workflow files:"
fd -e yml -e yaml . .github/workflows/ --exec cat {}

Length of output: 52784

@gartnera gartnera enabled auto-merge November 4, 2024 18:16
@gartnera gartnera added this pull request to the merge queue Nov 4, 2024
Merged via the queue into zeta-chain:develop with commit 44c377a Nov 4, 2024
32 of 37 checks passed
@gartnera gartnera deleted the ci-rpcimportable-no-forks-2 branch November 4, 2024 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Changes to CI pipeline or github actions no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants