Skip to content

Commit

Permalink
[REF] refactor style checks in CI (#4406)
Browse files Browse the repository at this point in the history
* refactor style checks in CI

* update doc

* misc

* fix

* ref
  • Loading branch information
Remi-Gau committed Apr 30, 2024
1 parent 76b482b commit 44616e8
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 227 deletions.
60 changes: 13 additions & 47 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ Allows anyone to self-assign an issue automatically by commenting the word `take

Automatically comments on a newly open pull request to provide some guidelines, useful links and a checklist. The checklist is only editable by maintainers at the moment.

## Black formatting

### black.yml

Runs black code formatter on the codebase both in pull requests and on main. Configurations can be found in [pyproject.toml](../../pyproject.toml).

## Building the development documentation

### build-docs.yml
Expand Down Expand Up @@ -63,6 +57,9 @@ However for quick checks to do yourself you should always opt for local builds f

Note: setuptools needs to be installed to run the doc build with python 3.12.

Upon a successful build of the doc, it is zipped and uploaded as an artifact.
A circle-ci workflow is then triggered. See below.

#### Dataset caching

We also implemented a dataset caching strategy within this Actions workflow such that datasets are only downloaded once every month.
Expand All @@ -78,10 +75,13 @@ To run a full build and download all datasets, you would then combine both tags:
$ git commit -m "[full doc][force download] request full build"
```

#### Hosting of the docs
## Building the stable release documentation

Upon a successful build of the doc, it is zipped and uploaded as an artifact.
A circle-ci workflow is then triggered. See below.
### release-docs.yml

Should be triggered automatically after merging and tagging a release PR to
build the stable docs with a GitHub runner and push to nilearn.github.io.
Can also be triggered manually.

## Hosting and deploying development documentation

Expand All @@ -107,46 +107,12 @@ Pings github API to collect information about:
Plots the results and saves it as an artefact to download and manually inspect
to see if there is a trend in tests taking longer.

## Check spelling errors

### codespell.yml

Checks for spelling errors. Configured in [pyproject.toml](../../pyproject.toml). More information here: https://github.com/codespell-project/actions-codespell

## PEP8 check
## Style checks

### flake8.yml
### check_style_guide.yml

Uses flake8 tool to verify code is PEP8 compliant. Configured in [.flake8](../../.flake8)

## f strings

### f_strings.yml

Checks for f strings in the codebase with [flynt](https:/pypi.org/project/flynt/).
Configured in [pyproject.toml](../../pyproject.toml)
Flynt will check if it automatically convert "format" or "%" strings to "f strings".
This workflow will fail if it finds any potential target to be converted.

## Prettier formatting

### prettier.yml

Runs prettier to format HTML and CSS on the codebase both in pull requests and on main.

## Sort imports automatically

### isort.yml

Sorts Python imports alphabetically and by section. Configured in [pyproject.toml](../../pyproject.toml)

## Building the stable release documentation

### release-docs.yml

Should be triggered automatically after merging and tagging a release PR to
build the stable docs with a GitHub runner and push to nilearn.github.io.
Can also be triggered manually.
Relies on pre-commit to run a series of check on the content of the repositories.
See the config [`.pre-commit-config.yaml`](../../.pre-commit-config.yaml).

## Running unit tests

Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/black.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: flake8
name: check style guide compliance

on:
push:
Expand All @@ -13,27 +13,27 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Force to use color
env:
FORCE_COLOR: true

jobs:
flake8:
name: run flake8
style_check:
name: run pre-commit on all files
runs-on: ubuntu-latest

defaults:
run:
shell: bash

steps:
- name: Checkout nilearn
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.11'
allow-prereleases: false

- name: Install tox
run: python -m pip install --upgrade tox

- name: Run Flake8
run: tox run -e flake8
- name: Run pre-commit via tox
run: tox
21 changes: 0 additions & 21 deletions .github/workflows/codespell.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/f_strings.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/isort.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/prettier.yml

This file was deleted.

0 comments on commit 44616e8

Please sign in to comment.