Skip to content

Commit 9ac5a98

Browse files
authored
Merge branch 'develop' into pre-commit-ci-update-config
2 parents 48daf51 + 5ba7d2b commit 9ac5a98

31 files changed

+3344
-1904
lines changed
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Update Changelog
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
update-changelog:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Ruby
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: "3.3"
20+
bundler-cache: true
21+
22+
- name: Install github_changelog_generator
23+
run: |
24+
gem install github_changelog_generator
25+
26+
- name: Generate changelog
27+
env:
28+
CHANGELOG_GITHUB_TOKEN: ${{ secrets.CHANGELOG_GITHUB_TOKEN }}
29+
run: |
30+
github_changelog_generator -u WMD-group -p SMACT --token $CHANGELOG_GITHUB_TOKEN --output docs/CHANGELOG.md --exclude-labels dependencies
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.10"
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
41+
- name: Run filter script
42+
run: |
43+
python dev_scripts/filter_changelog.py docs/CHANGELOG.md
44+
45+
- name: Run pre-commit hooks
46+
uses: pre-commit/action@v3.0.1
47+
with:
48+
extra_args: --files docs/CHANGELOG.md
49+
50+
- name: Commit and push changes
51+
run: |
52+
git config --global user.name 'github-actions[bot]'
53+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
54+
git add docs/CHANGELOG.md
55+
git commit -m "Update changelog for new release"
56+
git push
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,8 @@ $RECYCLE.BIN/
224224

225225
*.swp
226226

227-
*.bak
227+
*.bak
228+
229+
# Ignore any files generated by the tutorial notebooks
230+
docs/tutorials/data/*
231+
docs/tutorials/*.txt

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
skip: [pyright]
4+
autofix_commit_msg: pre-commit auto-fixes
5+
autoupdate_commit_msg: pre-commit autoupdate
16
repos:
27
- repo: https://github.com/astral-sh/ruff-pre-commit
38
rev: v0.9.9

CONTRIBUTING.md

+77-10
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,72 @@ branches for new work and pull requests for verifying the work.
1010
The steps for a new piece of work can be summarised as follows:
1111

1212
1. Push up or create [an issue](https://github.com/WMD-group/SMACT/issues).
13-
2. Create a branch from main, with a sensible name that relates to the issue.
14-
3. Do the work and commit changes to the branch. Push the branch
13+
2. Fork the repository, i.e. go to the [`SMACT` repository on GitHub](https://github.com/WMD-group/SMACT) and click the "Fork" button to create a copy of the repository under your own account.
14+
3. Clone your fork of the repository to your local machine.
15+
16+
```bash
17+
git clone https://github.com/<your-username>/SMACT.git
18+
cd SMACT
19+
```
20+
21+
4. Install the [uv package manager](https://github.com/astral-sh/uv).
22+
23+
```bash
24+
pip install uv # installs uv package manager
25+
```
26+
27+
5. Create a virtual environment for SMACT.
28+
29+
Using `uv`:
30+
31+
```bash
32+
uv create venv # A virtual environment will be created in the current directory
33+
source .venv/bin/activate # Activate the virtual environment
34+
```
35+
36+
N.B. A virtual environment can also be created using [mamba](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html) for those more familiar with mamba/conda.
37+
38+
6. Install the package in editable mode with the development, documentation and optional dependencies.
39+
40+
```bash
41+
uv pip install -e ".[dev,docs,optional]"
42+
pre-commit install # Install pre-commit hooks
43+
```
44+
45+
7. Create a branch from master, with a sensible name that relates to the issue.
46+
47+
```bash
48+
git checkout -b <branch-name> # should be run from the master branch
49+
```
50+
51+
8. Do the work and commit changes to the branch. Push the branch
1552
regularly to GitHub to make sure no work is accidentally lost.
16-
4. Write or update unit tests for the code you work on.
17-
5. When you are finished with the work, ensure that all of the unit
18-
tests pass on your own machine.
19-
6. Open a pull request [on the pull request page](https://github.com/WMD-group/SMACT/pulls).
20-
7. If nobody acknowledges your pull request promptly, feel free to poke one of the main developers into action.
53+
54+
```bash
55+
git add <files>
56+
git commit -m "A message describing the changes"
57+
git push origin <branch-name>
58+
```
59+
60+
9. Write or update unit tests for the code you work on.
61+
10. When you are finished with the work, ensure that all of the unit tests pass on your own machine by running `pytest -v` in the root directory of the repository.
62+
63+
11. Open a pull request [on the pull request page](https://github.com/WMD-group/SMACT/pulls).
64+
12. If nobody acknowledges your pull request promptly, feel free to poke one of the main developers into action.
65+
13. For keeping your repository up to date with the master repository, you can add it as a remote to your local repository.
66+
67+
```bash
68+
git remote add upstream https://github.com/WMD-group/SMACT.git
69+
```
70+
71+
Fetch the latest changes from the master branch to keep it up to date (make sure you are on the master branch ).
72+
73+
```bash
74+
git checkout master
75+
git pull upstream master
76+
```
77+
78+
Reminder, `pull` is a combination of `fetch` and `merge`. This could lead to merge conflicts if you have made changes to the master branch.
2179

2280
## Pull requests
2381

@@ -32,14 +90,14 @@ Recommended reading: [How to Write the Perfect Pull Request](https://github.blog
3290

3391
## Dev requirements
3492

35-
When developing locally, it is recommended to install the python packages in `requirements-dev.txt`.
93+
When developing locally, it is recommended to install the python packages for development and documentation.
3694

3795
```bash
38-
pip install -e ".[dev,docs]"
96+
pip install -e ".[dev,docs]" # Should be ran from the root of the repository
3997
```
4098

4199
This will allow you to run the tests locally with pytest as described in the main README,
42-
as well as run pre-commit hooks to automatically format python files with isort and black.
100+
as well as run pre-commit hooks to automatically format python files with [ruff](https://docs.astral.sh/ruff/).
43101
To install the pre-commit hooks (only needs to be done once):
44102

45103
```bash
@@ -48,3 +106,12 @@ pre-commit run --all-files # optionally run hooks on all files
48106
```
49107

50108
Pre-commit hooks will check all files when you commit changes, automatically fixing any files which are not formatted correctly. Those files will need to be staged again before re-attempting the commit.
109+
110+
To render the documentation locally, you can use the following command:
111+
112+
```bash
113+
cd docs
114+
sphinx-build -nW --keep-going -b html . _build/html/
115+
```
116+
117+
You should then be able to view the documentation by opening `_build/html/index.html` in a web browser. You should inspect the documentation to ensure that it is correctly formatted, any docstrings are present and that the code examples are correct.

dev_scripts/filter_changelog.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Remove GitHub Actions bot entries from changelog."""
2+
3+
from __future__ import annotations
4+
5+
import argparse
6+
import re
7+
8+
9+
def remove_github_actions_entries(changelog_path: str) -> None:
10+
"""Remove GitHub Actions bot entries from the changelog.
11+
12+
Args:
13+
changelog_path: Path to the changelog file.
14+
"""
15+
with open(changelog_path) as file:
16+
lines = file.readlines()
17+
18+
with open(changelog_path, "w") as file:
19+
skip = False
20+
for line in lines:
21+
if re.search(r"\[github-actions\[bot\]\]", line):
22+
skip = True
23+
elif skip and line.strip() == "":
24+
skip = False
25+
elif not skip:
26+
file.write(line)
27+
28+
29+
if __name__ == "__main__":
30+
parser = argparse.ArgumentParser(description="Remove GitHub Actions bot entries from changelog.")
31+
parser.add_argument("changelog_path", type=str, help="Path to the changelog file")
32+
args = parser.parse_args()
33+
34+
remove_github_actions_entries(args.changelog_path)

0 commit comments

Comments
 (0)