Skip to content

ci(tests): Remove limitation of branches to run on - #11794

Merged
alumni merged 4 commits into
typeorm:masterfrom
OSA413:unrestricted-branches
Dec 8, 2025
Merged

alumni merged 4 commits into
typeorm:masterfrom
OSA413:unrestricted-branches

Conversation

@OSA413

@OSA413 OSA413 commented Nov 23, 2025 •

Copy link
Copy Markdown
Collaborator

User description

Description of change

This change removes restriction of branches the tests are run on. This is useful for contributors that create their forks and their branches. Currently, even if a contributor creates their fork, it's currently limited to master and next branches. This is useful for people that create a lot of branches to test things on.

I verified it on my personal fork.

Basically the same as #11173

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • [ ] This pull request links relevant issues as Fixes #00000
  • [ ] There are new or updated unit tests validating the change
  • [ ] Documentation has been updated to reflect this change

PR Type

Enhancement


Description

  • Removes branch restrictions from GitHub Actions workflow

  • Tests now run on all branches, not just master and next

  • Enables contributors to test on their own fork branches

  • Simplifies CI/CD configuration for development workflows


Diagram Walkthrough

flowchart LR
  A["GitHub Actions<br/>Workflow Config"] -- "Remove branch<br/>restrictions" --> B["Tests run on<br/>all branches"]
  B -- "Benefits" --> C["Contributors can<br/>test fork branches"]
Loading

File Walkthrough

Relevant files
Configuration changes
tests.yml
Remove branch restrictions from push trigger                         

.github/workflows/tests.yml

  • Removed branches filter from push trigger that limited runs to master
    and next
  • Changed push trigger to run on all branches without branch
    specification
  • Kept pull_request trigger unchanged to maintain PR validation
  • All job definitions and logic remain functionally identical
+128/-131

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 23, 2025 •

Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
⚪
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
⚪
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 23, 2025 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to f304208

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix inverted fork PR condition

Correct the if condition logic to ensure the job runs for pull requests from the
same repository, as the current implementation incorrectly skips them.

.github/workflows/tests.yml [9]

-if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.fork) }}
+if: ${{ (github.event_name != 'pull_request') || (!github.event.pull_request.head.repo.fork) }}
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical logic flaw in the if condition that prevents the workflow job from running on pull requests originating from the same repository, which is a primary use case for CI.

High
  • More

Previous suggestions

✅ Suggestions up to commit 142a450
CategorySuggestion                                                                                                                                    Impact
High-level
✅ Consider the impact on CI resources
Suggestion Impact:The commit addressed the CI resource concern by adding a conditional filter to the detect-changes job (line 138) that prevents the workflow from running on pull requests from non-forked repositories. This optimization reduces redundant CI runs since pull requests from the same repository would trigger both push and pull_request events. The condition `if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.fork) }}` ensures the workflow runs on pushes OR on pull requests from forks only, mitigating the resource consumption issue raised in the suggestion.

code diff:

+    if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.fork) }}

Evaluate the trade-offs of running the test workflow on every push to every
branch, as this will significantly increase CI resource consumption, potentially
leading to higher costs and slower builds.

Examples:

.github/workflows/tests.yml [3-4]
  push:
  pull_request:

Solution Walkthrough:

Before:

name: Tests
on:
  push:
    branches:
      - master
      - next
  pull_request:

jobs:
  # ...

After:

name: Tests
on:
  push:
    # No branch filter, runs on all branches
  pull_request:

jobs:
  # ...
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a critical operational side-effect of the change, which could lead to increased CI costs and slower build queues for a large project.

Medium
Possible issue
✅ Prevent duplicate workflow runs
Suggestion Impact:The commit implemented the suggestion's intent to prevent duplicate workflow runs, but used a different approach. Instead of adding a condition to the push trigger at the workflow level, it added a job-level condition to the detect-changes job that skips execution for non-fork pull requests. This achieves the same goal of avoiding duplicate runs when both push and pull_request events trigger for the same commit.

code diff:

+    if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.fork) }}

To prevent duplicate workflow runs on pull requests, add a condition to the push
trigger to ignore pushes to PR branches. This will save CI resources and avoid
confusion.

.github/workflows/tests.yml [2-4]

 on:
   push:
+    # Avoid duplicate runs for PRs
+    # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-for-a-push-or-pull-request
+    if: github.ref_type != 'tag' && !startsWith(github.ref, 'refs/pull/')
   pull_request:
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that the PR's changes will cause duplicate workflow runs and proposes a valid solution to prevent this, improving CI efficiency.

Medium

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

Hold on, there seems to be a problem with ending of the lines, I'll check why the whole thing is highlighted

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

Now fine

@alumni

alumni commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator

@OSA413 We might need to add a condition so that the tests don't run twice when the PR is created from a branch in this repo, like we had it in the past - I'm not sure if that condition is still there (didn't manage to check the changes from October yet, only observed the effects).

@pkuczynski pkuczynski left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should allow to run tests on every push to any branch. Generally developers should use local test run to verify their changes as their are much faster and do not count against the quota. The test run in PR are for helping reviewers. The test run on push are only for calculating coverage.

Why would we want to run test on pushes against any branch?

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

Generally developers should use local test run to verify their changes as their are much faster and do not count against the quotes.

Yeah, but what if I don't want to boot all the databases (ALL of them) locally to check if a core functionality is still working across all DBs in the change I made? Providing a way of assuring that the tests are fine before creating a PR would decrease the time reviewing because the contributor had the time to check breaking changes on their fork in their branch.

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

Why would we want to run test on pushes against any branch?

afair it only applies to the branches where the github ci yaml is located, so only that branches will run. And also afair there's a way to limit branch runs on specific repo allowing unrestricted run on other repos.

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

run twice when the PR is created from a branch in this repo,

@alumni do you mean the situation when a PR is created and then a contributor with write access is pushing to the PR branch and it's run on their fork and on this repo? This situation was also happening when a contributor with write access created a branch on this repo and pushed to this repo's other branch.

@coveralls

coveralls commented Nov 23, 2025 •

Copy link
Copy Markdown

Coverage Status

coverage: 80.764%. remained the same
when pulling f304208 on OSA413:unrestricted-branches
into 2133c97 on typeorm:master.

@pkuczynski

Copy link
Copy Markdown
Member

Generally developers should use local test run to verify their changes as their are much faster and do not count against the quotes.

Yeah, but what if I don't want to boot all the databases (ALL of them) locally to check if a core functionality is still working across all DBs in the change I made? Providing a way of assuring that the tests are fine before creating a PR would decrease the time reviewing because the contributor had the time to check breaking changes on their fork in their branch.

When I work with other open source projects, I typically make changes locally, run tests, and when all work, I commit, push and immediately go and create a PR without waiting no for CI to run.

And when I am maintainer, I do not even look at a PR with failing CI.

What you propose is quite unusual setup for both open source and private repos. I doubt anybody would expect his push to a branch would trigger CI, until a PR is created. So I guess they will just create a PR immediately after the push.

And spinning 10 docker containers with databases locally to run the tests should also not be that much of an issue on a modern computer. They will be also much faster than in CI. And if you really don't want to do that, you can always temporarily change this file in your branch before making a PR.

@alumni

alumni commented Nov 23, 2025 •

Copy link
Copy Markdown
Collaborator

@OSA413 No, I meant when a collaborator is creating a branch in this repo, and a PR from that branch (without using a fork). The same action was running twice in the past, I fixed it at some point, did not check if it's the same now (this was affecting @naorpeled quite a lot actually).

@pkuczynski we want users to be able to run the actions in their own fork while they are preparing the PR. For me at least it is very helpful, since I don't run all drivers locally. It is also helpful for contributors, since the actions don't run unless they are approved by a collaborator, so seeing the result in their own fork (which counts against their own quota) is extremely helpful.

The CI setup that we had in the past was implemented intentionally the way it was, based on the problems we observed over a longer period of time for multiple contributors ;) @pkuczynski please trust us, it was what we wanted.

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

When I work with other open source projects, [...] I commit, push and immediately go and create a PR without waiting no for CI to run.

What if your local configuration is different than CI's and only it passes the tests but not the CI on the repo? Do you test locally with all operation systems that the project supports? Anyway, this would also be shown in a PR that it fails.

And when I am maintainer, I do not even look at a PR with failing CI.

Ooops, your non-maintainer PR is failing because of different configurations (described above in this reply), what will you do?

@pkuczynski

Copy link
Copy Markdown
Member

run twice when the PR is created from a branch in this repo,

@alumni do you mean the situation when a PR is created and then a contributor with write access is pushing to the PR branch and it's run on their fork and on this repo? This situation was also happening when a contributor with write access created a branch on this repo and pushed to this repo's other branch.

In the current setup a push to PR and push to any branch will both cause run of CI so for PR it will be effectively running twice. I guess that's what he thinks...

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

The same action was running twice in the past, I fixed it at some point

I'm afraid that you'll have to figure that out again (in a separate PR, for example) because I have no idea how to properly do that, sorry ;)

Anyway here are useful documentation that should point to the correct way:

@pkuczynski

Copy link
Copy Markdown
Member

What if your local configuration is different than CI's and only it passes the tests but not the CI on the repo? Do you test locally with all operation systems that the project supports? Anyway, this would also be shown in a PR that it fails.

That's why we should help people to have exactly the same configuration like in CI and we already to that with nvmrc and docker compose.

If you don use them, you go against contribution guidelines.

And when I am maintainer, I do not even look at a PR with failing CI.

Ooops, your non-maintainer PR is failing because of different configurations (described above in this reply), what will you do?

I try to reproduce the issue locally. Pushing blindly to CI is pointless since it will run all the test again and again, and you rather only make a mistake against one db...

@pkuczynski

Copy link
Copy Markdown
Member

@pkuczynski we want users to be able to run the actions in their own fork while they are preparing the PR. For me at least it is very helpful, since I don't run all drivers locally. It is also helpful for contributors, since the actions don't run unless they are approved by a collaborator, so seeing the result in their own fork (which counts against their own quota) is extremely helpful.

Everybody should be first running the tests locally. There is a good reason why actions are not run without pre approval: security and abuse.

99% of people will push and fire up PR immediately. And once we approve first run, it will run on subsequent pushes.

In your setup, when PR is fired, the test will run in PR against our quota and in fork against fork quota. Let's have compassion to the planet and not burn electricity for same job twice. Especially we have lengthy jobs.

And really running few docker containers with a single docker compose is a matter of single command.

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

If you don use them, you go against contribution guidelines.

Run the full TypeORM test suite, as described in the developer documentation, and ensure that all tests pass.

Does that mean that I have to constantly upgrade RAM to keep my laptop up with the requests of all the databases? My gaming laptop came with 8 GB RAM, I manually upgraded it to 32 GB later.

Btw I'm (personally) unable to download Oracle Free DB docker image locally because it restricted downloads from my country. What should I do to comply with the contribution guidelines then?

@OSA413

OSA413 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

And once we approve first run, it will run on subsequent pushes.

That's not the case when contributor has no write access.

@pkuczynski

Copy link
Copy Markdown
Member

Btw I'm (personally) unable to download Oracle Free DB docker image locally because it restricted downloads from my country. What should I do to comply with the contribution guidelines then?

Contributor has nothing to worry. We will run test in PR. And since you run all the other databases, the chance it will fail just of oracle is rather small...

@alumni

alumni commented Nov 23, 2025 •

Copy link
Copy Markdown
Collaborator

I'm afraid that you'll have to figure that out again (in a separate PR, for example) because I have no idea how to properly do that, sorry ;)

@OSA413 sure, no problem :) I'll figure it out at some point, just maybe later - these issues with CI that popped up were the last thing I wanted to worry about now.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@alumni
alumni dismissed pkuczynski’s stale review December 8, 2025 22:58

We've been explicitly recommending contributors to setup the CI in their forks, so they can test their changes without us having to approve the PR. So we would like to allow this in the future as well.

@alumni
alumni merged commit 514e3d8 into typeorm:master Dec 8, 2025
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
kranners pushed a commit to kranners/typeorm that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants