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

[BUG] Negating filter doesn't work #335

Closed
3 tasks done
AdrianGarcia-StayWithReside opened this issue Jan 31, 2022 · 11 comments · Fixed by #337
Closed
3 tasks done

[BUG] Negating filter doesn't work #335

AdrianGarcia-StayWithReside opened this issue Jan 31, 2022 · 11 comments · Fixed by #337
Labels
bug Something isn't working

Comments

@AdrianGarcia-StayWithReside

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Using a negation filter after another filter doesn't remove files from the modified file lists as expected. Instead, all .py files are included.

To Reproduce

The output of this action should include all python files that are not in the migrations folder.

    - name: Get changed files
      id: changed-files
      uses: tj-actions/[email protected]
      with:
        files: |
          '**.py'
          !backend/**/migrations/*

Except it outputs files in the migrations folder:

backend/core/migrations/0006_auto_20220127_1838.py
backend/core/models/some_model.py
backend/core/serializers/some_serializer.py

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Files that match the !backend/**/migrations/* will be removed from the file list as defined in the Github workflow syntax:

Using an exclamation mark (!) in front of a pattern negates it. When a file matches a pattern and also matches a negative pattern defined later in the file, the file will not be included.

So the following file list is expected:

backend/core/models/some_model.py
backend/core/serializers/some_serializer.py

Relevant log output

No response

Anything else?

I might just be an idiot and my patterns don't work. More details can be provided if needed.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@AdrianGarcia-StayWithReside AdrianGarcia-StayWithReside added the bug Something isn't working label Jan 31, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue.

@jackton1
Copy link
Member

jackton1 commented Jan 31, 2022

Hi @AdrianGarcia-StayWithReside can you confirm that this is the same issues using ?

Exact extension match

!backend/**/migrations/*.py

OR

(n+1 depth) extension match

!backend/**/migrations/**.py

@AdrianGarcia-StayWithReside
Copy link
Author

Same result, files in backend/**/migrations/ are included in the changed file list.

@jackton1
Copy link
Member

jackton1 commented Jan 31, 2022

@AdrianGarcia-StayWithReside Can you include the full log output for the changed files action to assist with debugging. Thanks

@AdrianGarcia-StayWithReside
Copy link
Author

Sanitized logs from this step in the action:

2022-01-31T16:22:11.4964758Z No dependencies to install or update
2022-01-31T16:22:11.6048203Z ##[group]Run tj-actions/[email protected]
2022-01-31T16:22:11.6048492Z with:
2022-01-31T16:22:11.6048750Z   files: '**.py'
!backend/**/migrations/*.py

2022-01-31T16:22:11.6049250Z   token: ***
2022-01-31T16:22:11.6049486Z   separator:  
2022-01-31T16:22:11.6049753Z   sha: 563910a97a64cbc2c12cba410a96d7a28ec52ec1
2022-01-31T16:22:11.6050063Z   since_last_remote_commit: false
2022-01-31T16:22:11.6050315Z env:
2022-01-31T16:22:11.6050572Z   PIP_DISABLE_PIP_VERSION_CHECK: on
2022-01-31T16:22:11.6050910Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2022-01-31T16:22:11.6051303Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2022-01-31T16:22:11.6051619Z   VENV: .venv/bin/activate
2022-01-31T16:22:11.6051852Z ##[endgroup]
2022-01-31T16:22:11.6074544Z ##[group]Run # "Set base sha..."
2022-01-31T16:22:11.6074932Z �[36;1m# "Set base sha..."�[0m
2022-01-31T16:22:11.6075179Z �[36;1mif [[ -n "" ]]; then�[0m
2022-01-31T16:22:11.6075517Z �[36;1m  echo "::set-output name=base_sha::"�[0m
2022-01-31T16:22:11.6075821Z �[36;1melif [[ "false" == "true" ]]; then�[0m
2022-01-31T16:22:11.6083307Z �[36;1m  if [[ "9fb9ea6897e9dadb3112b8b448e7818847586265" != "0000000000000000000000000000000000000000" ]]; then�[0m
2022-01-31T16:22:11.6083747Z �[36;1m    echo "::set-output name=base_sha::9fb9ea6897e9dadb3112b8b448e7818847586265"�[0m
2022-01-31T16:22:11.6084082Z �[36;1m  else�[0m
2022-01-31T16:22:11.6084403Z �[36;1m    echo "::set-output name=base_sha::563910a97a64cbc2c12cba410a96d7a28ec52ec1"�[0m
2022-01-31T16:22:11.6084833Z �[36;1m  fi�[0m
2022-01-31T16:22:11.6085051Z �[36;1mfi�[0m
2022-01-31T16:22:11.6140255Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-01-31T16:22:11.6140557Z env:
2022-01-31T16:22:11.6140815Z   PIP_DISABLE_PIP_VERSION_CHECK: on
2022-01-31T16:22:11.6141158Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2022-01-31T16:22:11.6141542Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2022-01-31T16:22:11.6141869Z   VENV: .venv/bin/activate
2022-01-31T16:22:11.6142129Z ##[endgroup]
2022-01-31T16:22:11.6247095Z ##[group]Run bash $GITHUB_ACTION_PATH/sourcefiles.sh
2022-01-31T16:22:11.6247468Z �[36;1mbash $GITHUB_ACTION_PATH/sourcefiles.sh�[0m
2022-01-31T16:22:11.6298755Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-01-31T16:22:11.6299058Z env:
2022-01-31T16:22:11.6299318Z   PIP_DISABLE_PIP_VERSION_CHECK: on
2022-01-31T16:22:11.6299659Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2022-01-31T16:22:11.6300039Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2022-01-31T16:22:11.6300353Z   VENV: .venv/bin/activate
2022-01-31T16:22:11.6300661Z   INPUT_FILES: '**.py'
!backend/**/migrations/*.py

2022-01-31T16:22:11.6300960Z   INPUT_FILES_FROM_SOURCE_FILE: 
2022-01-31T16:22:11.6301217Z ##[endgroup]
2022-01-31T16:22:11.6399818Z ##[group]changed-files-from-source-file
2022-01-31T16:22:11.6558942Z Input files: '**.py' !backend/**/migrations/*.py
2022-01-31T16:22:11.6561011Z ##[endgroup]
2022-01-31T16:22:11.6661722Z ##[group]Run tj-actions/[email protected]
2022-01-31T16:22:11.6662102Z with:
2022-01-31T16:22:11.6662377Z   files: '**.py' !backend/**/migrations/*.py
2022-01-31T16:22:11.6662676Z   files-separator:  
2022-01-31T16:22:11.6662916Z   separator: |
2022-01-31T16:22:11.6663299Z   token: ***
2022-01-31T16:22:11.6663616Z   follow-symbolic-links: true
2022-01-31T16:22:11.6663904Z   strip-top-level-dir: true
2022-01-31T16:22:11.6664169Z env:
2022-01-31T16:22:11.6664428Z   PIP_DISABLE_PIP_VERSION_CHECK: on
2022-01-31T16:22:11.6664787Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2022-01-31T16:22:11.6665159Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2022-01-31T16:22:11.6665483Z   VENV: .venv/bin/activate
2022-01-31T16:22:11.6665735Z ##[endgroup]
2022-01-31T16:22:11.6698472Z ##[group]Run actions/github-script@v5
2022-01-31T16:22:11.6698745Z with:
2022-01-31T16:22:11.6699118Z   github-token: ***
2022-01-31T16:22:11.6699775Z   script: const path = require("path");

const { GITHUB_ACTION_PATH } = process.env
const ACTION_PATH = path.join(GITHUB_ACTION_PATH, "main.js")

const main = require(ACTION_PATH)
await main({ core, glob })

2022-01-31T16:22:11.6700281Z   debug: false
2022-01-31T16:22:11.6700556Z   user-agent: actions/github-script
2022-01-31T16:22:11.6700841Z   result-encoding: json
2022-01-31T16:22:11.6701086Z env:
2022-01-31T16:22:11.6701340Z   PIP_DISABLE_PIP_VERSION_CHECK: on
2022-01-31T16:22:11.6701680Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2022-01-31T16:22:11.6702066Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2022-01-31T16:22:11.6702387Z   VENV: .venv/bin/activate
2022-01-31T16:22:11.6702723Z   GITHUB_ACTION_PATH: /home/runner/work/_actions/tj-actions/glob/v3.3
2022-01-31T16:22:11.6703097Z   GITHUB_WORKSPACE: /home/runner/work/prokect/project
2022-01-31T16:22:11.6703453Z   INPUT_FILES: !backend/**/migrations/*.py '**.py'
2022-01-31T16:22:11.6703759Z   INPUT_FILES_SEPARATOR:  
2022-01-31T16:22:11.6704031Z   INPUT_FOLLOW_SYMBOLIC_LINKS: true
2022-01-31T16:22:11.6704318Z   INPUT_SEPARATOR: |
2022-01-31T16:22:11.6704596Z   INPUT_STRIP_TOP_LEVEL_DIR: true
2022-01-31T16:22:11.6704861Z ##[endgroup]
2022-01-31T16:22:11.7785554Z 
2022-01-31T16:22:11.7790666Z 
2022-01-31T16:22:11.7934135Z ##[group]Run bash $GITHUB_ACTION_PATH/entrypoint.sh
2022-01-31T16:22:11.7934519Z �[36;1mbash $GITHUB_ACTION_PATH/entrypoint.sh�[0m
2022-01-31T16:22:11.7988480Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-01-31T16:22:11.7988778Z env:
2022-01-31T16:22:11.7989045Z   PIP_DISABLE_PIP_VERSION_CHECK: on
2022-01-31T16:22:11.7989408Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2022-01-31T16:22:11.7989798Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2022-01-31T16:22:11.7990108Z   VENV: .venv/bin/activate
2022-01-31T16:22:11.7990419Z   GITHUB_SERVER_URL: https://github.com
2022-01-31T16:22:11.7990765Z   GITHUB_REPOSITORY: repo/project
2022-01-31T16:22:11.7991085Z   GITHUB_BASE_REF: github-action-hotfix
2022-01-31T16:22:11.7991434Z   INPUT_SHA: 563910a97a64cbc2c12cba410a96d7a28ec52ec1
2022-01-31T16:22:11.7991738Z   INPUT_BASE_SHA: 
2022-01-31T16:22:11.7992156Z   INPUT_TOKEN: ***
2022-01-31T16:22:11.7992401Z   INPUT_FILES_PATTERN: 
2022-01-31T16:22:11.7992665Z   INPUT_SEPARATOR:  
2022-01-31T16:22:11.7992921Z   INPUT_PATH: 
2022-01-31T16:22:11.7993146Z ##[endgroup]
2022-01-31T16:22:11.8129276Z ##[group]changed-files
2022-01-31T16:22:11.8129650Z Resolving repository path...
2022-01-31T16:22:11.8167307Z Setting up 'temp_changed_files' remote...
2022-01-31T16:22:11.8215025Z No 'temp_changed_files' remote found
2022-01-31T16:22:11.8215787Z Creating 'temp_changed_files' remote...
2022-01-31T16:22:11.8256303Z Getting HEAD info...
2022-01-31T16:22:12.4383159Z remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0        
2022-01-31T16:22:12.4582179Z From https://github.com/repo/project
2022-01-31T16:22:12.4583307Z  * [new branch]        github-action-hotfix -> github-action-hotfix
2022-01-31T16:22:12.4584224Z  * [new branch]        github-action-hotfix -> temp_changed_files/github-action-hotfix
2022-01-31T16:22:12.4659851Z Retrieving changes between d6234c9b7e81b9c91e1dca0292bcf853e9f409aa (github-action-hotfix) → 563910a97a64cbc2c12cba410a96d7a28ec52ec1 (feature/3515/test)
2022-01-31T16:22:12.4660761Z Getting diff...
2022-01-31T16:22:12.5065575Z Added files: backend/core/migrations/0006_auto_20220127_1838.py
2022-01-31T16:22:12.5066333Z Copied files: 
2022-01-31T16:22:12.5067286Z Deleted files: 
2022-01-31T16:22:12.5068291Z Modified files: .github/workflows/backend.yml backend/core/models/some_model.py backend/core/serializers/some_serializers.py
2022-01-31T16:22:12.5069291Z Renamed files: 
2022-01-31T16:22:12.5069791Z Type Changed files: 
2022-01-31T16:22:12.5071550Z Unmerged files: 
2022-01-31T16:22:12.5072022Z Unknown files: 
2022-01-31T16:22:12.5138749Z All changed and modified files: .github/workflows/backend.yml backend/core/migrations/0006_auto_20220127_1838.py backend/core/models/some_model.py backend/core/serializers/some_serializers.py
2022-01-31T16:22:12.5140291Z All changed files: .github/workflows/backend.yml backend/core/migrations/0006_auto_20220127_1838.py backend/core/models/some_model.py backend/core/serializers/some_serializers.py
2022-01-31T16:22:12.5141755Z All modified files: .github/workflows/backend.yml backend/core/migrations/0006_auto_20220127_1838.py backend/core/models/some_model.py backend/core/serializers/some_serializers.py
2022-01-31T16:22:12.5263860Z ##[endgroup]

@jackton1
Copy link
Member

jackton1 commented Jan 31, 2022

@AdrianGarcia-StayWithReside Seems the problem is the usage of single quotes

Change: '**.py' -> **.py

@AdrianGarcia-StayWithReside
Copy link
Author

This also yields the same result, files from the migration folder are present in the changed file list.

I was following the GitHub documentation for matching:

The * character is a special character in YAML. When you start a pattern with *, you must use quotes.

Which doesn't seem to actually matter, it works the same with and without the '.

files: backend/**/migrations/*.py correctly matches backend/core/migrations/0006_auto_20220127_1838.py and no other changed files, so it seems only the negation part is broken?

@jackton1 jackton1 linked a pull request Feb 1, 2022 that will close this issue
@jackton1
Copy link
Member

jackton1 commented Feb 1, 2022

@AdrianGarcia-StayWithReside this should be resolved in the latest 14.2 release.

@AdrianGarcia-StayWithReside
Copy link
Author

Cool, thanks.

@AdrianGarcia-StayWithReside
Copy link
Author

So I typed up this really long follow-up about it still not working and the steps I've tried to fix it, but it turns out that changing **.py* to backend/**/*.py fixed everything. No idea why the bare **.py caused the negation filter to not work...

@jackton1
Copy link
Member

jackton1 commented Feb 2, 2022

Yep also found that **.py only returns the files located in the top-level directory.

Glad you found a fix.

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

Successfully merging a pull request may close this issue.

2 participants