Skip to content

Conversation

@sgarner
Copy link
Collaborator

@sgarner sgarner commented Jun 10, 2025

Description of change

Previously, pushes to branches in this repository with pull requests would trigger duplicate CI runs:

image image image

This is because our workflow uses both the push and pull_request events, and GitHub Actions doesn't do any de-duplication. So a push to a typeorm/typeorm branch with a PR would trigger both events (producing 86 test jobs instead of 43).

This didn't happen very often because most PRs are from outside contributors on branches in their own forks, which would only trigger the pull_request event. However it would occur when maintainers with write access created PRs using non-fork branches in typeorm/typeorm.

We can fix this by changing the trigger branch criteria:

  • Filter the push event so it only triggers for pushes to the master branch. We have (I believe?) branch protection rules to ensure that commits can't be made directly to master, but this ensures we re-validate master after a PR is merged. Since all changes require a PR, CI doesn't need to run on other branches unless a PR is opened.

  • I've also widened the filter on the pull_request event so it triggers for PRs based on all branches. I don't see any need to restrict this, and it ensures that tests can run in chained PRs.

Summary by CodeRabbit

  • Chores
    • Updated workflow triggers so tests now run on pushes to the master branch and on pull requests targeting any branch.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

The GitHub Actions "test" workflow configuration was updated to change its trigger conditions. Now, it runs on pushes only to the master branch and on pull requests targeting any branch, instead of the previous broader push and narrower pull request triggers. Ignored paths remain unchanged.

Changes

File(s) Change Summary
.github/workflows/test.yml Modified workflow triggers: pushes now limited to master branch; pull requests target any branch.

Poem

A hop and a skip, the triggers rearrange,
Workflows on master, no longer so strange.
Pull requests now welcome from every last bough,
The branches all flutter, the rules shift somehow.
In the warren of code, the tests run anew,
As rabbits ensure, all builds hop through! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86f12c9 and 32bc68d.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: database-tests (18) / mssql (^10.0.1)
  • GitHub Check: database-tests (18) / sqlite
  • GitHub Check: database-tests (18) / cockroachdb
  • GitHub Check: database-tests (18) / mysql_mariadb
  • GitHub Check: database-tests (16) / mysql_mariadb
  • GitHub Check: database-tests (16) / mongodb
  • GitHub Check: database-tests (16) / postgres (17-3.5)
  • GitHub Check: database-tests (16) / postgres (14-3.5)
  • GitHub Check: database-tests (16) / sqljs
  • GitHub Check: database-tests (16) / better-sqlite3
  • GitHub Check: database-tests (16) / sqlite
  • GitHub Check: database-tests (16) / cockroachdb
  • GitHub Check: database-tests-compose (20) / oracle
  • GitHub Check: database-tests-compose (18) / sap
  • GitHub Check: database-tests-compose (20) / sap
  • GitHub Check: database-tests-windows / sqljs
  • GitHub Check: database-tests-compose (18) / oracle
  • GitHub Check: database-tests-windows / better-sqlite3
  • GitHub Check: database-tests-windows / sqlite
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
.github/workflows/test.yml (2)

9-9: Restrict push event to master branch
Limiting push triggers to master avoids running CI twice on branches that already have open PRs. This aligns with the goal of eliminating duplicate runs while ensuring build validation on the main branch.


13-13: Expand pull_request trigger to all branches
Allowing PR workflows on any target branch supports chained PRs and covers contributions from non-fork branches without duplication.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@sgarner sgarner requested a review from dlhck June 10, 2025 22:58
@alumni
Copy link
Collaborator

alumni commented Jun 11, 2025

@sgarner probably contributors should be using forks instead, so the workflows run in their own forks :)

I think it's okay that the test workflows run on every branch - then the contributors (whether they have write access to this repo or not) will see the test results in their own forked repository and they will not need to wait for workflow approval from one of us.

I am tempted to decline this PR.

@sgarner
Copy link
Collaborator Author

sgarner commented Jun 11, 2025

@sgarner probably contributors should be using forks instead, so the workflows run in their own forks :)

I think it's okay that the test workflows run on every branch - then the contributors (whether they have write access to this repo or not) will see the test results in their own forked repository and they will not need to wait for workflow approval from one of us.

I am tempted to decline this PR.

That's a fair point - although I doubt that many contributors work that way. Workflows are disabled on forks by default, so they would have to specifically go in and enable the option to do this. I've observed that most people only run tests on their local machine (if at all) before submitting a PR.

If we want to support that, additional conditions could be used to adapt the workflow depending on whether the branch is on a fork or not.

Other than working around this issue, what would be the benefit of forcing maintainers to work on forks?

@OSA413
Copy link
Collaborator

OSA413 commented Jun 13, 2025

Workflows are disabled on forks by default, so they would have to specifically go in and enable the option to do this. 

Hm, it didn't request me to enable anything when I forked the repo, though it was very long ago.

Maybe we should update docs to tell people how to enable CI/CD on their fork?

@sgarner
Copy link
Collaborator Author

sgarner commented Jun 13, 2025

Hm, it didn't request me to enable anything when I forked the repo, though it was very long ago.

Possible it was different if you forked before typeorm was using GitHub Actions. Here's what appears now:

image

Of course if you do this with the current trigger settings it causes the same duplicate CI runs issue to occur in your fork. Every push to a pull request will then trigger jobs in both your fork and the upstream (though this will be less visible since the jobs in the fork won't appear as checks on the PR).

@alumni
Copy link
Collaborator

alumni commented Jun 14, 2025

I think I had to enable it, but it was one time only so I vaguely remember.

Either way, I like that I can run the workflows in my own fork before I open the PR.

@sgarner sgarner closed this Jun 14, 2025
@sgarner sgarner deleted the fix-duplicate-ci-runs branch June 14, 2025 21:09
@alumni
Copy link
Collaborator

alumni commented Jun 15, 2025

@sgarner I think I might know how to solve this, by checking the repository owner:

jobs:
  database-tests:
    if: ${{ (github.repository_owner != 'typeorm') || (github.ref_name == 'master' && <something to check it's a not PR> ) }}

github.repository != 'typeorm/typeorm' is also allowed, not entirely sure how to check the workflow trigger.

@alumni
Copy link
Collaborator

alumni commented Jun 15, 2025

Actually I'm wondering, why don't we keep the on.push workflow as it is and remove on.pull_request?

Later edit: nevermind, I understand why :)

@alumni alumni mentioned this pull request Jun 15, 2025
4 tasks
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.

4 participants