Skip to content

Conversation

@r0qs
Copy link
Member

@r0qs r0qs commented Oct 21, 2025

Part of CI refactor suggested by #16136 and #16253 (comment). This PR replaces our current code-style setup by a github action. After merging we can completely remove the need of a bot account and remove the GITHUB_ACCESS_TOKEN from CircleCI.

@r0qs r0qs requested review from cameel and nikola-matic October 21, 2025 10:25
@r0qs r0qs force-pushed the move-coding-style-check-to-gh-actions branch 2 times, most recently from 5497399 to 8059962 Compare October 27, 2025 15:26
@r0qs
Copy link
Member Author

r0qs commented Oct 27, 2025

Note that ci/circleci: chk_coding_style will need to be replaced by github chk_coding_style in the branch protection setting as a required check.

@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Nov 11, 2025
@nikola-matic nikola-matic force-pushed the move-coding-style-check-to-gh-actions branch from 8059962 to a28d095 Compare November 12, 2025 07:35
@nikola-matic nikola-matic removed the stale The issue/PR was marked as stale because it has been open for too long. label Nov 12, 2025
@argotorg argotorg deleted a comment from github-actions bot Nov 15, 2025
@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Nov 30, 2025
@argotorg argotorg deleted a comment from github-actions bot Dec 1, 2025
@r0qs r0qs removed the stale The issue/PR was marked as stale because it has been open for too long. label Dec 1, 2025
@r0qs r0qs self-assigned this Dec 17, 2025
@r0qs r0qs force-pushed the move-coding-style-check-to-gh-actions branch from 449afb6 to efa9895 Compare December 23, 2025 16:20
@heathdutton
Copy link

The main scenario is when a file is modified but the style error is on a line that's not part of the diff hunk. GitHub's createReviewComment API only allows comments on lines within the diff context (changed lines plus surrounding context lines).

For example, if a PR modifies lines 10-20 of a file, but there's a pre-existing style error on line 500, the API will reject the comment with a 422 error because line 500 isn't in the diff.

This could happen if:

  • The style checker finds errors in parts of a modified file that weren't touched by this specific PR
  • A rebase brings in new code that has style issues in non-diff lines
  • The script runs against files that are in the PR but where the specific error line isn't in the diff context

Since the codebase should be clean as you noted, this is an edge case, but the try/catch prevents a noisy failure when it does happen.

@r0qs
Copy link
Member Author

r0qs commented Dec 23, 2025

The main scenario is when a file is modified but the style error is on a line that's not part of the diff hunk. GitHub's createReviewComment API only allows comments on lines within the diff context (changed lines plus surrounding context lines).

For example, if a PR modifies lines 10-20 of a file, but there's a pre-existing style error on line 500, the API will reject the comment with a 422 error because line 500 isn't in the diff.

This could happen if:

* The style checker finds errors in parts of a modified file that weren't touched by this specific PR

* A rebase brings in new code that has style issues in non-diff lines

* The script runs against files that are in the PR but where the specific error line isn't in the diff context

Since the codebase should be clean as you noted, this is an edge case, but the try/catch prevents a noisy failure when it does happen.

Thanks for the clarification! While these should be rare given our CI enforcement, I agree that it is better to be defensive here, because changes in the code style script can also change what will be detected. So, I've added the try-catch ;)

@r0qs
Copy link
Member Author

r0qs commented Dec 23, 2025

Thanks for the clarification! While this should be rare given our CI enforcement, I agree that it is better to be defensive here. I've added the try-catch ;)

A test triggering the validation error (422) when there is no try-catch can be seen here: https://github.com/r0qs/solidity/actions/runs/20467384783/job/58814376600?pr=14

@github-actions

This comment was marked as resolved.

@r0qs
Copy link
Member Author

r0qs commented Dec 23, 2025

@heathdutton motivated me to improve this PR further. I've added error descriptions to our code style checker and pushed the bc25670 with intentional style errors for easier review of the behavior (the file will be removed before merge). That said, I think we should rethink about moving to clang-format as proposed in #2856 for more robust style checking.

@argotorg argotorg deleted a comment from github-actions bot Dec 23, 2025
@github-actions
Copy link

There was an error when running Code Style Check for commit 9e45e2b0eeb4a6a465878f3b2bed599536bd9c0a:

grep: warning: * at start of expression
grep: warning: * at start of expression
Coding style error:
[Use angle brackets for includes] libsolutil/TestStyleViolations.cpp:2:#include "libsolutil/Common.h"
[Missing space after keyword] libsolutil/TestStyleViolations.cpp:12:	if(true) {
[Opening brace on same line as if] libsolutil/TestStyleViolations.cpp:12:	if(true) {
[Missing space before opening brace in namespace] libsolutil/TestStyleViolations.cpp:6:namespace solidity::util {
[const should be on the right side of the type] libsolutil/TestStyleViolations.cpp:8:const int BAD_CONST = 42;
[Use std::move] libsolutil/TestStyleViolations.cpp:14:		auto x = move(badRef);
[Do not use 'using namespace std'] libsolutil/TestStyleViolations.cpp:4:using namespace std;

Please check that your changes are working as intended.

@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
#include "libsolutil/Common.h"

Choose a reason for hiding this comment

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

Coding style error: Use angle brackets for includes


void testFunction()
{
if(true) {

Choose a reason for hiding this comment

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

Coding style error: Missing space after keyword

@argotorg argotorg deleted a comment from github-actions bot Dec 23, 2025

void testFunction()
{
if(true) {

Choose a reason for hiding this comment

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

Coding style error: Opening brace on same line as if


using namespace std;

namespace solidity::util {

Choose a reason for hiding this comment

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

Coding style error: Missing space before opening brace in namespace


namespace solidity::util {

const int BAD_CONST = 42;

Choose a reason for hiding this comment

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

Coding style error: const should be on the right side of the type

{
if(true) {
int& badRef = BAD_CONST;
auto x = move(badRef);

Choose a reason for hiding this comment

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

Coding style error: Use std::move

// SPDX-License-Identifier: GPL-3.0
#include "libsolutil/Common.h"

using namespace std;

Choose a reason for hiding this comment

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

Coding style error: Do not use 'using namespace std'

@argotorg argotorg deleted a comment from github-actions bot Dec 23, 2025
@argotorg argotorg deleted a comment from github-actions bot Dec 23, 2025
@argotorg argotorg deleted a comment from github-actions bot Dec 23, 2025
@argotorg argotorg deleted a comment from github-actions bot Dec 23, 2025
@argotorg argotorg deleted a comment from github-actions bot Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants