-
Notifications
You must be signed in to change notification settings - Fork 7
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
Pre commit #17
Merged
Merged
Pre commit #17
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
17e13d0
Add pre-commit to environment
mnlevy1981 d9c2929
Fix arguments passed to black
mnlevy1981 c699e60
Update pre-commit instruction in README
mnlevy1981 eb45313
Remove large file pre-commit check
mnlevy1981 63dc247
Found workaround that allows us to keep py3.8
mnlevy1981 03eb094
Add pytest functionality
mnlevy1981 82d9706
Add continuous integration to github actions
mnlevy1981 6f0d76c
Clean up ci.yaml
mnlevy1981 9375f42
One more typo from ci.yaml
mnlevy1981 848bc5c
Different method for activating conda environment
mnlevy1981 6644ed5
Yet another typo in ci.yaml
mnlevy1981 25bb3dc
Adding some debug statements to a yaml file
mnlevy1981 f645ba5
Missing action/checkout@v2 was culprit?
mnlevy1981 3986c86
actions/checkout, not action/checkout
mnlevy1981 dff841c
Update README.md
mnlevy1981 fcd0747
Updates at Anderson's suggestion
mnlevy1981 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Continuous Integration | ||
on: | ||
push: | ||
branches: | ||
- "*" | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
build: | ||
name: Test on ubuntu | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install conda | ||
uses: goanpeca/setup-miniconda@v1 | ||
with: | ||
auto-update-conda: true | ||
activate-environment: hires-marbl | ||
environment-file: environments/environment.yaml | ||
auto-activate-base: false | ||
|
||
- name: Show conda environment | ||
shell: bash -l {0} | ||
run: conda list | ||
|
||
- name: Run Tests | ||
shell: bash -l {0} | ||
run: pytest -v tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: pre-commit | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
pull_request: | ||
branches: master | ||
|
||
jobs: | ||
pre-commit: | ||
name: pre-commit | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
- name: set up python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: Run pre-commit | ||
uses: pre-commit/action@v2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
|
||
- repo: https://github.com/ambv/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black | ||
args: [] | ||
|
||
- repo: https://github.com/deathbeds/prenotebook | ||
rev: f5bdb72a400f1a56fe88109936c83aa12cc349fa | ||
hooks: | ||
- id: prenotebook | ||
args: | ||
[ | ||
'--keep-output', | ||
'--keep-metadata', | ||
'--keep-execution-count', | ||
'--keep-empty', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# HiRes-CESM-analysis | ||
|
||
This repository is building a set of tools for analyzing BGC output in a high-resolution POP run. | ||
|
||
## For Developers | ||
|
||
A few recommended practices to incorporate in your development sandbox: | ||
|
||
### Keep your conda environment up to date | ||
|
||
The first time you check out this repository, run | ||
|
||
``` | ||
$ conda env install -f environments/environment.yaml | ||
``` | ||
|
||
If you notice the YAML file has changed after you fetch changes from github, | ||
update the environment with | ||
|
||
``` | ||
$ conda env update -f environments/environment.yaml | ||
``` | ||
|
||
### Use `pre-commit` to test code before commiting | ||
|
||
Please take advantage of the pre-commit package to ensure that `black` is run before commiting: | ||
|
||
``` | ||
$ pre-commit install --install-hooks # set up pre-commit | ||
$ pre-commit run -a # check all the files currently in the repo | ||
``` | ||
|
||
The pre-commit package is already installed via the `hires-marbl` conda environment. | ||
There is a github action to run `black` on all pull requests, | ||
but running it locally via-pre-commit will reduce the number of failed actions. | ||
NOTE: for some reason, to properly install `pre-commit` on the CISL systems, | ||
the above command must be run from `casper` rather than `cheyenne`. | ||
|
||
Note that pre-commit creates a virtual environment using specific tags of each package. | ||
To ensure pre-commit is testing with the latest releases, it is necessary to run | ||
|
||
``` | ||
$ pre-commit autoupdate | ||
$ pre-commit install --install-hooks # set up pre-commit | ||
``` | ||
|
||
from time to time. | ||
|
||
### Run `pytest` after modifying python in `utils/` | ||
|
||
To test some of the python code in `notebooks/utils/`, run `pytest`. | ||
These tests can be run from the top level of this repository by running | ||
|
||
``` | ||
$ pytest tests/ | ||
``` | ||
|
||
If you add new code to this directory, | ||
consider writing small tests to ensure it is running as expected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add the following pre-commit hook for formatting notebooks as well: