Skip to content

Commit

Permalink
(Feat) add pre-commit on github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lbesnard committed Jun 4, 2024
1 parent 79e3a13 commit fd700f7
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ jobs:
- name: Verify build
run: |
pip install dist/*.whl
36 changes: 36 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pre-commit

on: [push, pull_request]

jobs:
pre-commit:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10.14'

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit
run: |
pre-commit run --all-files || { echo "Pre-commit checks failed"; exit 0; }
- name: Install GitHub CLI
run: |
sudo apt-get install gh
- name: Commit changes
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add .
git diff --cached --quiet || { git commit -m "Apply pre-commit fixes" && gh auth login --with-token <<< $GITHUB_TOKEN && gh repo view --json url --json name | grep url | cut -d':' -f2 | tr -d '"},'; git push; }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: check-json
exclude : aodn_cloud_optimised/config/dataset/dataset_template.json
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ See [documentation](README_add_new_dataset.md) to learn how to add a new dataset
# Notebooks

Notebooks exist under
https://github.com/aodn/architecturereview/blob/main/cloud-optimised/cloud-optimised-team/parquet/notebooks/
https://github.com/aodn/aodn_cloud_optimised/blob/main/notebooks/

For each new dataset, it is a good practice to use the provided template ```cloud-optimised/cloud-optimised-team/parquet/notebooks/template.ipynb```
For each new dataset, it is a good practice to use the provided template ```notebooks/template.ipynb```
and create a new notebook.

These notebooks use a common library of python functions to help with creating the geo-spatial filters:
```cloud-optimised/cloud-optimised-team/parquet/notebooks/parquet_queries.py```
```notebooks/parquet_queries.py```
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ srs_l3s_1d_dn_to_zarr = "aodn_cloud_optimised.bin.srs_l3s_1d_dn_to_zarr:main"
pytest = "^8.2.1"
coverage = "^7.5.3"

[tool.pre_commit]
version = "2.3.0"
config = ".pre-commit-config.yaml"

0 comments on commit fd700f7

Please sign in to comment.