diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..78018ddd6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Build-related directories and files +.task +build + +# IDE-related directories and files +.idea diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..2d96d0d8e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tools/yscope-dev-utils"] + path = tools/yscope-dev-utils + url = https://github.com/y-scope/yscope-dev-utils.git diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 000000000..a2a528336 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,5 @@ +extends: "tools/yscope-dev-utils/lint-configs/.yamllint.yml" + +ignore: | + build/ + tools/yscope-dev-utils/ diff --git a/README.md b/README.md new file mode 100644 index 000000000..ade08e545 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Contributing +Follow the steps below to develop and contribute to the project. + +## Requirements +* Python 3.8 or higher +* [Task] 3.38.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 +``` + +### Running specific linters +The commands above run all linting checks, but for performance you may want to run a subset (e.g., +if you only changed C++ files, you don't need to run the YAML linting checks) using one of the tasks +in the table below. + +| Task | Description | +|-------------------------|----------------------------------------------------------| +| `lint:yml-check` | Runs the YAML linters. | +| `lint:yml-fix` | Runs the YAML linters and fixes some violations. | + +[Task]: https://taskfile.dev diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 000000000..d0ff71756 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,19 @@ +version: "3" + +includes: + lint: "lint-tasks.yml" + 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/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 000000000..993e8b4fd --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1 @@ +yamllint>=1.35.1 diff --git a/lint-tasks.yml b/lint-tasks.yml new file mode 100644 index 000000000..2f2ff1492 --- /dev/null +++ b/lint-tasks.yml @@ -0,0 +1,51 @@ +version: "3" + +vars: + G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv" + +tasks: + check: + cmds: + - task: "yml-check" + + fix: + cmds: + - task: "yml-fix" + + yml: + aliases: + - "yml-check" + - "yml-fix" + deps: ["venv"] + cmds: + - |- + . "{{.G_LINT_VENV_DIR}}/bin/activate" + yamllint --strict . + + venv: + internal: true + vars: + CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK | replace \":\" \"#\"}}.md5" + OUTPUT_DIR: "{{.G_LINT_VENV_DIR}}" + sources: + - "{{.ROOT_DIR}}/Taskfile.yml" + - "{{.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/tools/yscope-dev-utils b/tools/yscope-dev-utils new file mode 160000 index 000000000..159768c7d --- /dev/null +++ b/tools/yscope-dev-utils @@ -0,0 +1 @@ +Subproject commit 159768c7d171595ed2cba17b758c10043a2efe96