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

[Feature] Add a way to retrieve main components from files_yaml with just one output #1579

Closed
2 tasks done
V0lantis opened this issue Sep 18, 2023 · 12 comments · Fixed by #1581
Closed
2 tasks done

[Feature] Add a way to retrieve main components from files_yaml with just one output #1579

V0lantis opened this issue Sep 18, 2023 · 12 comments · Fixed by #1581
Labels
enhancement New feature or request

Comments

@V0lantis
Copy link
Contributor

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

Taking the example in the README.md on master:

...
 # Example 1
      - name: Get all test, doc and src files that have changed
        id: changed-files-yaml
        uses: tj-actions/changed-files@v39
        with:
          files_yaml: |
            doc:
              - '**/*.md'
              - docs/**
              - README.md
            test:
              - test/**
              - '!test/**.md'
            src:
              - src/**
          # Optionally set `files_yaml_from_source_file` to read the YAML from a file. e.g `files_yaml_from_source_file: .github/changed-files.yml`

From the snippet above, I would like to have all the different components which have any modifed / changed files and to get just the name of the component. For example,

      - name: Return components which have a changed files
        run: |
          echo "Here are all the components which have changed files:"
          echo "List all the components that have changed: ${{ steps.changed-files-yaml.outputs.changed-components }}" # doc, test

Describe the solution you'd like?

If we have some changed files in doc, then the echo above would give us just doc as a result ect...

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@V0lantis V0lantis added the enhancement New feature or request label Sep 18, 2023
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Sep 18, 2023

Note: When using files_yaml* inputs ensure all outputs are prefixed by the key test_{...} e.g. test_added_files, test_any_changed

@jackton1 jackton1 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2023
@V0lantis
Copy link
Contributor Author

Thank you @jackton1, but actually, I need something else. Basically, I need to create a list of components that I will feed to a matrix, and I thought it would be more elegant if they would be such output from changed-files, directly re-using the name of the root object from the yaml we feed to changed-files. Please ask me to reformulate if I am not clear enough

@jackton1
Copy link
Member

Yeah it's not clear you might have to use a working example

@jackton1
Copy link
Member

jackton1 commented Sep 18, 2023

Also note that you can also use the files input instead which would not require a key for each path your provide e.g

Instead of

      - name: Get all test, doc and src files that have changed
        id: changed-files-yaml
        uses: tj-actions/changed-files@v39
        with:
          files_yaml: |
            doc:
              - '**/*.md'
              - docs/**
              - README.md
            test:
              - test/**
              - '!test/**.md'
            src:
              - src/**
      - name: Run step if test file(s) change
        if: steps.changed-files-yaml.outputs.test_any_changed == 'true' 
        ...

You can use

      - name: Get all test files that have changed
        id: changed-files-yaml
        uses: tj-actions/changed-files@v39
        with:
          files: |
            test/**
            !test/**.md
      - name: Run step if test file(s) change
        if: steps.changed-files-yaml.outputs.any_changed == 'true' 
        ...

@jackton1
Copy link
Member

jackton1 commented Sep 18, 2023

Actually I just went through your request again I think you mean you want to know which key has changed files?

E.g

      - name: Get all test, doc and src files that have changed
        id: changed-files-yaml
        uses: tj-actions/changed-files@v39
        with:
          files_yaml: |
            doc:
              - '**/*.md'
              - docs/**
              - README.md
            test:
              - test/**
              - '!test/**.md'
            src:
              - src/**

If there are changes to the test/** files this should return a list like test ...

Is this the case @V0lantis ?

@jackton1 jackton1 reopened this Sep 18, 2023
@V0lantis
Copy link
Contributor Author

V0lantis commented Sep 18, 2023

Thanks for thinking about it again @jackton1.
That's exactly what you just described above. And if there would be changes in test and src, we would have (with json output) ['test', 'src']

This would help me pass the output directly to a matrix job definition like in matrix-test example but instead of files we would directly have the name of the root yaml object

@jackton1
Copy link
Member

Okay, this can be supported easily in that case.

@V0lantis
Copy link
Contributor Author

I was trying to do it on my laptop but had some struggles setting up the local environment. Somehow, I needed to pass a hell lot of environment variables. I don't know if there was an easier way out

@jackton1
Copy link
Member

Oh okay, sorry to hear that. Hopefully, the update simplifies things for you.

@jackton1
Copy link
Member

@V0lantis This is now available using any of the following outputs changed_keys or modified_keys

@V0lantis
Copy link
Contributor Author

Amazing, thank-you @jackton1 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants