Skip to content

Commit

Permalink
Merge pull request #1513 from ewels/nf-core-fix-linting
Browse files Browse the repository at this point in the history
Add fix-linting workflows
  • Loading branch information
ewels authored Apr 13, 2022
2 parents 2a1d1be + e3be16e commit 3edd219
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-lint-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

# Set up nf-core/tools
- name: Set up Python 3.8
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: 3.8

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-test-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
name: Check out source-code repository

- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: 3.7

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Check out source-code repository

- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: 3.7

Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Fix linting from a comment
on:
issue_comment:
types: [created]

jobs:
deploy:
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
if: >
contains(github.event.comment.html_url, '/pull/') &&
contains(github.event.comment.body, '@nf-core-bot fix linting') &&
github.repository == 'nf-core/tools'
runs-on: ubuntu-latest
steps:
# Use the @nf-core-bot token to check out so we can push later
- uses: actions/checkout@v3
with:
token: ${{ secrets.nf_core_bot_auth_token }}

# Action runs on the issue comment, so we don't get the PR by default
# Use the gh cli to check out the PR
- name: Checkout Pull Request
run: gh pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}

- uses: actions/setup-node@v2

- name: Install Prettier
run: npm install -g prettier @prettier/plugin-php

- name: Run 'prettier --write'
run: prettier --write ${GITHUB_WORKSPACE}

- name: Run Black
uses: psf/black@stable
with:
# Override to remove the default --check flag so that we make changes
options: "--color"

- name: Commit & push changes
run: |
git config user.email "[email protected]"
git config user.name "nf-core-bot"
git config push.default upstream
git add .
git status
git commit -m "[automated] Fix linting with Prettier"
git push
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: Check out source-code repository

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
fetch-depth: "0"

- name: Set up Python 3.8
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: 3.8

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools-api-docs-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: 3.7

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools-api-docs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: 3.7

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ This patch release to removes the Graphviz dependency from default pipeline temp
- Fix Prettier formatting bug in completion email HTML template ([#1509](https://github.com/nf-core/tools/issues/1509))
- Removed retry strategy for AWS tests CI, as Nextflow now handles spot instance retries itself
- Add `.prettierignore` file to stop Prettier linting tests from running over test files
- Add actions workflow to respond to `@nf-core-bot fix linting` comments on pipeline PRs

### General

- Bumped the minimum version of `rich` from `v10` to `v10.7.0`
- Add an empty line to `modules.json`, `params.json` and `nextflow-schema.json` when dumping them to avoid prettier errors.
- Add actions workflow to respond to `@nf-core-bot fix linting` comments on nf-core/tools PRs

### Modules

Expand Down
55 changes: 55 additions & 0 deletions nf_core/pipeline-template/.github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Fix linting from a comment
on:
issue_comment:
types: [created]

jobs:
deploy:
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
if: >
contains(github.event.comment.html_url, '/pull/') &&
contains(github.event.comment.body, '@nf-core-bot fix linting') &&
github.repository == '{{ name }}' {%- raw %}
runs-on: ubuntu-latest
steps:
# Use the @nf-core-bot token to check out so we can push later
- uses: actions/checkout@v3
with:
token: ${{ secrets.nf_core_bot_auth_token }}

# Action runs on the issue comment, so we don't get the PR by default
# Use the gh cli to check out the PR
- name: Checkout Pull Request
run: gh pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}

- uses: actions/setup-node@v2

- name: Install Prettier
run: npm install -g prettier @prettier/plugin-php

# Check that we actually need to fix something
- name: Run 'prettier --check'
id: prettier_status
run: |
if prettier --check ${GITHUB_WORKSPACE}; then
echo "::set-output name=result::pass"
else
echo "::set-output name=result::fail"
fi
- name: Run 'prettier --write'
if: steps.prettier_status.outputs.result == 'fail'
run: prettier --write ${GITHUB_WORKSPACE}

- name: Commit & push changes
if: steps.prettier_status.outputs.result == 'fail'
run: |
git config user.email "[email protected]"
git config user.name "nf-core-bot"
git config push.default upstream
git add .
git status
git commit -m "[automated] Fix linting with Prettier"
git push {%- endraw %}
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/.github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
- uses: actions/setup-python@v1
- uses: actions/setup-python@v3
with:
python-version: "3.6"
architecture: "x64"
Expand Down

0 comments on commit 3edd219

Please sign in to comment.