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: skip cache build for dependabot PRs #3270

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Dec 10, 2024

Skip build-zetanode step for depdenabot PRs as dependabot cannot push to ghcr.io. dependabot PRs will just use the slow build like fork PRs do.

reference.

Related to #3269

Summary by CodeRabbit

  • New Features

    • Enhanced end-to-end (E2E) testing workflow with improved conditions for job execution.
    • Added Slack notifications for E2E test results, including success and failure formatting.
  • Bug Fixes

    • Adjusted job triggers to exclude specific automated actors from initiating certain jobs.
  • Documentation

    • Updated workflow logic to reflect changes in test execution conditions based on pull request context.

@gartnera gartnera added the no-changelog Skip changelog CI check label Dec 10, 2024
@gartnera gartnera requested a review from a team as a code owner December 10, 2024 17:07
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

📝 Walkthrough

Walkthrough

The pull request modifies the .github/workflows/e2e.yml file to refine the conditions under which the build-zetanode job executes, specifically excluding the dependabot[bot] actor. Enhancements to the matrix-conditionals job expand the output options based on various triggering events. The e2e job now depends on both build-zetanode and matrix-conditionals, employing a matrix strategy for test execution. Additionally, the e2e-ok job has been updated to send formatted Slack messages with test results, ensuring effective communication of outcomes.

Changes

File Path Change Summary
.github/workflows/e2e.yml - Updated build-zetanode job to exclude dependabot[bot] from triggering.
- Enhanced matrix-conditionals job to broaden output based on event context.
- Structured e2e job to depend on build-zetanode and matrix-conditionals, utilizing a matrix strategy for tests.
- Updated e2e-ok job to send Slack messages with formatted test results.

Possibly related PRs

  • ci: Add Semgrep to CI #2912: The changes in the .github/workflows/semgrep.yml file include a condition to skip execution if the actor is dependabot[bot], similar to the updates made in the .github/workflows/e2e.yml file regarding the build-zetanode job.
  • ci: remove v2 migration test from scheduled CI and release workflow #3013: This PR modifies the .github/workflows/e2e.yml file to streamline the conditions under which specific tests are triggered, which aligns with the changes made in the main PR to enhance job dependencies and execution conditions.
  • refactor(e2e): only build zetanode once #3121: The introduction of a new job named build-zetanode in the .github/workflows/e2e.yml file directly relates to the changes made in the main PR, which also focuses on the build-zetanode job and its dependencies.
  • test: add e2e consensus test #3126: The modifications to the .github/workflows/e2e.yml file to add a new output variable and enhance the testing process are relevant to the changes made in the main PR, which also involves updates to the E2E workflow.
  • ci(e2e): use !cancelled() rather than always() #3229: The changes to the conditional execution of jobs in the .github/workflows/e2e.yml file to improve workflow reliability are related to the adjustments made in the main PR, which also focuses on refining job execution conditions.

Suggested labels

ci

Suggested reviewers

  • lumtis
  • kingpinXD
  • skosito
  • CryptoFewka

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.

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 Dec 10, 2024
@gartnera gartnera enabled auto-merge December 10, 2024 17:09
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/e2e.yml (2)

Line range hint 156-157: Track technical debt: Plan V2 migration cleanup

These TODO comments reference issue #2627 for V2 migration. Consider creating a milestone or project board item to track the removal of these temporary conditions after the V2 migration is complete.


Line range hint 284-341: Consider refactoring the e2e-ok job for better maintainability

The current implementation mixes concerns between Slack notification and status checking. Consider these improvements:

  1. Extract Slack notification to a separate composite action:
-      - name: Send slack message with results
-        uses: actions/github-script@v7
-        if: ${{ github.event_name == 'schedule' || (github.event_name == 'push' && needs.e2e.result == 'failure') }}
-        env:
-          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CI_ALERTS }}
-        with:
-          script: |
-            const {data} = await github.rest.actions.listJobsForWorkflowRunAttempt({
-              owner: context.repo.owner,
-              repo: context.repo.repo,
-              run_id: context.runId,
-              attempt_number: ${{ github.run_attempt }},
-            });
-            # ... rest of the script ...
+      - name: Send test results to Slack
+        uses: ./.github/actions/notify-slack-test-results
+        if: ${{ github.event_name == 'schedule' || (github.event_name == 'push' && needs.e2e.result == 'failure') }}
+        with:
+          webhook-url: ${{ secrets.SLACK_WEBHOOK_CI_ALERTS }}
+          workflow-run-id: ${{ github.run_id }}
+          workflow-attempt: ${{ github.run_attempt }}
  1. Simplify the exit code logic:
-      - run: |
-          result="${{ needs.build-zetanode.result }}"
-          if [[ $result == "failed" ]]; then
-            exit 1
-          fi
-          result="${{ needs.e2e.result }}"
-          if [[ $result == "success" || $result == "skipped" ]]; then
-            exit 0
-          else
-            exit 1
-          fi
+      - run: |
+          [[ "${{ needs.build-zetanode.result }}" != "failed" ]] && 
+          [[ "${{ needs.e2e.result }}" =~ ^(success|skipped)$ ]]
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5f35a90 and e3798db.

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

Line range hint 251-283: LGTM: Matrix strategy effectively manages test execution

The implementation follows GitHub Actions best practices:

  • Uses fail-fast: false to prevent single test failure from stopping other tests
  • Configures appropriate runners and timeouts for resource-intensive tasks
  • Properly inherits secrets and uses reusable workflow pattern

35-35: LGTM: Condition correctly excludes Dependabot PRs from cache builds

The condition github.actor != 'dependabot[bot]' is properly combined with the existing fork check, ensuring that Dependabot PRs fall back to the slow build process, which aligns with the PR objectives.

Let's verify the condition works as expected:

✅ Verification successful

Condition correctly implemented to skip cache builds for Dependabot PRs

The workflow implementation has been verified to work as intended:

  • The condition github.actor != 'dependabot[bot]' is correctly placed in the build-zetanode job
  • Recent workflow runs show Dependabot PRs are being processed, with the cache build being skipped
  • The condition is properly combined with the existing fork check logic, maintaining security constraints
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the workflow behavior for Dependabot PRs
# Expected: Workflow should skip build-zetanode for Dependabot PRs

# Check recent workflow runs for Dependabot PRs
gh run list --workflow=e2e.yml --json conclusion,displayTitle,headBranch,databaseId --jq '.[] | select(.headBranch | contains("dependabot")) | {conclusion, displayTitle, headBranch, url: "https://github.com/zeta-chain/node/actions/runs/\(.databaseId)"}' --limit 10

Length of output: 893


Script:

#!/bin/bash
# Let's examine the workflow file to verify the condition's implementation
cat .github/workflows/e2e.yml

Length of output: 16566

@gartnera gartnera added this pull request to the merge queue Dec 10, 2024
Merged via the queue into develop with commit 3a8fa1e Dec 10, 2024
44 checks passed
@gartnera gartnera deleted the dependabot-slow-build branch December 10, 2024 18:04
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