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

chore: Separate installer CI tests #3584

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

bradenhilton
Copy link
Collaborator

@bradenhilton bradenhilton commented Feb 21, 2024

Refs #3366 (comment)

Experimental. I fully expect it to fail.

@bradenhilton bradenhilton force-pushed the install-script-ci branch 9 times, most recently from 52632ba to 6763ec6 Compare February 21, 2024 13:18
@bradenhilton
Copy link
Collaborator Author

@twpayne I have a few questions if I may:

  1. I added completions/** to main because the original **/*.ps1 matched both assets/scripts/install.ps1 and completions/chezmoi.ps1. Is this necessary?
  2. Should I re-add https://get.chezmoi.io/* tests? I believe the value of them is slightly limited if we are already testing new changes to the scripts, but I suspect they will be so quick to run after this is merged that it could be worth doing regardless.

Of course, I would revert the changes I made to the install scripts before merging. I just did that to trigger the new tests.

@twpayne
Copy link
Owner

twpayne commented Feb 22, 2024

  1. I added completions/** to main because the original **/*.ps1 matched both assets/scripts/install.ps1 and completions/chezmoi.ps1. Is this necessary?

It's safe to keep it for sure. As completions/* is auto-generated it should only change if the code is changed, so strictly speaking it should not be necessary to add completions/* to the dorny/paths-filter step in main.yml. However, I would much rather err on the side of caution.

2. Should I re-add https://get.chezmoi.io/* tests? I believe the value of them is slightly limited if we are already testing new changes to the scripts, but I suspect they will be so quick to run after this is merged that it could be worth doing regardless.

No, I think you're right to remove them. The tests you've added in this PR give better coverage anyway.

@bradenhilton
Copy link
Collaborator Author

Okay, I'll revert the comments I added to the scripts and add a few more tweaks and it should be good to merge.

I think the env.SHA I added is correct in principle, but I'm unsure if that exact implementation is correct. The issue is I won't know until this is merged because the commit SHA is available from different places depending on if it's a merge commit or a PR commit etc.

@twpayne
Copy link
Owner

twpayne commented Feb 22, 2024

I think the env.SHA I added is correct in principle, but I'm unsure if that exact implementation is correct. The issue is I won't know until this is merged because the commit SHA is available from different places depending on if it's a merge commit or a PR commit etc.

That's fine. It's OK to break things on master from time to time. As long as everything works the next time we tag a version, I'm happy.

@bradenhilton bradenhilton merged commit 0d6c4c2 into twpayne:master Feb 22, 2024
25 checks passed
@bradenhilton
Copy link
Collaborator Author

This line:

https://github.com/twpayne/chezmoi/pull/3584/files#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3R51

will still cause main to run when internal/cmds/generate-install.sh/install.sh.tmpl is modified (in addition to installer). If you don't consider it to also be part of code changes, I don't have a particularly elegant solution, as the path filter does not support exclusions. It would need to be changed to something like:

- - 'internal/**'
+ - 'internal/archivetest/**'
+ - 'internal/chezmoi/**'
+ - 'internal/chezmoiassert/**'
+ - 'internal/chezmoibubbles/**'
+ - 'internal/chezmoierrors/**'
+ - 'internal/chezmoigit/**'
+ - 'internal/chezmoilog/**'
+ - 'internal/chezmoimaps/**'
+ - 'internal/chezmoitest/**'
+ - 'internal/cmd/**'
+ - 'internal/cmds/execute-template/**'
+ - 'internal/cmds/lint-commit-messages/**'
+ - 'internal/cmds/lint-txtar/**'
+ - 'internal/cmds/lint-whitespace/**'

@twpayne
Copy link
Owner

twpayne commented Feb 24, 2024

Thanks. In the absence of a better solution, let's leave things as they are for the moment.

@bradenhilton
Copy link
Collaborator Author

This was bugging me so I had another look.

Normally, I would expect that !... would mean "exclude ...", but in picomatch, my understanding is that it actually means "include everything but ...". This requires a more specific pattern to avoid matching everything but install.sh.tmpl.

With this knowledge, I set up a minimal repo to test, and it seems to work as expected with

- 'internal/**/!(install.sh.tmpl)'
tree
.
├── .github
│   └── workflows
│       ├── installer.yml
│       └── main.yml
└── internal
    └── cmds
        └── generate-install.sh
            ├── install.sh.tmpl
            ├── main.go
            └── main_test.go

I added a step to each workflow file to echo the matched files.

When I commit and push the internal directory, it gives these outputs:

# main workflow
internal/cmds/generate-install.sh/main.go internal/cmds/generate-install.sh/main_test.go

# installer workflow
internal/cmds/generate-install.sh/install.sh.tmpl

I'm happy to open the PR if you like the change.

@twpayne
Copy link
Owner

twpayne commented Feb 26, 2024

I'm happy to open the PR if you like the change.

Yes, this is nice. Please do!

@bradenhilton bradenhilton deleted the install-script-ci branch February 27, 2024 01:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants