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

[9.x] Prevent workflows from running twice #44053

Merged
merged 2 commits into from
Sep 9, 2022
Merged

[9.x] Prevent workflows from running twice #44053

merged 2 commits into from
Sep 9, 2022

Conversation

Jubeki
Copy link
Contributor

@Jubeki Jubeki commented Sep 8, 2022

Explanation

When creating a PR from a branch within the same repo (i.e. not a fork), the current run-test workflows get triggered twice - for both push and pull_request:

Screenshot 2022-09-08 at 18 08 50

This PR adds constrains so that the workflow only runs once.
(Push Event will only be triggered on the master and *.x branch)

Sources

Idea and Changes are taken from spatie/package-skeleton-laravel#119
Thanks and Credits to @jessarcher

Branch names can use patterns for Pull Requests:
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

Side note

I think it would be good to change the default branch to main per
https://github.com/github/renaming#new-repositories-use-main-as-the-default-branch-name

@Jubeki Jubeki changed the title Prevent workflows from running twice [9.x] Prevent workflows from running twice Sep 8, 2022
@GrahamCampbell
Copy link
Member

I think that's actually desirable that they run twice, allowing testing before cutting a PR.

@Jubeki
Copy link
Contributor Author

Jubeki commented Sep 8, 2022

I think that's actually desirable that they run twice, allowing testing before cutting a PR.

I am sorry, but could you please explain what you mean with "cutting a PR"? 😅

@GrahamCampbell
Copy link
Member

Opening a pull request.

@garygreen
Copy link
Contributor

It would be better to only listen on pull_request because by default it should trigger whenever any changes occur to a pull request because it has the default types of opened synchronize and reopened:

By default, a workflow only runs when a pull_request event's activity type is opened, synchronize, or reopened. To trigger workflows by different activity types, use the types keyword

@driesvints
Copy link
Member

Bit torn. I've thought about this a lot in the past already and my gut feeling says it'll be annoying to not be able to build on individual branches anymore before sending in a PR.

It would be better to only listen on pull_request because by default it should trigger whenever any changes occur to a pull request because it has the default types of opened synchronize and reopened:

That would mean directly pushed code to existing stable branches isn't tested anymore?

@driesvints
Copy link
Member

@Jubeki @GrahamCampbell @taylorotwell maybe we should just give this a try to see how it goes and then evaluate if we want to keep or ditch it.

@Jubeki
Copy link
Contributor Author

Jubeki commented Sep 9, 2022

Bit torn. I've thought about this a lot in the past already and my gut feeling says it'll be annoying to not be able to build on individual branches anymore before sending in a PR.

I am also a bit torn about it, but most features are worked on in a Draft PR, so that would mean the tests would still run.
(My main reasons are that it is annoying to see always two tests, double the run time and for environmental reasons)

It would be better to only listen on pull_request because by default it should trigger whenever any changes occur to a pull request because it has the default types of opened synchronize and reopened:

That would mean directly pushed code to existing stable branches isn't tested anymore?

I also think that would be the case, but I am not completely sure.

@taylorotwell taylorotwell merged commit 004163a into laravel:9.x Sep 9, 2022
@driesvints
Copy link
Member

Thanks @Jubeki

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.

5 participants