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

on.pull_request.paths-ignore are not respected correctly #2324

Open
GRBurst opened this issue Dec 19, 2022 · 12 comments
Open

on.pull_request.paths-ignore are not respected correctly #2324

GRBurst opened this issue Dec 19, 2022 · 12 comments
Labels
bug Something isn't working

Comments

@GRBurst
Copy link

GRBurst commented Dec 19, 2022

Describe the bug

According to the documentation we can use paths-ignore in the same way for pull_request events as we can do for push events on.<push|pull_request|pull_request_target>.<paths|paths-ignore>.

However, if we define a workflow like the following, the behavior differs:

name: Echo Date

on:
  push:
    paths-ignore:
      - 'README.md'
  pull_request:
    types: [opened, synchronize]
    paths-ignore:
      - 'README.md'

jobs:
  echo-date:
    runs-on: ubuntu-latest
    name: "Echo"

    steps:
      - name: Run echo date
        run: |
          echo -e "Hello at $(date -I)"

Although it seems to be working at the beginning when I (1) created a pr, (2) pushed a change on README.md and (3) nothing triggered, the behavior changed as soon as one commit of the pr references a file outside of the paths-ignore list.
After a change to a file outside of the paths-ignore list, all following commits trigger the workflow.

Someone else mentioned a problem here as well: #545 (comment)

To Reproduce
You can find a minimal example here: https://github.com/GRBurst/pull_requests.paths

Steps to reproduce the behavior:

  1. Create an action as above (or fork the example)
  2. Create a new branch and a pr
  3. Add commits, where at least one commit changes a file outside the paths-ignore declaration
  4. Check that all following commits trigger the workflow (the pull_request events triggers, the push does not).

Expected behavior
I expect that the conditions to run the actions only take the last commit into account.
So if I have commit that changes a file outside the path definition, it triggers the workflow.
If a following commit does only changes to files declared in the paths-ignore list, the workflow should not trigger.

Runner Version and Platform

Version of your runner?
-> 2.299.1

OS of the machine running the runner? OSX/Windows/Linux/...
-> Ubuntu, 22.04.1, LTS

@GRBurst GRBurst added the bug Something isn't working label Dec 19, 2022
@rene-hermenau
Copy link

Can confirm the bug

@nickfujita
Copy link

@ShutdownRepo
Copy link

I also confirm this bug.

oz123 added a commit to kairos-io/kairos that referenced this issue Mar 7, 2023
actions/runner#2324

Signed-off-by: Oz Tiram <oz@spectrocloud.com>
oz123 added a commit to kairos-io/kairos that referenced this issue Mar 7, 2023
actions/runner#2324

Signed-off-by: Oz Tiram <oz@spectrocloud.com>
mudler pushed a commit to kairos-io/kairos that referenced this issue Mar 8, 2023
* 📖 Align kairos versions in the docs

Partial fix for #1049.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Fix build and server scripts to work system hugo

This PR change the detection of hugo to check if it
is also found globally (e.g. installed with system's package
manager), so there is no need to download and compile hugo locally.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Add parametrized shortcode

The version is now read from config.toml, so the release manager
has to update only one file everytime we release a new version.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 📖 add paramerized shortcode for k3s

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Don't build images if only docs have changed

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Disable linting go when only docs have changed

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Disable unit-test if only docs changed

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Fix syntax for exclusion on workflow files

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 another attempt to disable running on docs change only

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 disable lint from running on docs changes

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 test change in docs

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Work around github bug

actions/runner#2324

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Fix lint.yml syntax

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Disable running unit-tests on docs changes

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 artificial change, test github ci

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

---------

Signed-off-by: Oz Tiram <oz@spectrocloud.com>
Itxaka pushed a commit to kairos-io/kairos-docs that referenced this issue Apr 25, 2023
* 📖 Align kairos versions in the docs

Partial fix for #1049.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Fix build and server scripts to work system hugo

This PR change the detection of hugo to check if it
is also found globally (e.g. installed with system's package
manager), so there is no need to download and compile hugo locally.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Add parametrized shortcode

The version is now read from config.toml, so the release manager
has to update only one file everytime we release a new version.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 📖 add paramerized shortcode for k3s

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Don't build images if only docs have changed

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Disable linting go when only docs have changed

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Disable unit-test if only docs changed

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Fix syntax for exclusion on workflow files

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 another attempt to disable running on docs change only

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 disable lint from running on docs changes

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 test change in docs

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Work around github bug

actions/runner#2324

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Fix lint.yml syntax

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Disable running unit-tests on docs changes

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 artificial change, test github ci

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

---------

Signed-off-by: Oz Tiram <oz@spectrocloud.com>
@zdenko-kovac
Copy link

I can also confirm the bug:

Workflow: https://github.com/zdenko-kovac/testing/blob/main/.github/workflows/testPR.yaml
PR with 3 commits: zdenko-kovac/testing#2

where:

  • initial README.md update didn't trigger the WF (correct)
  • update of the WF itself (outside of paths-ignore): triggered the WF (correct)
  • additional update of README.md triggered the wf (wrong)

@kingthorin
Copy link

It's been half a year, any news on this?

@ilyesAj
Copy link

ilyesAj commented Aug 28, 2023

as a work around you can make :

  pull_request:
     paths:
       - '!docs/**'
       - '.github/**'

@mmulligan03
Copy link

Is there an update on this issue? Has anyone developed a workaround?

qrkourier added a commit to openziti/ziti that referenced this issue Aug 30, 2023
@pavetok
Copy link

pavetok commented Aug 31, 2023

It seems pull_request.paths affected too.

@qrkourier
Copy link

Is there an update on this issue? Has anyone developed a workaround?

@ilyesAj's workaround to negate paths patterns didn't work for me. I tried it the way they wrote it, and I tried it like this because the workflow syntax reference indicates that negations may only subtract from selected paths. The result of both workaround attempts was that no pull request event types triggered the workflow irrespective of change objects matching the paths filter patterns.

  pull_request:
     paths:
       - '**'
       - '!docs/**'
       - '.github/**'

qrkourier added a commit to openziti/ziti that referenced this issue Aug 31, 2023
@wallyrion
Copy link

Also, I have a similar issue in my project.
Paths working for 'push' but not working for 'pull_requests' This workflow always runs when new changes are added in a pull request regardless of the changed path

on:
push:
branches: ["refactoring/move-to-separate-solutions"]
paths:
- "TwitPoster.EmailSender/"
pull_request:
branches: ["master"]
paths:
- "TwitPoster.EmailSender/
"

@deleugpn
Copy link

deleugpn commented Sep 1, 2023

According to this explanation https://github.com/orgs/community/discussions/25161#discussioncomment-3246673 this "bug" is by design. Apparently when we make the on: pull-request actions, it will automatically use the synchronize event which will always consider all commits of a file change.

Although understandable, I think what we're missing here is a different implementation of the on: pull request functionality. If we had something like:

on:
  pull_request:
    types: [pushed]

Perhaps the pushed event could work differently than the synchronize event and thus not creating a huge breaking change effect. This way we could have a setup where we only run GH Actions based on pull requests events that includes a push of a commit, but also offers path filters on the most recent commit only. After all, if I have a deployment action and I'm only changing docs file, it doesn't matter that previous commits made changes to the real code, I still don't want to re-run all my deployment and pay for GH Actions when there's clearly no functionality change.

theofidry added a commit to theofidry/box that referenced this issue Nov 27, 2023
Since this is not working might as well just check the docs all the
time.

See actions/runner#2324.
@munapower
Copy link

munapower commented Feb 6, 2024

I have a similar issue. I have defined a workflow with the following:

name: Update Documentation
on: 
  push:
    paths-ignore: 
      - '.github/workflows/**'
      - "!**.md"
  pull_request:
    paths-ignore: 
        - '.github/workflows/**'
        - "!**.md"

When I push a change of the yaml that contains this code it doesn't execute. This is expected. Then I made a change to "samples/chaincode/echo-go/chaincode/echo.go" and pushed it and the workflow did run. I understand that it shouldn't have since the "!**.md" would have been true, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

14 participants