Skip to content

Commit

Permalink
CI: Optimized GH actions workflow YAML
Browse files Browse the repository at this point in the history
Avoids unnecessary jobs in open PRs, removes flake8 in favor of ruff.
Also adds minor style changes for ruff compliance.
  • Loading branch information
itellaetxe committed Sep 23, 2024
1 parent f7d3dde commit bc7036b
Show file tree
Hide file tree
Showing 23 changed files with 961 additions and 381 deletions.
25 changes: 11 additions & 14 deletions .github/workflows/lint_test_coverage.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Test Coverage Lint
name: TestCov Lint

on:
push:
branches-ignore:
branches:
- main
- release-*
pull_request:
branches: [ "main", "$default_branch" ]

jobs:
build:
Expand All @@ -25,16 +22,16 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry and the package dependencies
- name: Dependency installation
if: github.event_name == 'pull_request' || github.event_name == 'push'
run: |
python -m pip install --upgrade pip
python -m pip install poetry nox nox-poetry
- name: Nox TEST session
run: |
nox -s test
- name: Nox COVERAGE session
python -m pip install poetry nox nox-poetry
- name: TestCoverage
if: github.event_name == 'pull_request' || github.event_name == 'push'
run: |
nox -s coverage
- name: Nox LINTING session
- name: Linting
if: github.event_name == 'pull_request' || github.event_name == 'push'
run: |
nox -s lint
nox -s lint
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Apple
# Apple
.DS_store

# VSCode
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ageml
Copyright 2023 The ageml Developers

This product includes software developed at the Computational Neuroimaging Laboratory of the Biobizkaia Health Research Institute, Barakaldo, Basque Country.
This product includes software developed at the Computational Neuroimaging Laboratory of the Biobizkaia Health Research Institute, Barakaldo, Basque Country.
4 changes: 2 additions & 2 deletions bin/scripts/debug_classify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ageml.commands as commands

if __name__ == '__main__':
commands.clinical_classify()
if __name__ == "__main__":
commands.clinical_classify()
4 changes: 2 additions & 2 deletions bin/scripts/debug_clinical.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ageml.commands as commands

if __name__ == '__main__':
commands.clinical_groups()
if __name__ == "__main__":
commands.clinical_groups()
4 changes: 2 additions & 2 deletions bin/scripts/debug_factors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ageml.commands as commands

if __name__ == '__main__':
commands.factor_correlation()
if __name__ == "__main__":
commands.factor_correlation()
4 changes: 2 additions & 2 deletions bin/scripts/debug_model_age.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ageml.commands as commands

if __name__ == '__main__':
commands.ModelAge()
if __name__ == "__main__":
commands.ModelAge()
12 changes: 6 additions & 6 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ ageml
│ ├──CONTRIBUTING.md # Contribution Guidelines.
│ └──...
├── resources # Folder with figures and other supporting files
├── resources # Folder with figures and other supporting files
├── src # Contains all the source code of the package
│ └── ageml
│ ├── ...
│ └── ageml
│ ├── ...
│ ├── my_awesome_subpkg1
│ │ ├── __init__.py
│ │ └── awesome_fun.py
│ │ └── awesome_fun.py
│ └── my_awesome_subpkg2
│ ├── __init__.py
│ └── awesome_fun.py
Expand All @@ -49,8 +49,8 @@ ageml
│ └── test_awesome_fun
├── .coverage # File to measure code coverage, percentage of tested code lines
├── README.md
├── .coverage # File to measure code coverage, percentage of tested code lines
├── README.md
├── pyproject.toml # Requirements for environment settings, packaging and so on
├── poetry.lock # Dependency for building the system
├── noxfile.py # Defines the linting, coverage, pytest sessions
Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def coverage(s: Session) -> None:

@session(reuse_venv=True)
def lint(s: Session) -> None:
# Run pyproject-flake8 entrypoint to support reading configuration from pyproject.toml.
# Run the ruff linter, way faster than flake8
s.run("poetry", "install", external=True)
s.run("flake8")
s.run("ruff", "check")
118 changes: 117 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ scipy = ">=1.10"
statsmodels = "0.14.0"
matplotlib = "3.5"
scikit-learn = "1.3"
coverage-conditional-plugin = "^0.7.0"
xgboost = "^2.0.3"
pillow = "^10.3.0"
hpsklearn = {git = "https://github.com/hyperopt/hyperopt-sklearn", rev = "4bc286479677a0bfd2178dac4546ea268b3f3b77"}

[tool.poetry.dev-dependencies]
# Testing and linting tool
nox-poetry = "*"
coverage-conditional-plugin = "^0.7.0"
# Pre-commit
pre-commit = "^3.0.0"
# Testing
pytest = "*"
pytest-cov = "*"
Expand Down
10 changes: 5 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[flake8]
exclude = .nox, .pytest_cache, dist, .venv, resources, data, bin, .history,
exclude = .nox, .pytest_cache, dist, .venv, resources, data, bin, .history,
max-line-length = 140
statistics = True
# Which LINTING rules to ignore
ignore = F401, # Imported but unused
F403, # Unable to detect undefined names
B028, # No explicit stacklevel keyword argument found
W293, # blank line contains whitespace (I don't like this rule, interferes with good function indentation)
C419, # Unnecessary list comprehension passed to all() prevents short-circuiting - rewrite as a generator
C419, # Unnecessary list comprehension passed to all() prevents short-circuiting - rewrite as a generator
E702, # Multiple statements on one line (semicolon)
B023, # Function definition does not bind loop variable 'some_var_name'.

per-file-ignores =
per-file-ignores =
# It poses no inconvenient to violate B006 in this file.
tests/test_ageml/test_modelling.py: B006
tests/test_ageml/test_modelling.py: B006


[coverage:run]
Expand All @@ -25,4 +25,4 @@ plugins =
[coverage:coverage_conditional_plugin]
rules =
"is_installed('django')": has-django
"not is_installed('django')": has-no-django
"not is_installed('django')": has-no-django
2 changes: 1 addition & 1 deletion src/ageml/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ def main():
ageml.ui.CLI()


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading

0 comments on commit bc7036b

Please sign in to comment.