-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Drop Ruby as a build dependency #740
base: master
Are you sure you want to change the base?
Conversation
I have no idea why the file-mode.sh test suddenly fails in github CI. Works On My Machine. |
Makefile
Outdated
@@ -215,7 +215,7 @@ gofmt: | |||
find . -maxdepth 9 -type f -name '*.go' -not -path './old/*' -not -path './tmp/*' -not -path './vendor/*' -exec goimports -w {} \; | |||
|
|||
yamlfmt: | |||
find . -maxdepth 3 -type f -name '*.yaml' -not -path './old/*' -not -path './tmp/*' -not -path './omv.yaml' -exec ruby -e "require 'yaml'; x=YAML.load_file('{}').to_yaml.each_line.map(&:rstrip).join(10.chr)+10.chr; File.open('{}', 'w').write x" \; | |||
find . -maxdepth 3 -type f -name '*.yaml' -not -path './old/*' -not -path './tmp/*' -not -path './omv.yaml' | xargs yamllint |
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.
Apparently there's a tool called yamlfix
that might satisfy this.
https://github.com/lyz-code/yamlfix
@@ -1,3 +1,4 @@ | |||
--- |
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.
We could disable the requirement for this in yamllint if we wanted
Race bugs in testing env. I will disable it. |
Quite true. I expect a few incoming config file things, but in general it's not as much of an issue. |
In github CI I realized we have two more ruby users: mdl and fpm. fpm is not so painful because it doesn't need to be part of the build, and if we want to run it in CI, github actions can still just run ruby setup actions. However, mdl is an entire different story. I tried substituting it with pymarkdownlnt, which has a limitation around tables (I can work around), but also has an annoying bug that occurs when indented blocks appear in enumerations or bullet point lists, and TABs are used for indentation. This begs the questions: Why do we insist on tabs in markdown? It's not best practice and we explicitly disable the MD010 rule that would warn us about this. Linting life would be much easier without tabs. Would spaces be so bad here? (This mostly happens in docs/language-guide.md.) |
I love my tabs. For many reasons unfortunately.
... |
(And in theory we should be adding more markdown docs as time goes on, so we definitely want to keep the validator.) |
To illustrate the issue in the previous comment:
The issue is a failed assertion in this parser. I believe that it's caused by a bug, and I have been looking into it, but debugging someone else's parser/lexer code is...challenging. |
While I love the idea of dropping the use of any ruby, it being there is not personally blocking me atm. But if you're really keen on this issue, maybe this would help though: https://github.com/gomarkdown/markdown ? |
Oh I definitely want to be sure we keep linting the markdown. We should even work towards disabling fewer rules imo. So yeah I filed jackdewinter/pymarkdown#1015 and will also look at the gomarkdown thingy. |
9034c4c
to
8570028
Compare
The tip of this now has a shape like I could imagine it. Let me know your thoughts please. If you all find this an acceptable way forward, I will squash it down. Note that I went for |
Wow, lots of neat work, thanks Felix! I've just had a short read through as a diff of the whole thing, rather than each commit separately. There are clearly a bunch of great changes I can see already. There are a few unknowns I'd need to dig into first. My first question is that if we're moving from ruby to python, is this a major improvement? It definitely seems to be from a packaging point of view. I'd like to rule out Lastly, how did you want to squash? (I do not recommend squashing all of it into a single commit.) If there are a few stand-alone / easy commits to squash and/or merge early, maybe I can make this easier to review by merging those first? I have a very large feature branch that I'll be merging shortly, and my goal is to merge this right after that. I don't think there are would be any major conflicts, but will do it in that order just to be safe. Cheers! |
Python is already a dependency, and no modern Linux box can function without python. It's a lot less noise on contributor's machines in this way. Ruby is rather obscure. Even Puppet users don't install it anymore, since Puppet vendors its own Ruby (go figure). I will try replacing pymarkdown with gomarkdown before I proceed.
Mainly I want to get rid of some intermediary steps like ruby-yaml-fix -> yamllint -> yamlfix. Also if I go for gomarkdown, any mention of pymarkdown needs not be in our history. But yes, otherwise I'm no fan of single-commit branches either. Some history can be helpful in archaeology down the line. |
So gomarkdown does not come with linting functionality. There is gomarkdown/mdfmt, but it's unmaintained and A slightly better maintained version is at https://github.com/shurcooL/markdownfmt/ and it does build, but it's not really customizable, and at a glance, it seems to do the opposite of what we want, e.g. joining our nice and carefully crafted 80 character line paragraphs into single long lines. |
haha, okay! I'm okay with the python route for now if you think that's preferable. I'm a bit concerned about the open issue and wouldn't mind waiting until that's fixed before we swap it though. Would you be able to rebase/squash your commits into a few separate ones based on logical functionality that you think makes sense and I'll review and merge those? |
Or I could pick off the easy ones first if you'd like. LMK |
I will clean up and ping you. |
Okay, go. |
@purpleidea this is ready for review. |
Update, I'm in communication with @jackdewinter in jackdewinter/pymarkdown#1015 in order to solve the limitation around tab characters. Once the fix works, it will allow us to remove the workaround from test-markdownlint.sh. But I feel that we can merge as is now, and remove the workaround later, so this needs not be blocked. |
test/test-commit-message.sh
Outdated
@@ -10,11 +10,12 @@ echo running "$0" | |||
ROOT=$(dirname "${BASH_SOURCE}")/.. | |||
cd "${ROOT}" || exit 1 | |||
|
|||
commit_title_regex='^\([a-z0-9]\(\(, \)\|[a-z0-9]\)\+[a-z0-9]: \)\+[A-Z0-9][^:]\+[^:.]$' | |||
commit_title_regex='^\([a-z0-9]\(\(, \)\|[a-z0-9]\)*[a-z0-9]: \)\+[A-Z0-9][^:]\+[^:.]$' |
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.
What does this do?
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.
It drops the random requirement that the "topic:" prefix has at least three characters in the topic.
@@ -183,5 +184,13 @@ then | |||
test_commit_message_common_bugs $commit | |||
done | |||
fi | |||
else # assume local branch |
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.
sweet!
@@ -155,42 +157,30 @@ test_commit_message_body() { | |||
if [[ -n "$TRAVIS_PULL_REQUEST_SHA" ]] | |||
then | |||
commits=$(git log --format=%H origin/${TRAVIS_BRANCH}..${TRAVIS_PULL_REQUEST_SHA}) | |||
[[ -n "$commits" ]] |
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.
Why are we nuking everything from here to the end?
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.
We just avoid copy/paste by doing the for commit in $commits
work at the bottom of the script.
then | ||
echo "FAIL: Commit message should match the following regex: '$commit_title_regex'" | ||
echo "('$title' does not match)" |
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.
Nice!
I've cherry-picked a few of these commits. I think we should hold off on the markdown/yaml thing for the moment. I need to have a deeper look into it all. Thanks for the fun commits! |
We pull in pipenv and install pip packages for yamlfix and pymarkdownlnt into the virtualenv. This allows us to drop mdl and later replace the ruby hack in Makefile that currently does our yamlfmt.
At the same time, introduce yamlfix for a proper "make yamlfmt" workflow that does not rely on the old ruby based hack. Also change existing YAML to reflect the result.
Also now shows the title line of offensive commit message.
Debian also now forbids installing pips system-wide, so pip3 install will just fail without messy force flags, so going the pipx route is more compatible. It is brittle in new ways, but probably less so than messing with system pip packages.
b8072b2
to
380004b
Compare
We have been using Ruby for two things
gofmt
but for YAML, which is also an odd proposition, given that whitespace has semantic meaning in YAMLThis change adds the Python based yamllint to our build dependencies. It has a much smaller footprint compared to bringing in Ruby, especially for folks who want to build mgmt on their regular work/play machines.
The test script now works and gives actionable error output.
The yamlfmt target essentially does the same thing now, though. No automatic "fixing" of YAML formats anymore, but then we probably also don't expect to write that much YAML any longer.
Linter settings were chose so that few changes are needed in existing YAML. It's another benefit of this approach that we can now curate our linter configuration.