launchdarkly / find-code-references-in-pull-request

Find Code Reference Flags in Pull Requests
https://docs.launchdarkly.com/home/code/code-references
Apache License 2.0
7 stars 2 forks source link

Aliases in .launchdarkly/coderefs.yaml not working #124

Closed DigTheDoug closed 2 months ago

DigTheDoug commented 4 months ago

I am attempting to setup this action but it looks like it is not correctly referencing the .launchdarkly/coderefs.yaml file as it should, noted in the README.

We have another action in the same repo running the launchdarkly/find-code-references@v2.12.0 action, which does correctly find code alias references, so the config yaml should be working and referenced correctly.

.launchdarkly/coderefs.yaml

projects:
    - key: platform
      dir: src
      aliases:
        - type: camelcase

code-refs-in-pr action

Here's the relevant section of the job from the workflow file

  launch-darkly-pr-diff:
    runs-on: ubuntu-latest
    name: Find LaunchDarkly feature flags in diff
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Find flags
        if: "!contains(github.event.issue.labels.*.name, 'maintenance')"
        uses: launchdarkly/find-code-references-in-pull-request@v2
        id: find-flags
        with:
          project-key: platform
          access-token: ${{ secrets.LAUNCH_DARKLY_CODE_REFS_SECRET }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}

action running launchdarkly/find-code-references-in-pull-request@v2

I have changed/removed some key names and references, but in the logs it lists empty lists aliases for all the flag keys. I put one actual kebab case flag reference in the source to make sure that the action and comments were working as intended and to debug whether it was an aliasing issue. The kebab key reference that I put in is found and a comment is left correctly, but the other flag references are never noted. Note the aliases are empty lists in the debug log as well.

 ##[debug]Getting pull request diff...
  ##[debug]Got 6 diff files
  2024/07/09 16:29:42 Generating aliases...
  2024/07/09 16:29:42 Finished generating aliases...
  ##[debug]Generating aliases for removed files...
  ##[debug]Generated aliases for 'example-flag-name':  []
... <repeated for all flags, empty list values for all>
...
  2024/07/09 16:29:43 Searching for 620 flags
  2024/07/09 16:29:43 Summarizing results
  ::endgroup::
::group::Scanning diff for references...
Scanning diff for references...
##[debug]Setting outputs...
##[debug]setting output any-modified=true
##[debug]setting output modified-flags-count=1
##[debug]setting output modified-flags=test-kebab-name

Existing action running launchdarkly/find-code-references@v2.12.0

In the existing action you can see that it does find code references correctly aliased ("4 code references across 620 flags and 2 files")

INFO: 2024/07/09 17:35:08 coderefs.go:27: absolute directory path: /github/workspace
INFO: 2024/07/09 17:35:08 git.go:48: git branch: ld-flag-actions
INFO: 2024/07/09 17:35:12 coderefs.go:148: sending 4 code references across 620 flags and 2 files to LaunchDarkly for project(s): [ platform]
INFO: 2024/07/09 17:35:12 coderefs.go:180: checking if 617 flags without references were removed in the last 10 commits for project: platform

Please let me know if there's any other information I can provide. Thanks!

lucywyman commented 3 months ago

Hi! I just wanted to say we're looking into this! Hopefully we'll have an update for you soon.

DigTheDoug commented 2 months ago

Hello, just wondering if there's any update or estimate on this? Thanks!

rachelmarison commented 2 months ago

Hi @DigTheDoug apologies for the delay here, and thanks for your patience on this issue!

I've been able to reproduce this and found that it's because monorepos/multi-projects are not yet supported in this action (see the README) so your per-project aliases aren't going to be honored. We are looking into what it would take to add that support, but in the meantime, a quick workaround would be to set the aliases on the global level as well. So something like:

aliases:
  - type: camelcase
projects:
    - key: platform
      dir: src
      aliases:
        - type: camelcase

Let me know if this workaround works for you, thanks!

DigTheDoug commented 2 months ago

Thanks for the response. I can confirm that using the aliases key at the global level does work for cases where we only have one project in the repo. We don't have monorepos, but unfortunately all of our repos do use that format with the projects key, so I will see if we can change them to be the non-nested version. Thanks!

rachelmarison commented 2 months ago

Thanks for the response. I can confirm that using the aliases key at the global level does work for cases where we only have one project in the repo. We don't have monorepos, but unfortunately all of our repos do use that format with the projects key, so I will see if we can change them to be the non-nested version. Thanks!

Great - glad to hear it works for you! If you find this approach doesn't work for one of your repos, let us know and we'll see what we can do. It may be some time before we can add monorepos/multi-project support to this action.

I'll go ahead and close this issue out, but feel free to reopen it if you have any more questions!