From 6c9a8d3ae74889ad24895796f6c1bdb2ff0eb146 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 23 Mar 2021 13:05:58 +0100 Subject: [PATCH 1/3] Add code lint CI PR comments to pipeline template --- .github/workflows/markdown-lint.yml | 9 +-- .../.github/workflows/linting.yml | 55 +++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml index 5a590aff8e..3e2158c9f4 100644 --- a/.github/workflows/markdown-lint.yml +++ b/.github/workflows/markdown-lint.yml @@ -30,13 +30,14 @@ jobs: * Install `markdownlint-cli` * On Mac: `brew install markdownlint-cli` - * Everything else: [Install `npm`](https://www.npmjs.com/get-npm) then [install `markdownlint-cli`](https://www.npmjs.com/package/markdownlint-cli): `npm install -g markdownlint-cli` - * Try to automatically fix errors in your pipeline: `markdownlint . --config .github/markdownlint.yml --fix` - * Check that there are no remaining problems: `markdownlint . --config .github/markdownlint.yml` + * Everything else: [Install `npm`](https://www.npmjs.com/get-npm) then [install `markdownlint-cli`](https://www.npmjs.com/package/markdownlint-cli) (`npm install -g markdownlint-cli`) + * Fix the markdown errors + * Automatically: `markdownlint . --config .github/markdownlint.yml --fix` + * Manually resolve anything left from `markdownlint . --config .github/markdownlint.yml` Once you push these changes the test should pass, and you can hide this comment :+1: - We highly recommend setting up Black in your code editor so that this formatting is done automatically on save. Ask about it on Slack for help! + We highly recommend setting up markdownlint in your code editor so that this formatting is done automatically on save. Ask about it on Slack for help! Thanks again for your contribution! repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/nf_core/pipeline-template/.github/workflows/linting.yml b/nf_core/pipeline-template/.github/workflows/linting.yml index 900067a0da..50918d9776 100644 --- a/nf_core/pipeline-template/.github/workflows/linting.yml +++ b/nf_core/pipeline-template/.github/workflows/linting.yml @@ -19,6 +19,34 @@ jobs: run: npm install -g markdownlint-cli - name: Run Markdownlint run: markdownlint ${GITHUB_WORKSPACE} -c ${GITHUB_WORKSPACE}/.github/markdownlint.yml + + # If the above check failed, post a comment on the PR explaining the failure + - name: Post PR comment + if: failure() + uses: mshick/add-pr-comment@v1 + with: + message: | + ## Markdown linting is failing + + To keep the code consistent with lots of contributors, we run automated code consistency checks. + To fix this CI test, please run: + + * Install `markdownlint-cli` + * On Mac: `brew install markdownlint-cli` + * Everything else: [Install `npm`](https://www.npmjs.com/get-npm) then [install `markdownlint-cli`](https://www.npmjs.com/package/markdownlint-cli) (`npm install -g markdownlint-cli`) + * Fix the markdown errors + * Automatically: `markdownlint . --config .github/markdownlint.yml --fix` + * Manually resolve anything left from `markdownlint . --config .github/markdownlint.yml` + + Once you push these changes the test should pass, and you can hide this comment :+1: + + We highly recommend setting up markdownlint in your code editor so that this formatting is done automatically on save. Ask about it on Slack for help! + + Thanks again for your contribution! + repo-token: ${{ secrets.GITHUB_TOKEN }} + allow-repeats: false + + YAML: runs-on: ubuntu-latest steps: @@ -30,6 +58,33 @@ jobs: run: npm install -g yaml-lint - name: Run yaml-lint run: yamllint $(find ${GITHUB_WORKSPACE} -type f -name "*.yml") + + # If the above check failed, post a comment on the PR explaining the failure + - name: Post PR comment + if: failure() + uses: mshick/add-pr-comment@v1 + with: + message: | + ## YAML linting is failing + + To keep the code consistent with lots of contributors, we run automated code consistency checks. + To fix this CI test, please run: + + * Install `yaml-lint` + * [Install `npm`](https://www.npmjs.com/get-npm) then [install `yaml-lint`](https://www.npmjs.com/package/yaml-lint) (`npm install -g yaml-lint`) + * Fix the markdown errors + * Run the test locally: `yamllint $(find . -type f -name "*.yml")` + * Fix any reported errors in your YAML files + + Once you push these changes the test should pass, and you can hide this comment :+1: + + We highly recommend setting up yaml-lint in your code editor so that this formatting is done automatically on save. Ask about it on Slack for help! + + Thanks again for your contribution! + repo-token: ${{ secrets.GITHUB_TOKEN }} + allow-repeats: false + + nf-core: runs-on: ubuntu-latest steps: From ac62403b54327f530e5acf0717074fb3ef23f69c Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 23 Mar 2021 13:06:45 +0100 Subject: [PATCH 2/3] Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b50dc04d..905550a74e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ * Fixed parameter validation bug caused by JSONObject [[#937](https://github.com/nf-core/tools/issues/937)] * Fixed template creation error regarding file permissions [[#932](https://github.com/nf-core/tools/issues/932)] * Split the `create-lint-wf` tests up into separate steps in GitHub Actions to make the CI results easier to read -* Added automated PR comments to the Markdownlint and Python Black lint CI tests to explain failures +* Added automated PR comments to the Markdown, YAML and Python lint CI tests to explain failures (tools and pipeline template) ## [v1.13.1 - Copper Crocodile Patch :crocodile: :pirate_flag:](https://github.com/nf-core/tools/releases/tag/1.13.1) - [2021-03-19] From 217eceae6afc6de5dc4d063d8055d9cc82cb9200 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 23 Mar 2021 13:32:03 +0100 Subject: [PATCH 3/3] Proper {{}} escaping in workflow for new comments --- nf_core/pipeline-template/.github/workflows/linting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nf_core/pipeline-template/.github/workflows/linting.yml b/nf_core/pipeline-template/.github/workflows/linting.yml index 50918d9776..5b09090281 100644 --- a/nf_core/pipeline-template/.github/workflows/linting.yml +++ b/nf_core/pipeline-template/.github/workflows/linting.yml @@ -1,4 +1,4 @@ -name: nf-core linting +{% raw %}name: nf-core linting # This workflow is triggered on pushes and PRs to the repository. # It runs the `nf-core lint` and markdown lint tests to ensure that the code meets the nf-core guidelines on: @@ -108,7 +108,7 @@ jobs: run: | python -m pip install --upgrade pip pip install nf-core -{% raw %} + - name: Run nf-core lint env: GITHUB_COMMENTS_URL: ${{ github.event.pull_request.comments_url }}