Skip to content

Commit 2602c8c

Browse files
style: add pre-commit for style (#101)
1 parent dac6404 commit 2602c8c

28 files changed

+577
-272
lines changed

.github/scripts/pack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ tar -czvf everest-tutorials-drogon-well_order.tar.gz ./data/drogon/well_ord
88
tar -czvf everest-tutorials-drogon-well_rate.tar.gz ./data/drogon/well_rate
99
tar -czvf everest-tutorials-drogon-well_selection.tar.gz ./data/drogon/well_selection
1010
tar -czvf everest-tutorials-drogon-well_swap.tar.gz ./data/drogon/well_swap
11-
tar -czvf everest-tutorials-drogon-well_trajectory.tar.gz ./data/drogon/well_trajectory
11+
tar -czvf everest-tutorials-drogon-well_trajectory.tar.gz ./data/drogon/well_trajectory

.github/workflows/commitlint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: commit lint
22

3-
on:
3+
on:
44
workflow_dispatch:
55
workflow_call:
66
push:
@@ -25,4 +25,4 @@ jobs:
2525
run: npm install @commitlint/{cli,config-conventional}
2626

2727
- name: run commitlint
28-
run: npx commitlint --from=$(git merge-base origin/main HEAD) --to=HEAD
28+
run: npx commitlint --from=$(git merge-base origin/main HEAD) --to=HEAD

.github/workflows/publish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
workflow_call:
66
push:
7-
branches:
7+
branches:
88
- main
99

1010
permissions:
@@ -19,16 +19,16 @@ concurrency:
1919
jobs:
2020
publish:
2121
runs-on: ubuntu-latest
22-
22+
2323
environment:
2424
name: github-pages
2525
url: ${{ steps.deployment.outputs.page_url }}
26-
26+
2727
steps:
2828
- name: checkout code
2929
uses: actions/checkout@v4
3030
with:
31-
fetch-depth: 0
31+
fetch-depth: 0
3232

3333
- name: install uv
3434
uses: astral-sh/setup-uv@v5
@@ -38,15 +38,15 @@ jobs:
3838

3939
- name: build docs
4040
run: uv run sphinx-build -M html ./docs/source ./docs/build/
41-
41+
4242
- name: setup pages
4343
uses: actions/configure-pages@v5
44-
44+
4545
- name: upload artifact
4646
uses: actions/upload-pages-artifact@v3
4747
with:
4848
path: './docs/build/html'
49-
49+
5050
- name: deploy to github pages
5151
id: deployment
52-
uses: actions/deploy-pages@v4
52+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
if: ${{ steps.release.outputs.release_created }}
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
run: .github/scripts/upload.sh ${{ steps.release.outputs.tag_name }}
40+
run: .github/scripts/upload.sh ${{ steps.release.outputs.tag_name }}

.github/workflows/style.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Style
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'version-**'
8+
pull_request:
9+
10+
jobs:
11+
check-style:
12+
timeout-minutes: 15
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ['3.12']
17+
18+
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v7
30+
with:
31+
enable-cache: true
32+
python-version: ${{ matrix.python-version }}
33+
34+
- name: Install with style dependencies
35+
run: |
36+
uv sync --extra style
37+
38+
- name: Run style check
39+
if: ${{ always() }}
40+
run: |
41+
SKIP=no-commit-to-branch uv run pre-commit run --all-files --show-diff-on-failure

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,4 @@ cython_debug/
179179
# PyPI configuration file
180180
.pypirc
181181

182-
.vscode
182+
.vscode

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
default_install_hook_types: [pre-commit]
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v6.0.0
5+
hooks:
6+
- id: no-commit-to-branch
7+
- id: check-json
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
exclude: ^(docs/|data/)
11+
- id: trailing-whitespace
12+
exclude: ^(docs/|data/)
13+
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.12.11
16+
hooks:
17+
- id: ruff-check
18+
args: [ --fix ]
19+
- id: ruff-format
20+
21+
- repo: https://github.com/astral-sh/uv-pre-commit
22+
rev: 0.8.14
23+
hooks:
24+
- id: uv-lock

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ wish to place an anonymous, confidential report we encourage to use the [Equinor
5454
Ethics
5555
helpline](https://secure.ethicspoint.eu/domain/media/en/gui/102166/index.html).
5656

57-
This helpline is hosted by a third party helpline provider.
57+
This helpline is hosted by a third party helpline provider.

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Contributors Guide
22

3-
Welcome to the **EVEREST™ Tutorials** repository!
4-
We appreciate your interest in contributing to this project.
3+
Welcome to the **EVEREST™ Tutorials** repository!
4+
We appreciate your interest in contributing to this project.
55

6-
We expect all contributors to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).
6+
We expect all contributors to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).
77
Be respectful and inclusive in all interactions.
88

99
Below are the guidelines to help you contribute effectively.
@@ -21,8 +21,8 @@ Below are the guidelines to help you contribute effectively.
2121

2222
## Introduction
2323

24-
The EVEREST Tutorials repository is focused on providing reproducible tutorials for EVEREST.
25-
This is a documentation-based repository with examples and configuration files that focus on practical usage.
24+
The EVEREST Tutorials repository is focused on providing reproducible tutorials for EVEREST.
25+
This is a documentation-based repository with examples and configuration files that focus on practical usage.
2626
Contributors are welcome to improve the tutorials, fix bugs, and suggest enhancements to the documentation.
2727

2828

@@ -68,7 +68,7 @@ We enforce this linting all commit and pull request messages using the [commitli
6868

6969
#### Commit Message Format
7070

71-
Each commit message consists of a `header`, a `body` and a `footer`.
71+
Each commit message consists of a `header`, a `body` and a `footer`.
7272
The header has a special format that includes a `type`, a `scope` and a `subject`:
7373

7474
```
@@ -83,7 +83,7 @@ The `header` and the `subject` are mandatory and the rest are optional.
8383
If there is a `body` you need to add a blank line between the header and the body.
8484
If there is `footer` you need to add a blank line between the body and the footer.
8585

86-
The footer can contain a `close` or `fixes` keyword to link to the issue and close it when the pull request is merged.
86+
The footer can contain a `close` or `fixes` keyword to link to the issue and close it when the pull request is merged.
8787
This behavior is described in [Linking a pull request to an issue using a keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword).
8888

8989
The accepted types follow the [Angular convention](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional#type-enum) and can be:
@@ -119,7 +119,7 @@ chore(main): release 0.4.1
119119

120120
### Pull Request Guidelines
121121

122-
The format of the pull request message is the same as the commit message.
122+
The format of the pull request message is the same as the commit message.
123123
Ensure your pull request is based on the latest main branch.
124124
Follow the repository's commit message format.
125125
Provide a clear description of the changes in the pull request.

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
# everest-tutorials
2-
EVEREST Tutorials
1+
[![Code Style](https://github.com/equinor/everest-tutorials/actions/workflows/style.yml/badge.svg)](https://github.com/equinor/everest-tutorials/actions/workflows/style.yml)
2+
3+
Everest tutorials
4+
5+
6+
7+
### Style requirements
8+
9+
There are a set of style requirements, which are gathered in the `pre-commit`
10+
configuration, to have it automatically run on each commit do:
11+
12+
```sh
13+
pip install pre-commit
14+
pre-commit install
15+
```
16+
17+
or before each commit do:
18+
19+
```sh
20+
pre-commit run --all-files
21+
```
22+
23+
24+
There is also a pre-push hook configured in `pre-commit` to run a collection of
25+
relatively fast tests, to install this hook:
26+
27+
```sh
28+
pre-commit install --hook-type pre-push
29+
```

0 commit comments

Comments
 (0)