-
Notifications
You must be signed in to change notification settings - Fork 85
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
Ease reusability of the template #180
Conversation
Thanks for starting this PR, @dafyddj. It's an interesting take on things, definitely worth a discussion. I'd like to start by pulling in other contributors who have experience with conversions using the CC: @saltstack-formulas/wg @xenophonf @GMAzrael. Some alternatives to compare against:
|
@dafyddj Thanks for the ongoing effort here, this will definitely be useful in resolving this problem. I hope others can share their opinions, so that we select the best approach going forwards. |
I think that in the middle/long term it should be nice to have a tool/script to generate a formula from scratch like other config management tools have. Maybe cookiecutter can be used for it but I don't really know it so I can't judge if it'll work for our needs. In the meantime (until someone take this job or we consider this a priority, maybe we already should?) manual generation (like documented in my PR) can be nice, and if this PR help it, I'm ok with it. |
@dafyddj The script looks great, this is really taking shape. Some comments:
|
@dafyddj I've started #181, with the plan to propagate using |
8ea358a
to
42f5fa4
Compare
# [1.63.0](v1.62.0...v1.63.0) (2019-11-27) ### Code Refactoring * **travis:** use pathspecs for `git ls-files` instead of `grep` ([615e3b2](615e3b2)), closes [/github.com/saltstack-formulas/template-formula/pull/181#discussion_r351421463](https://github.com//github.com/saltstack-formulas/template-formula/pull/181/issues/discussion_r351421463) ### Features * **shellcheck:** apply fixes throughout this repo ([1ea7fbb](1ea7fbb)) * **travis:** run `shellcheck` during lint job ([f52eb37](f52eb37)), closes [/github.com/saltstack-formulas/template-formula/pull/180#issuecomment-558612422](https://github.com//github.com/saltstack-formulas/template-formula/pull/180/issues/issuecomment-558612422)
b907232
to
703750f
Compare
@dafyddj Thanks for moving over to |
I'm not particularly attached to Also, do you agree that this conversion process should be CI tested? I'm thinking, in Travis, clone the repo, run the script, then run at least one of the test suites in that cloned repo. Thoughts? |
@dafyddj Definitely useful and worthwhile. A single job would be enough to test that. |
BREAKING CHANGE: changed all state names and ids
@myii this is mostly done as far as I'm concerned. It could probably do with some documentation. Can you suggest where best to place the docs - and should the script remove that part of the documentation when it's done? |
Great, I'm going to take this for a test drive soon, since I need to make a formula or two. That will help me finalise the review.
The
Since the end-user is going to be editing the |
git commit --quiet --all \ | ||
--message 'feat: convert `template-formula` to `'"${NEW_NAME}"'-formula` | ||
|
||
BREAKING CHANGE: changed all state names and ids' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
git commit --quiet --all \
--message 'feat: convert `template-formula` to `'"${NEW_NAME}"'-formula`' \
--message 'BREAKING CHANGE: changed all state names and ids'
git rm --quiet bin/convert-formula.sh AUTHORS.md CHANGELOG.md | ||
git mv TEMPLATE "${NEW_NAME}" | ||
grep --recursive --files-with-matches --exclude-dir=.git TEMPLATE . \ | ||
| xargs -L 1 ex -sc '%s/TEMPLATE/'"${NEW_NAME}"'/g|x' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my first local tests, the script doesn't get past this line. Since this is working in Travis, there's probably something in the way I've patched things together. The only way past it is to comment out line 3, i.e.:
# set -o errexit # If a command fails exit the whole script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might get some clues by running as (if you haven't already done so):
DEBUG=true bin/convert-formula.sh ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I started with that and then tried all sorts, including removing all of the quiet
or silent
flags but to no avail. Even when I get it running with this line commented out, there are no warning given. Not sure what's happening with that ex
command to cause an error status...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dafyddj This sounds a little strange but I found a solution (using -u NONE
) based on this reference:
So that's:
grep --recursive --files-with-matches --exclude-dir=.git TEMPLATE . \
| xargs -L 1 ex -u NONE -sc '%s/TEMPLATE/'"${NEW_NAME}"'/g|x'
- This actually worked, with
set -o errexit
re-enabled. - Maybe the end user (like me) could have something strange in their configuration, affecting
ex
when it exits?
git reset \ | ||
"$(echo 'feat: initial commit' \ | ||
| git commit-tree 'HEAD^{tree}')" | ||
git rm --quiet bin/convert-formula.sh AUTHORS.md CHANGELOG.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git rm --quiet bin/convert-formula.sh AUTHORS.md CHANGELOG.md | |
git rm --quiet bin/convert-formula.sh AUTHORS.md CHANGELOG.md \ | |
docs/_static/css/custom.css docs/AUTHORS.rst docs/CHANGELOG.rst \ | |
docs/conf.py docs/CONTRIBUTING_DOCS.rst docs/index.rst |
Current status:
A wish-list collection for the long-run, doesn't prevent merging this PR:
|
@dafyddj Merged, the rest of the issues can be covered in a future PR. Thanks for this fantastic PR. |
🎉 This PR is included in version 4.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
fix(convert-formula.sh): apply remaining suggestions from #180
## [4.0.1](v4.0.0...v4.0.1) (2019-12-17) ### Bug Fixes * **convert-formula.sh:** apply remaining suggestions from [#180](#180) ([76ecd44](76ecd44)), closes [/github.com//pull/180#discussion_r357308821](https://github.com//github.com/saltstack-formulas/template-formula/pull/180/issues/discussion_r357308821) [/github.com//pull/180#discussion_r357318860](https://github.com//github.com/saltstack-formulas/template-formula/pull/180/issues/discussion_r357318860) [/github.com//pull/180#discussion_r357362707](https://github.com//github.com/saltstack-formulas/template-formula/pull/180/issues/discussion_r357362707)
PR progress checklist (to be filled in by reviewers)
What type of PR is this?
Primary type
[build]
Changes related to the build system[chore]
Changes to the build process or auxiliary tools and libraries such as documentation generation[ci]
Changes to the continuous integration configuration[feat]
A new feature[fix]
A bug fix[perf]
A code change that improves performance[refactor]
A code change that neither fixes a bug nor adds a feature[revert]
A change used to revert a previous commit[style]
Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)Secondary type
[docs]
Documentation changes[test]
Adding missing or correcting existing testsDoes this PR introduce a
BREAKING CHANGE
?Yes.
All state names and state ids are changed to the new unique token.
Related issues and/or pull requests
#98 slightly
Describe the changes you're proposing
While creating my first formula using this template, I found it wasn't as straightforward as I'd hoped.
Obviously the word
template
is used all over this formula and some need changing and some don't.This is just an idea I had of uniquely marking out the replaceable
template
by using the tokentemplate__
- of course, it could be something else too.Then a simple global replace can be performed while converting the template to a real formula.
Thoughts before I continue further?
Pillar / config required to test the proposed changes
Debug log showing how the proposed changes work
Documentation checklist
README
(e.g.Available states
).pillar.example
.Testing checklist
state_top
).Additional context