From 2dfdff0e328f21fef6bc173a46e96d7279f5b5d4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 5 Sep 2021 06:04:41 -0700 Subject: [PATCH 1/3] tools,build: update YAML files in preparation for linting Fix indentation, traiiling spaces, and missing newline issues in preparation for linting. --- .github/workflows/comment-labeled.yml | 2 +- .github/workflows/coverage-linux.yml | 2 +- .../workflows/find-inactive-collaborators.yml | 2 +- .github/workflows/notify-force-push.yml | 24 +++++++++---------- test/.eslintrc.yaml | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/comment-labeled.yml b/.github/workflows/comment-labeled.yml index 14e48ea8dd37ca..c2c700c38b8ca1 100644 --- a/.github/workflows/comment-labeled.yml +++ b/.github/workflows/comment-labeled.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Post stalled comment env: - COMMENTS_URL: ${{ github.event.issue.comments_url || github.event.pull_request.comments_url }} + COMMENTS_URL: ${{ github.event.issue.comments_url || github.event.pull_request.comments_url }} run: | curl -X POST $COMMENTS_URL \ -H "Content-Type: application/json" \ diff --git a/.github/workflows/coverage-linux.yml b/.github/workflows/coverage-linux.yml index 2ee6c8b5f19b77..59a758ebdfc6a0 100644 --- a/.github/workflows/coverage-linux.yml +++ b/.github/workflows/coverage-linux.yml @@ -45,7 +45,7 @@ jobs: - name: Report JS run: npx c8 report --check-coverage env: - NODE_OPTIONS: --max-old-space-size=8192 + NODE_OPTIONS: --max-old-space-size=8192 - name: Report C++ run: cd out && gcovr --gcov-exclude='.*\b(deps|usr|out|obj|cctest|embedding)\b' -v -r Release/obj.target --xml -o ../coverage/coverage-cxx.xml --root=$(cd ../ && pwd) # Clean temporary output from gcov and c8, so that it's not uploaded: diff --git a/.github/workflows/find-inactive-collaborators.yml b/.github/workflows/find-inactive-collaborators.yml index f4dfc964ccd2f3..ca582839fc8b7d 100644 --- a/.github/workflows/find-inactive-collaborators.yml +++ b/.github/workflows/find-inactive-collaborators.yml @@ -13,7 +13,7 @@ env: jobs: find: - + runs-on: ubuntu-latest steps: diff --git a/.github/workflows/notify-force-push.yml b/.github/workflows/notify-force-push.yml index e3bdc0353c60fb..9c2fc3a6a4e64d 100644 --- a/.github/workflows/notify-force-push.yml +++ b/.github/workflows/notify-force-push.yml @@ -11,16 +11,16 @@ jobs: if: ${{ github.event.forced && github.repository == 'nodejs/node' }} runs-on: ubuntu-latest steps: - - name: Slack Notification - uses: rtCamp/action-slack-notify@master - env: - SLACK_COLOR: '#DE512A' - SLACK_ICON: https://github.com/nodejs.png?size=48 - SLACK_TITLE: '${{ github.actor }} force-pushed to ${{ github.ref }}' - SLACK_MESSAGE: | - A commit was force-pushed to by + - name: Slack Notification + uses: rtCamp/action-slack-notify@master + env: + SLACK_COLOR: '#DE512A' + SLACK_ICON: https://github.com/nodejs.png?size=48 + SLACK_TITLE: '${{ github.actor }} force-pushed to ${{ github.ref }}' + SLACK_MESSAGE: | + A commit was force-pushed to by - Before: - After: - SLACK_USERNAME: nodejs-bot - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + Before: + After: + SLACK_USERNAME: nodejs-bot + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 6a0104f7ce17ca..50c51ae5010da3 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -8,7 +8,7 @@ rules: no-var: error prefer-const: error symbol-description: off - multiline-comment-style: ["error", "separate-lines"] + multiline-comment-style: ["error", "separate-lines"] no-restricted-syntax: # Config copied from .eslintrc.js From 6e6ff64c05b183a789bf0f0631e6fa49194b7597 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 5 Sep 2021 05:59:24 -0700 Subject: [PATCH 2/3] build: add YAML linting --- .gitignore | 5 +++-- .yamllint.yaml | 8 ++++++++ Makefile | 25 ++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 .yamllint.yaml diff --git a/.gitignore b/.gitignore index c0053a07323419..b7a33d86bedf61 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,11 @@ !deps/**/.* !test/fixtures/**/.* !.clang-format +!.cpplint !.editorconfig !.eslintignore !.eslintrc.js +!.eslintrc.yaml !.flake8 !.gitattributes !.github @@ -19,8 +21,7 @@ !.gitkeep !.mailmap !.nycrc -!.eslintrc.yaml -!.cpplint +!.yamllint.yaml # === Rules for root dir === /core diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 00000000000000..d4af06e4156947 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,8 @@ +extends: relaxed + +rules: + line-length: disable + +ignore: | + /deps/ + node_modules/ diff --git a/Makefile b/Makefile index cc0539d98e8ab9..baae6a3b46bd26 100644 --- a/Makefile +++ b/Makefile @@ -1389,13 +1389,13 @@ cpplint: lint-cpp .PHONY: lint-py-build # python -m pip install flake8 -# Try with '--system' is to overcome systems that blindly set '--user' +# Try with '--system' if it fails without; the system may have set '--user' lint-py-build: $(info Pip installing flake8 linter on $(shell $(PYTHON) --version)...) $(PYTHON) -m pip install --upgrade -t tools/pip/site-packages flake8 || \ $(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages flake8 -ifneq ("","$(wildcard tools/pip/site-packages)") +ifneq ("","$(wildcard tools/pip/site-packages/flake8)") .PHONY: lint-py # Lints the Python code with flake8. # Flag the build if there are Python syntax errors or undefined names @@ -1407,6 +1407,24 @@ lint-py: $(warning Run 'make lint-py-build') endif +.PHONY: lint-yaml-build +# python -m pip install yamllint +# Try with '--system' if it fails without; the system may have set '--user' +lint-yaml-build: + $(info Pip installing yamllint on $(shell $(PYTHON) --version)...) + $(PYTHON) -m pip install --upgrade -t tools/pip/site-packages yamllint || \ + $(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages yamllint + +.PHONY: lint-yaml +# Lints the YAML files with yamllint. +lint-yaml: + @if [ -d "tools/pip/site-packages/yamllint" ]; then \ + PYTHONPATH=tools/pip $(PYTHON) -m yamllint .; \ + else \ + echo 'YAML linting with yamllint is not available'; \ + echo "Run 'make lint-yaml-build'"; \ + fi + .PHONY: lint .PHONY: lint-ci ifneq ("","$(wildcard tools/node_modules/eslint/)") @@ -1416,11 +1434,12 @@ lint: ## Run JS, C++, MD and doc linters. $(MAKE) lint-cpp || EXIT_STATUS=$$? ; \ $(MAKE) lint-addon-docs || EXIT_STATUS=$$? ; \ $(MAKE) lint-md || EXIT_STATUS=$$? ; \ + $(MAKE) lint-yaml || EXIT_STATUS=$$? ; \ exit $$EXIT_STATUS CONFLICT_RE=^>>>>>>> [[:xdigit:]]+|^<<<<<<< [[:alpha:]]+ # Related CI job: node-test-linter -lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs +lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs lint-yaml-build lint-yaml @if ! ( grep -IEqrs "$(CONFLICT_RE)" --exclude="error-message.js" benchmark deps doc lib src test tools ) \ && ! ( $(FIND) . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \ exit 0 ; \ From 75940488d3a37bf5f0f0261cf0092ffa2fc8905c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 5 Sep 2021 06:38:07 -0700 Subject: [PATCH 3/3] build: add YAML linting to GitHub Actions --- .github/workflows/linters.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 987a38e56165fe..f15872bbc22b09 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -90,7 +90,23 @@ jobs: - name: Lint Python run: | make lint-py-build || true - NODE=$(command -v node) make lint-py + make lint-py + lint-yaml: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v2 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Environment Information + run: npx envinfo + - name: Lint YAML + run: | + make lint-yaml-build || true + make lint-yaml + lint-sh: if: github.event.pull_request.draft == false runs-on: ubuntu-20.04