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

Improve local and CI flows #26

Closed
wants to merge 22 commits into from

Conversation

neatudarius
Copy link
Member

@neatudarius neatudarius commented Jun 28, 2024

TLDR: scripts for local and CI flows. #1 #2 #11 #16
The codebase (e.g. C++ files) are not updated in this PR. I will make a new PR an update main and rebase this branch until this PR becomes green!

===========================================================================

Updates already applied:

  • Update toolchain files (etc/ tree)

    • Remove unused toolchain files from etc/ . Add license. Run linters.
    • Expose CMAKE_CXX_STANDARD (tested with C++20, C++23 and C++26)
  • Configure linters:

    • C++: clang-format
      • pulled version: 19, tested on Ubuntu 24.04
      • config: .clang-format
    • Shell: shell-check
      • pulled version: default apt-get version on Ubuntu 24.04
      • config: .shellcheckrc
    • Markdown: markdownlint
      • pulled version: default version available with npm on Ubuntu 24.04
      • config: .markdownlint.json
    • YAML: yamllint
      • pulled version: default apt-get version, on Ubuntu 24.04
      • config: yamllint
    • CMake: cmake-format
      • pulled version: default apt-get version, on Ubuntu 24.04
      • config: .cmake-format
  • Scripts: Uniform testing and linting local and CI environments! Full usage in scripts/README.md.

    • scripts/lint.sh: Script used to lint some or all files in the project.

      • Can detect errors. Can automatically fix detected errors (--fix).
    • scripts/run-tests.sh: Script used to run tests on local and CI environments!

      • Can use a single or multiple toolchains (--preset). Can set a C++ standard (--std).
  • New CI flows:

image image

===========================================================================

Next steps:

  • All jobs from ci_tests.yml are green and can be deployed in main.
  • Intentionally, all jobs from ci_lint.yml are red. I will push start making commits to fix linter errors, after we agree a direciton.

.clang-format Outdated
@@ -1,5 +1,11 @@
---
# /.clang-format -*-config-*-
Copy link
Member

Choose a reason for hiding this comment

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

This will make it slightly harder to keep the .clang-format up to date because clang-format will want to rewrite it when you dump the config.
I believe it's right now at clang-format-17.

clang-format-19 --style=file:.clang-format    --dump-config

will produce the file that clang-format believes it read, adding the options that were defaulted.

Copy link
Member Author

Choose a reason for hiding this comment

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

This will make it slightly harder to keep the .clang-format up to date because clang-format will want to rewrite it when you dump the config.

I'm OK to remove this file, but wouldn't be consistent for other linters? I think I would like to change it manually (using --dump-config into a temporary file). What do you think?

btw, I tried with clang 17/18/19, and I cannot get the current config. Would you like to update it with clang-format-19 in this PR? (The required changes will be applied in later commits or in a new PR).

Copy link
Member

Choose a reason for hiding this comment

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

It's the comment itself that gets lost. clang-format configs are generally one way upgradable but otherwise stable. That is, clang-format-N+1 will read an N file and default the elements that are added, so that when you run dump-config you get a file that only cf-N+1 understands but that produces the same output as the old config.

Caveats around syntax that clang-format didn't used to understand, of course.

We don't need to be eager about upgrading unless we decide we need the new knobs.

I've left myself a TODO to see if clang-format changes matter for the few files we have, and if so, we probably don't need to upgrade.

It's just that the comments are easy to get lost, and I wouldn't want anyone to read too much into that.

@steve-downey
Copy link
Member

I'll take a look at what the lint fixes would do before approving this, but I'm in principle in favor of all it.

I have no strong feelings about markdown, shell, yaml, and json formatting -- all of them are terrible and I don't particularly care.

Slight preferences about C++ formatting, although as long as clang-format can put things back in canonical form it's only a slight preference. And with Lint Cpp currently green, it looks like I'm OK.

# Expected tools to be installed on the system. A pre-check is done to ensure all tools are installed.

set -e
set -x
Copy link
Member

Choose a reason for hiding this comment

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

Remove the execution trace option?
It's very noisy to use the script with this set.

Copy link
Member

@steve-downey steve-downey left a comment

Choose a reason for hiding this comment

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

👍

@neatudarius
Copy link
Member Author

Related PR - #52 . Will discuss with @steve-downey the approach.

@neatudarius
Copy link
Member Author

Put this PR on hold until we solve similar issue/discussion for beman.exampler.

@camio
Copy link
Member

camio commented Sep 26, 2024

Put this PR on hold until we solve similar issue/discussion for beman.exampler.

I think a good way to do that would be to mark it as a draft PR.

@neatudarius neatudarius reopened this Sep 26, 2024
@neatudarius
Copy link
Member Author

Put this PR on hold until we solve similar issue/discussion for beman.exampler.

I think a good way to do that would be to mark it as a draft PR.

It seems it cannot be put back to draft. I will temporary close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants