Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure GitHub Actions to run Super-Linter #3

Merged
merged 3 commits into from Feb 23, 2021
Merged

Conversation

lparsons
Copy link
Contributor

This Pull Request sets up a GitHub Actions workflow that runs the GitHub Super-Linter on the entire codebase. It also formats the files according to the standards specified by the linters.

Super-Linter is a collection of bash scripts that run various "standard" linters for many different types of files. The hope is that this helps to:

  • Prevent broken code from being uploaded to the default branch (main)
  • Help establish coding best practices across multiple languages
  • Build guidelines for code layout and format
  • Automate the process to help streamline code reviews

The linters that are in use right now are:

  • Markdown-lint - .markdown-lint.yml
  • Flake8 - .flake8
  • Pylint - .python-lint -> .pylintrc
  • Black - .python-black - Note that black will actually reformat your code for you, so just run black . before committing to fix everything up.
  • isort - .isort.cfg - isort also automatically formats files for you (isort .)

The python linters can all be installed via pip. To make it simpler to install them on a development machine, this PR creates a requirements/dev.txt file that can be used to create a virtual environment with the linters installed in addition to the core dependencies. Using requirements.txt or requirements/prod.txt will install only those things needed for production.

Finally, the configuration for the linters is borrowed from Super-Linter which attempts to provide some "best-practices" and also help ensure the linters all get along. There are two changes to the defaults:

  • .isort.cfg
    • Added config to include our Django apps as first party packages. For some reason running under Super-Linter didn't do this in GitHub actions.
  • .flake8

Formatting with:
* markdownlint
* flake8
* pylint
* black
* isort
Copy link
Collaborator

@hepcat72 hepcat72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking.

.flake8 Show resolved Hide resolved
.github/workflows/superlinter.yml Show resolved Hide resolved
.isort.cfg Outdated Show resolved Hide resolved
.github/workflows/superlinter.yml Outdated Show resolved Hide resolved
.markdown-lint.yml Outdated Show resolved Hide resolved
DataRepo/admin.py Show resolved Hide resolved
DataRepo/models.py Show resolved Hide resolved
DataRepo/tests.py Show resolved Hide resolved
DataRepo/views.py Show resolved Hide resolved
requirements/dev.txt Show resolved Hide resolved
Fix spelling and grammar

Co-authored-by: Robert Leach <rleach@princeton.edu>
@hepcat72
Copy link
Collaborator

Resolved all comments. Full speed ahead!

@lparsons lparsons merged commit 72deb00 into main Feb 23, 2021
@lparsons lparsons added this to the Stub website milestone Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants