From 1e51a1ad9e93adea0fb2434cb9f28b420873781c Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Sat, 18 Jan 2025 05:01:00 -0500 Subject: [PATCH 1/7] Add lint tasks for yaml files --- .gitignore | 3 +++ lint-requirements.txt | 18 ++++++++++++++ taskfile.yaml | 20 ++++++++++++++++ tasks/lint-tasks.yaml | 48 ++++++++++++++++++++++++++++++++++++++ tasks/lint-yaml-tasks.yaml | 19 +++++++++++++++ 5 files changed, 108 insertions(+) create mode 100644 .gitignore create mode 100644 lint-requirements.txt create mode 100644 taskfile.yaml create mode 100644 tasks/lint-tasks.yaml create mode 100644 tasks/lint-yaml-tasks.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..486e796 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Build-related directories and files +.task +build diff --git a/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 0000000..f0dd622 --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1,18 @@ +black>=24.4.2 +build>=0.8.0 +cibuildwheel>=2.16.2 +clang-format>=19.1.6 +clang-tidy>=19.1.0 +docformatter>=1.7.5 +gersemi>=0.16.2 +# Lock to v0.3.0 to support Python3.7 +msgpack-types==0.3.0 +mypy>=1.10.0 +mypy-extensions>=1.0.0 +packaging>=21.3 +ruff>=0.4.6 +smart_open==6.4.0 +types-Deprecated>=1.2.9 +types-python-dateutil>=2.8 +yamllint>=1.35.1 +zstandard>=0.18.0 diff --git a/taskfile.yaml b/taskfile.yaml new file mode 100644 index 0000000..051d224 --- /dev/null +++ b/taskfile.yaml @@ -0,0 +1,20 @@ +version: "3" + +includes: + lint: "./tasks/lint-tasks.yaml" + utils: "tools/yscope-dev-utils/taskfiles/utils.yml" + +vars: + G_BUILD_DIR: "{{.ROOT_DIR}}/build" + +tasks: + clean: + cmds: + - "rm -rf '{{.G_BUILD_DIR}}'" + + init: + internal: true + silent: true + run: "once" + cmds: + - "mkdir -p '{{.G_BUILD_DIR}}'" diff --git a/tasks/lint-tasks.yaml b/tasks/lint-tasks.yaml new file mode 100644 index 0000000..0321d34 --- /dev/null +++ b/tasks/lint-tasks.yaml @@ -0,0 +1,48 @@ +version: "3" + +includes: + yaml: + flatten: true + taskfile: "./lint-yaml-tasks.yaml" + +vars: + G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv" + G_LINT_VENV_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/lint#venv.md5" + +tasks: + check: + cmds: + - task: "yaml-check" + + fix: + cmds: + - task: "yaml-fix" + + venv: + internal: true + vars: + CHECKSUM_FILE: "{{.G_LINT_VENV_CHECKSUM_FILE}}" + OUTPUT_DIR: "{{.G_LINT_VENV_DIR}}" + sources: + - "{{.ROOT_DIR}}/taskfile.yaml" + - "{{.TASKFILE}}" + - "lint-requirements.txt" + generates: + - "{{.CHECKSUM_FILE}}" + deps: + - ":init" + - task: ":utils:validate-checksum" + vars: + CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" + DATA_DIR: "{{.OUTPUT_DIR}}" + cmds: + - task: ":utils:create-venv" + vars: + LABEL: "lint" + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + REQUIREMENTS_FILE: "lint-requirements.txt" + # This command must be last + - task: ":utils:compute-checksum" + vars: + DATA_DIR: "{{.OUTPUT_DIR}}" + OUTPUT_FILE: "{{.CHECKSUM_FILE}}" diff --git a/tasks/lint-yaml-tasks.yaml b/tasks/lint-yaml-tasks.yaml new file mode 100644 index 0000000..c56c013 --- /dev/null +++ b/tasks/lint-yaml-tasks.yaml @@ -0,0 +1,19 @@ +version: "3" + +tasks: + yaml: + aliases: + - "yaml-check" + - "yaml-fix" + deps: + - "venv" + dir: "{{.ROOT_DIR}}" + cmds: + - "echo '{{.TASKFILE}}'" + - |- + . "{{.G_LINT_VENV_DIR}}/bin/activate" + yamllint \ + --config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \ + --strict \ + tasks/ \ + taskfile.yaml From 527dad1cb92a827a996824975b2c573bf6bb3806 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 21 Jan 2025 13:21:50 -0500 Subject: [PATCH 2/7] Address review concerns --- lint-requirements.txt | 17 ----------------- taskfile.yaml | 2 +- .../lint-yaml.yaml | 6 +++--- tasks/lint-tasks.yaml => taskfiles/lint.yaml | 2 +- 4 files changed, 5 insertions(+), 22 deletions(-) rename tasks/lint-yaml-tasks.yaml => taskfiles/lint-yaml.yaml (81%) rename tasks/lint-tasks.yaml => taskfiles/lint.yaml (96%) diff --git a/lint-requirements.txt b/lint-requirements.txt index f0dd622..993e8b4 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1,18 +1 @@ -black>=24.4.2 -build>=0.8.0 -cibuildwheel>=2.16.2 -clang-format>=19.1.6 -clang-tidy>=19.1.0 -docformatter>=1.7.5 -gersemi>=0.16.2 -# Lock to v0.3.0 to support Python3.7 -msgpack-types==0.3.0 -mypy>=1.10.0 -mypy-extensions>=1.0.0 -packaging>=21.3 -ruff>=0.4.6 -smart_open==6.4.0 -types-Deprecated>=1.2.9 -types-python-dateutil>=2.8 yamllint>=1.35.1 -zstandard>=0.18.0 diff --git a/taskfile.yaml b/taskfile.yaml index 051d224..478ba2a 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -1,7 +1,7 @@ version: "3" includes: - lint: "./tasks/lint-tasks.yaml" + lint: "./taskfiles/lint.yaml" utils: "tools/yscope-dev-utils/taskfiles/utils.yml" vars: diff --git a/tasks/lint-yaml-tasks.yaml b/taskfiles/lint-yaml.yaml similarity index 81% rename from tasks/lint-yaml-tasks.yaml rename to taskfiles/lint-yaml.yaml index c56c013..0196a03 100644 --- a/tasks/lint-yaml-tasks.yaml +++ b/taskfiles/lint-yaml.yaml @@ -9,11 +9,11 @@ tasks: - "venv" dir: "{{.ROOT_DIR}}" cmds: - - "echo '{{.TASKFILE}}'" - |- . "{{.G_LINT_VENV_DIR}}/bin/activate" yamllint \ --config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \ --strict \ - tasks/ \ - taskfile.yaml + .github \ + taskfile.yaml \ + taskfiles/ diff --git a/tasks/lint-tasks.yaml b/taskfiles/lint.yaml similarity index 96% rename from tasks/lint-tasks.yaml rename to taskfiles/lint.yaml index 0321d34..cbfca7e 100644 --- a/tasks/lint-tasks.yaml +++ b/taskfiles/lint.yaml @@ -3,7 +3,7 @@ version: "3" includes: yaml: flatten: true - taskfile: "./lint-yaml-tasks.yaml" + taskfile: "./lint-yaml.yaml" vars: G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv" From 2b49533c407a5db463d13d6ccbef9fb9237162c7 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 22 Jan 2025 04:17:58 -0500 Subject: [PATCH 3/7] Add task descriptions --- taskfile.yaml | 1 + taskfiles/lint-yaml.yaml | 1 + taskfiles/lint.yaml | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/taskfile.yaml b/taskfile.yaml index 478ba2a..7a5ef57 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -9,6 +9,7 @@ vars: tasks: clean: + desc: "Removes project builds." cmds: - "rm -rf '{{.G_BUILD_DIR}}'" diff --git a/taskfiles/lint-yaml.yaml b/taskfiles/lint-yaml.yaml index 0196a03..1f5adaf 100644 --- a/taskfiles/lint-yaml.yaml +++ b/taskfiles/lint-yaml.yaml @@ -5,6 +5,7 @@ tasks: aliases: - "yaml-check" - "yaml-fix" + desc: "Runs the YAML linters. Only checks for warnings and violations." deps: - "venv" dir: "{{.ROOT_DIR}}" diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index cbfca7e..0df13f2 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -11,14 +11,18 @@ vars: tasks: check: + desc: |- + Runs the full suite of linters for various file tyes and checks for warnings or violations. cmds: - task: "yaml-check" fix: + desc: "Runs the full suite of linters and automatically fixes any fixable issues." cmds: - task: "yaml-fix" venv: + desc: "Creates the virtual environment to run the linters." internal: true vars: CHECKSUM_FILE: "{{.G_LINT_VENV_CHECKSUM_FILE}}" From 917c9bc7d26d3691af834e95155367e27ebe3d21 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 22 Jan 2025 04:50:14 -0500 Subject: [PATCH 4/7] Add a basic guide for running linters --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index e69de29..3611b9e 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,35 @@ +ystdlib-cpp +=================================== +An open-source C++ library developed and used at YScope. + +# Contributing +Follow the steps below to develop and contribute to the project. + +## Requirements +* Python 3.10 or higher +* [Task] 3.40.0 or higher + +## Set up +Initialize and update submodules: +```shell +git submodule update --init --recursive +``` + +## Linting +Before submitting a pull request, ensure you’ve run the linting commands below and either fixed any +violations or suppressed the warning. + +To run all linting checks: +```shell +task lint:check +``` + +To run all linting checks AND automatically fix any fixable issues: +```shell +task lint:fix +``` + +To see which linters are available and how to run a specific linter: +```shell +task --list-all +``` From a991e8b0131c7b175d47e06032d1c14b1e457772 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 22 Jan 2025 04:52:43 -0500 Subject: [PATCH 5/7] Add missing link to TASK --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3611b9e..60d24a2 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ git submodule update --init --recursive ``` ## Linting -Before submitting a pull request, ensure you’ve run the linting commands below and either fixed any -violations or suppressed the warning. +Before submitting a pull request, ensure you’ve run the linting commands below to fix violations or +suppress warnings. To run all linting checks: ```shell @@ -33,3 +33,4 @@ To see which linters are available and how to run a specific linter: ```shell task --list-all ``` +[Task]: https://taskfile.dev From 5d50eb1f7ee01fb7069693c2c9a648a75dfe4ae3 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 22 Jan 2025 05:03:53 -0500 Subject: [PATCH 6/7] Clarify --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60d24a2..59fdb02 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,10 @@ To run all linting checks AND automatically fix any fixable issues: task lint:fix ``` -To see which linters are available and how to run a specific linter: +To see which linters are available and how to run a specific linter, run ```shell task --list-all ``` +and check for all tasks under the `lint` namespace (marked with the `lint:` prefix). + [Task]: https://taskfile.dev From c34012ad47df5b848a79ede84c6504c6d4b0a758 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 22 Jan 2025 14:11:39 -0500 Subject: [PATCH 7/7] Reverted the last 4 commits --- README.md | 38 -------------------------------------- taskfile.yaml | 1 - taskfiles/lint-yaml.yaml | 1 - taskfiles/lint.yaml | 4 ---- 4 files changed, 44 deletions(-) diff --git a/README.md b/README.md index 59fdb02..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,38 +0,0 @@ -ystdlib-cpp -=================================== -An open-source C++ library developed and used at YScope. - -# Contributing -Follow the steps below to develop and contribute to the project. - -## Requirements -* Python 3.10 or higher -* [Task] 3.40.0 or higher - -## Set up -Initialize and update submodules: -```shell -git submodule update --init --recursive -``` - -## Linting -Before submitting a pull request, ensure you’ve run the linting commands below to fix violations or -suppress warnings. - -To run all linting checks: -```shell -task lint:check -``` - -To run all linting checks AND automatically fix any fixable issues: -```shell -task lint:fix -``` - -To see which linters are available and how to run a specific linter, run -```shell -task --list-all -``` -and check for all tasks under the `lint` namespace (marked with the `lint:` prefix). - -[Task]: https://taskfile.dev diff --git a/taskfile.yaml b/taskfile.yaml index 7a5ef57..478ba2a 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -9,7 +9,6 @@ vars: tasks: clean: - desc: "Removes project builds." cmds: - "rm -rf '{{.G_BUILD_DIR}}'" diff --git a/taskfiles/lint-yaml.yaml b/taskfiles/lint-yaml.yaml index 1f5adaf..0196a03 100644 --- a/taskfiles/lint-yaml.yaml +++ b/taskfiles/lint-yaml.yaml @@ -5,7 +5,6 @@ tasks: aliases: - "yaml-check" - "yaml-fix" - desc: "Runs the YAML linters. Only checks for warnings and violations." deps: - "venv" dir: "{{.ROOT_DIR}}" diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 0df13f2..cbfca7e 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -11,18 +11,14 @@ vars: tasks: check: - desc: |- - Runs the full suite of linters for various file tyes and checks for warnings or violations. cmds: - task: "yaml-check" fix: - desc: "Runs the full suite of linters and automatically fixes any fixable issues." cmds: - task: "yaml-fix" venv: - desc: "Creates the virtual environment to run the linters." internal: true vars: CHECKSUM_FILE: "{{.G_LINT_VENV_CHECKSUM_FILE}}"