-
Notifications
You must be signed in to change notification settings - Fork 6
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
Pull request tests run twice? #145
Comments
The impression is correct, the GitHub Actions for those tests are triggered on both pushes and pull request pushes. I think it's set up that way to avoid situations where no tests are run at all, like someone creates a PR from a fork. In that case the forked branch (and tests that may or may not run on it, depending on the forking side's setup) is not readily visible to a reviewer. A quick glance at the GH Actions docs didn't show an obvious way to say "if two triggers want to execute the tests just skip one of them". |
I found an article that describes how to write a condition that basically says "run on push and run on PR if the PR is from a forked repository", see https://wildwolf.name/github-actions-how-to-avoid-running-the-same-workflow-multiple-times/:
|
I have lately done it like this:
In the branches you would list |
Think about pushes against maintenance branches other than main/master. You would probably have to maintain a list of active branch names there that differ from repository to repository. |
That is true. For an individual package this would be fine, but here in meta not. |
Copied from the zopefoundation repositories. See zopefoundation/meta#145 (comment)
Copied from the zopefoundation repositories. See zopefoundation/meta#145 and the final version at https://github.com/zopefoundation/meta/blob/9c24f7380973de989c5132ec9f28fa71f1397f20/config/c-code/tests.yml.j2#L93
Copied from the zopefoundation repositories. See zopefoundation/meta#145 and the final version at https://github.com/zopefoundation/meta/blob/9c24f7380973de989c5132ec9f28fa71f1397f20/config/c-code/tests.yml.j2#L93
I am trying this in the
Note that you need single quotes. Thanks @mgedmin. |
And a drive-by comment to those struggling with this: The corrected version by @mauritsvanrees fixes two typos compared to the original: There need to be single quotes and it should be a test for inequality ( |
Easier to read formatting for YAML posted by @mauritsvanrees:
|
This is seems to be a common[1] issue[2] and there really is not a very satisfactory solution other than adding an "if" on the job rather than on the top-level workflow. Of course, there were other solutions listed, but they'd involve managing a hardcoded list of branch names where the "on push" action is triggered. So I went for the workaround listed in [1], which adds an if to the job specification. [1]: zopefoundation/meta#145 [2]: open-telemetry/opentelemetry-python#1370 Signed-off-by: aszlig <aszlig@nix.build>
I have the impression that the tests after a PR push are run twice, once with label
(push)
and once with label (pull_request
). If this impression is correct, what is the motivation?If there is no strong reason, we should avoid test duplication, as this would reduce testing time.
The text was updated successfully, but these errors were encountered: