Skip to content

Commit

Permalink
Add linting tools. (#19)
Browse files Browse the repository at this point in the history
* Add linting for YAML and C++ files and fix violations.
* Add Taskfile tasks to run linters.
* Add GitHub workflow to run linters periodically and on commit.
  • Loading branch information
SharafMohamed authored Aug 2, 2024
1 parent 6eda3b5 commit 0b9e45c
Show file tree
Hide file tree
Showing 17 changed files with 984 additions and 766 deletions.
47 changes: 23 additions & 24 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
Checks: >-
bugprone-*,
-bugprone-easily-swappable-parameters,
Expand All @@ -15,28 +14,28 @@ Checks: >-
-readability-identifier-length,
-readability-simplify-boolean-expr,
WarningsAsErrors: '*'
FormatStyle: file
WarningsAsErrors: "*"
FormatStyle: "file"
CheckOptions:
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true
readability-identifier-naming.ClassCase: 'CamelCase'
readability-identifier-naming.ClassMemberCase: 'lower_case'
readability-identifier-naming.ClassMemberPrefix: 'm_'
readability-identifier-naming.ClassMethodCase: 'lower_case'
readability-identifier-naming.ConstexprVariableCase: 'CamelCase'
readability-identifier-naming.ConstexprVariablePrefix: 'c'
readability-identifier-naming.EnumCase: 'CamelCase'
readability-identifier-naming.EnumConstantCase: 'CamelCase'
readability-identifier-naming.GlobalConstantCase: 'CamelCase'
readability-identifier-naming.GlobalConstantPrefix: 'c'
readability-identifier-naming.GlobalFunctionCase: 'lower_case'
readability-identifier-naming.GlobalVariableCase: 'lower_case'
readability-identifier-naming.LocalVariableCase: 'lower_case'
readability-identifier-naming.MemberCase: 'lower_case'
readability-identifier-naming.MemberPrefix: 'm_'
readability-identifier-naming.MethodCase: 'lower_case'
readability-identifier-naming.ParameterCase: 'lower_case'
readability-identifier-naming.StructCase: 'CamelCase'
readability-identifier-naming.TypedefCase: 'CamelCase'
readability-identifier-naming.TypedefIgnoredRegexp: '[a-z_]+_t'
readability-identifier-naming.UnionCase: 'CamelCase'
readability-identifier-naming.ClassCase: "CamelCase"
readability-identifier-naming.ClassMemberCase: "lower_case"
readability-identifier-naming.ClassMemberPrefix: "m_"
readability-identifier-naming.ClassMethodCase: "lower_case"
readability-identifier-naming.ConstexprVariableCase: "CamelCase"
readability-identifier-naming.ConstexprVariablePrefix: "c"
readability-identifier-naming.EnumCase: "CamelCase"
readability-identifier-naming.EnumConstantCase: "CamelCase"
readability-identifier-naming.GlobalConstantCase: "CamelCase"
readability-identifier-naming.GlobalConstantPrefix: "c"
readability-identifier-naming.GlobalFunctionCase: "lower_case"
readability-identifier-naming.GlobalVariableCase: "lower_case"
readability-identifier-naming.LocalVariableCase: "lower_case"
readability-identifier-naming.MemberCase: "lower_case"
readability-identifier-naming.MemberPrefix: "m_"
readability-identifier-naming.MethodCase: "lower_case"
readability-identifier-naming.ParameterCase: "lower_case"
readability-identifier-naming.StructCase: "CamelCase"
readability-identifier-naming.TypedefCase: "CamelCase"
readability-identifier-naming.TypedefIgnoredRegexp: "[a-z_]+_t"
readability-identifier-naming.UnionCase: "CamelCase"
65 changes: 33 additions & 32 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
name: "Bug Report"
description: Report software deficiencies
description: "Report software deficiencies"
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Use this form to report any functional or performance bugs you've found in the software.
- type: "markdown"
attributes:
value: |
Use this form to report any functional or performance bugs you've found in the software.
Be sure to check if your [issue](https://github.com/y-scope/log-surgeon/issues) has already been reported.
Be sure to check if your [issue](https://github.com/y-scope/log-surgeon/issues) has already
been reported.
- type: textarea
attributes:
label: Bug
description: "Describe what's wrong and if applicable, what you expected instead."
validations:
required: true
- type: "textarea"
attributes:
label: "Bug"
description: "Describe what's wrong and if applicable, what you expected instead."
validations:
required: true

- type: input
attributes:
label: log-surgeon version
description: "The release version number or development commit hash that has the bug."
placeholder: "Version number or commit hash"
validations:
required: true
- type: "input"
attributes:
label: "log-surgeon version"
description: "The release version number or development commit hash that has the bug."
placeholder: "Version number or commit hash"
validations:
required: true

- type: textarea
attributes:
label: Environment
description: "The environment in which you're running log-surgeon."
placeholder: "OS version, docker version, etc."
validations:
required: true
- type: "textarea"
attributes:
label: "Environment"
description: "The environment in which you're running log-surgeon."
placeholder: "OS version, docker version, etc."
validations:
required: true

- type: textarea
attributes:
label: Reproduction steps
description: "List each step required to reproduce the bug."
validations:
required: true
- type: "textarea"
attributes:
label: "Reproduction steps"
description: "List each step required to reproduce the bug."
validations:
required: true
35 changes: 17 additions & 18 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
name: "Feature/Change Request"
description: Request a feature or change
description: "Request a feature or change"
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Use this form to request a feature/change in the software, or the project as a whole.
- type: "markdown"
attributes:
value: |
Use this form to request a feature/change in the software, or the project as a whole.
- type: textarea
attributes:
label: Request
description: "Describe your request and why it's important."
validations:
required: true

- type: textarea
attributes:
label: Possible implementation
description: "Describe any implementations you have in mind."
validations:
required: true
- type: "textarea"
attributes:
label: "Request"
description: "Describe your request and why it's important."
validations:
required: true

- type: "textarea"
attributes:
label: "Possible implementation"
description: "Describe any implementations you have in mind."
validations:
required: true
35 changes: 27 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
name: Build
name: "Build"

on:
pull_request:
paths:
- ".github/workflows/build.yaml"
- "CMakeLists.txt"
- "examples/**/*"
- "src/**/*"
push:
paths:
- ".github/workflows/build.yaml"
- "CMakeLists.txt"
- "examples/**/*"
- "src/**/*"
workflow_call:

concurrency:
group: "${{github.workflow}}-${{github.ref}}"
# Cancel in-progress jobs for efficiency
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
build_type: [Release, Debug]
runs-on: ${{ matrix.os }}
os: ["macos-latest", "ubuntu-latest"]
build_type: ["Debug", "Release"]
runs-on: "${{matrix.os}}"
steps:
- uses: actions/checkout@v3
- uses: "actions/checkout@v4"

- run: "cmake -B ./build -DCMAKE_BUILD_TYPE=${{matrix.build_type}}"

- run: "cmake --build ./build --config ${{matrix.build_type}}"

- run: cmake -B ./build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- run: "cmake --install ./build --prefix ./install"

- run: cmake --build ./build --config ${{ matrix.build_type }}
- run: "cmake -S examples -B ./examples/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}}"

- run: cmake --install ./build --prefix ./install
- run: "cmake --build ./examples/build --config ${{matrix.build_type}}"
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "lint"

on:
pull_request:
push:
schedule:
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
- cron: "15 0 * * *"
workflow_dispatch:

concurrency:
group: "${{github.workflow}}-${{github.ref}}"
# Cancel in-progress jobs for efficiency
cancel-in-progress: true

jobs:
lint:
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: "${{matrix.os}}"
steps:
- uses: "actions/checkout@v4"
with:
submodules: "recursive"

- uses: "actions/setup-python@v5"
with:
python-version: "3.8"

- name: "Install task"
run: "npm install -g @go-task/cli"

- if: "matrix.os == 'macos-latest'"
name: "Install coreutils (for md5sum)"
run: "brew install coreutils"

- name: "Run lint task"
run: "task lint:check"
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tools/yscope-dev-utils"]
path = tools/yscope-dev-utils
url = https://github.com/y-scope/yscope-dev-utils
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,42 @@ To build the debug version replace the first command with:
* `log-surgeon`'s [design objectives](docs/design-objectives.md)
* [examples](examples) contains programs demonstrating usage of the library.

## Linting

Before submitting a PR, ensure you've run our linting tools and either fixed any violations or
suppressed the warning.

### Requirements

We currently support running our linting tools on Linux and macOS. If you're developing on another
OS, you can submit a [feature request][feature-req]. If you can't run the linting workflows
locally, you can enable and run the [lint] workflow in your fork.

To run the linting tools, besides commonly installed tools like `tar`, you'll need:

* `md5sum`
* Python 3.8 or newer
* python3-venv
* [Task]

### Running the linters

To report all errors run:

```shell
task lint:check
```

To fix cpp errors, and report yml errors, run:

```shell
task lint:fix
```

## Providing feedback

You can use GitHub issues to [report a bug](https://github.com/y-scope/log-surgeon/issues/new?assignees=&labels=bug&template=bug-report.yml)
or [request a feature](https://github.com/y-scope/log-surgeon/issues/new?assignees=&labels=enhancement&template=feature-request.yml).
or [request a feature][feature-req].

Join us on [Zulip](https://yscope-clp.zulipchat.com/) to chat with developers
and other community members.
Expand All @@ -123,3 +155,7 @@ The following are issues we're aware of and working on:
* A variable pattern has no way to match text around a variable, without having
it also be a part of the variable.
* Support for submatch extraction will be coming in a future release.

[feature-req]: https://github.com/y-scope/log-surgeon/issues/new?assignees=&labels=enhancement&template=feature-request.yml
[lint]: https://github.com/y-scope/log-surgeon/blob/main/.github/workflows/lint.yml
[Task]: https://taskfile.dev/
17 changes: 17 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3"

includes:
lint: "lint-tasks.yml"
utils: "tools/yscope-dev-utils/taskfiles/utils.yml"

vars:
G_BUILD_DIR: "{{.ROOT_DIR}}/build"

tasks:
clean: "rm -rf '{{.G_BUILD_DIR}}'"

init:
internal: true
silent: true
run: "once"
cmd: "mkdir -p '{{.G_BUILD_DIR}}'"
2 changes: 2 additions & 0 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
clang-format>=18.1.5
yamllint>=1.35.1
Loading

0 comments on commit 0b9e45c

Please sign in to comment.