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

Format yaml files #615

Merged
merged 8 commits into from
Jun 14, 2024
Merged

Format yaml files #615

merged 8 commits into from
Jun 14, 2024

Conversation

adetunjii
Copy link
Contributor

Closes #533

Signed-off-by: adetunjii <[email protected]>
Copy link

codecov bot commented Jun 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.16%. Comparing base (4c6bf30) to head (bb6349b).
Report is 2 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #615      +/-   ##
============================================
- Coverage     70.19%   70.16%   -0.04%     
============================================
  Files           110      110              
  Lines         60052    60052              
============================================
- Hits          42154    42135      -19     
- Misses        17898    17917      +19     

see 9 files with indirect coverage changes

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@v5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we pin to a commit for setup-go too? @bjosv, thoughts?

- name: Format Yaml files
run: |
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
yamlfmt .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this go into ./deps as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it formats all the yaml files present in the repository

@madolson
Copy link
Member

I'm a little confused because I thought in the daily.yml we had some inconsistently formatted files. The CI flow you added isn't failing though, so it doesn't look like it would catch those inconsistencies.

@adetunjii
Copy link
Contributor Author

I'm a little confused because I thought in the daily.yml we had some inconsistently formatted files. The CI flow you added isn't failing though, so it doesn't look like it would catch those inconsistencies.

I'm a little confused because I thought in the daily.yml we had some inconsistently formatted files. The CI flow you added isn't failing though, so it doesn't look like it would catch those inconsistencies.

I might have to format it locally then push. Subsequently, it should fix all inconsistencies

@madolson
Copy link
Member

I might have to format it locally then push. Subsequently, it should fix all inconsistencies

Hm, I think I understand better. It looks like it's just formatting it in the CI temporary directory, which happens in a separate directory from the one that will eventually get merged. Ideally we want the step to fail if it encounters any files it needs to format.

@adetunjii
Copy link
Contributor Author

I might have to format it locally then push. Subsequently, it should fix all inconsistencies

Hm, I think I understand better. It looks like it's just formatting it in the CI temporary directory, which happens in a separate directory from the one that will eventually get merged. Ideally we want the step to fail if it encounters any files it needs to format.

Then I think we need a linter instead of a formatter.

@madolson
Copy link
Member

Then I think we need a linter instead of a formatter.

Generally a format checker is a subset of linting, since linting is a broad term for code analysis. We should be able to use the format checker you proposed for the linting, and then give instructions for how the end user can use the same formatting tool to fix it.

@adetunjii
Copy link
Contributor Author

Then I think we need a linter instead of a formatter.

Generally a format checker is a subset of linting, since linting is a broad term for code analysis. We should be able to use the format checker you proposed for the linting, and then give instructions for how the end user can use the same formatting tool to fix it.

Okay. I'll have a look.

@madolson
Copy link
Member

@adetunjii Maybe take a look at https://github.com/valkey-io/valkey/blob/unstable/.github/workflows/clang-format.yml for an example for how we do the style checking with clang.

Signed-off-by: adetunjii <[email protected]>
@adetunjii
Copy link
Contributor Author

@madolson Are we excluding yaml files in the deps directory?

@madolson
Copy link
Member

@adetunjii Yes, exclude the files in deps.

Signed-off-by: adetunjii <[email protected]>
@adetunjii adetunjii requested a review from PingXie June 13, 2024 17:42
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Go
uses: actions/setup-go@v5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's pin to a commit like we did for other actions

./src/valkey-cli save | grep OK > /dev/null
vmtouch -v ./dump.rdb > /dev/null
- name: test
run: "echo \"test SAVE doesn't increase cache\"\nCACHE0=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')\necho \"$CACHE0\"\n./src/valkey-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080 --repl-diskless-sync no --pidfile /tmp/master/valkey.pid --rdbcompression no --enable-debug-command yes\n./src/valkey-cli -p 8080 debug populate 10000 k 102400\n./src/valkey-server --daemonize yes --logfile /dev/null --dir /tmp/slave --port 8081 --repl-diskless-load disabled --rdbcompression no\n./src/valkey-cli -p 8080 save > /dev/null\nVMOUT=$(vmtouch -v /tmp/master/dump.rdb)\necho $VMOUT\ngrep -q \" 0%\" <<< $VMOUT \nCACHE=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')\necho \"$CACHE\"\nif [ \"$(( $CACHE-$CACHE0 ))\" -gt \"8000000\" ]; then exit 1; fi\n#magic___^_^___line\necho \"test replication doesn't increase cache\"\n./src/valkey-cli -p 8081 REPLICAOF 127.0.0.1 8080 > /dev/null\nwhile [ $(./src/valkey-cli -p 8081 info replication | grep \"master_link_status:down\") ]; do sleep 1; done;\nsleep 1 # wait for the completion of cache reclaim bio\nVMOUT=$(vmtouch -v /tmp/master/dump.rdb)\necho $VMOUT\ngrep -q \" 0%\" <<< $VMOUT \nVMOUT=$(vmtouch -v /tmp/slave/dump.rdb)\necho $VMOUT\ngrep -q \" 0%\" <<< $VMOUT \nCACHE=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')\necho \"$CACHE\"\nif [ \"$(( $CACHE-$CACHE0 ))\" -gt \"8000000\" ]; then exit 1; fi\n#magic___^_^___line\necho \"test reboot doesn't increase cache\"\nPID=$(cat /tmp/master/valkey.pid)\nkill -15 $PID\nwhile [ -x /proc/${PID} ]; do sleep 1; done\n./src/valkey-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080\nwhile [ $(./src/valkey-cli -p 8080 info persistence | grep \"loading:1\") ]; do sleep 1; done;\nsleep 1 # wait for the completion of cache reclaim bio\nVMOUT=$(vmtouch -v /tmp/master/dump.rdb)\necho $VMOUT\ngrep -q \" 0%\" <<< $VMOUT\nCACHE=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')\necho \"$CACHE\"\nif [ \"$(( $CACHE-$CACHE0 ))\" -gt \"8000000\" ]; then exit 1; fi\n#magic___^_^___line\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the result of the yml format? it is a lot harder to read now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is caused by trailing whitespaces on some lines. See: google/yamlfmt#185

Signed-off-by: adetunjii <[email protected]>
@adetunjii adetunjii requested a review from PingXie June 14, 2024 13:40
@madolson madolson added the de-crapify Correct crap decisions made in the past label Jun 14, 2024
Copy link
Member

@PingXie PingXie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you @adetunjii!

@PingXie PingXie merged commit 93123f9 into valkey-io:unstable Jun 14, 2024
18 checks passed
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Jul 31, 2024
Closes valkey-io#533

---------

Signed-off-by: adetunjii <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
de-crapify Correct crap decisions made in the past
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate format of YAML files
3 participants