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

Casei precommit #549

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: local
hooks:
- id: eslint
name: eslint
entry: ./node_modules/.bin/eslint
language: script
types: [javascript]
args: ["--ignore-path .gitignore /\"**/*.{js,jsx}\"", "--fix"]
pass_filenames: true
always_run: false
63 changes: 63 additions & 0 deletions docs/adr/0007-add-pre-commit-hooks-and-directions
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# NUMBER. ADD LINTING PRECOMMIT

- Status: proposed : 2023-05-23 accepted: 2023-05-31
- Deciders: Orbaco
- Date: 2023-05-31

Technical Story: [link to discussion issue](https://github.com/NASA-IMPACT/admg-casei/issues/522) <!-- optional -->

## Context and Problem Statement

[Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.]

## Decision Drivers <!-- optional -->

- Discussion from post-mortem in reference ticket.

## Considered Options

- Local development environment for CASEI can more closely resemble Github Actions runners by using dev containers.
- Configuring a threshold for Jest unit tests
- pre-commit hooks for linting procedures in CI
- Pin versions in package.json

## Decision Outcome

Chosen option: to add pre-commit hooks because it will not slow commit and development process during feature development and is ultimately optional.

### Positive Consequences <!-- optional -->

- Use a python environment and pre-commit hooks to run `eslint` and other commands before they fail in CI.
- No debugging of linting issues in CI
- Automate `eslint` so developers do not need to remember to run it manually.

### Negative Consequences <!-- optional -->

### Pre-requisites
- Python virtualenv (venv, pyenv virtualenv, etc)
- Install pre-commit package

### Setup
```
# activate your pyenv environment
example... `pyenv activate casei-nodeenv`

# install all requirements
pip install -r requirements.txt

# OR install pre-commit
pip install pre-commit

# install the local repository pre commits
pre-commit install

# test a change a git commit
git add -A && git commit -m "testing pre commits"

# optional: run on all files
pre-commit run --all-files
```

## Links <!-- optional -->

- [Pre-commit library](https://pre-commit.com/index.html#plugins)
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cfgv==3.3.1
distlib==0.3.6
filelock==3.12.2
identify==2.5.24
nodeenv==1.7.0
platformdirs==3.5.3
pre-commit==3.3.3
PyYAML==6.0
virtualenv==20.23.1