Skip to content

Commit 627b742

Browse files
add workflow, small fixes in conventions guide
1 parent 242f1f3 commit 627b742

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

.github/workflows/pull-request.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: GitHub CI
2+
3+
# Execute this for every pull request (opened, reopened, and synchronized)
4+
on: [pull_request]
5+
6+
jobs:
7+
pre-commit-checks:
8+
name: 'Core / Pre-Commit Checks'
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
-
13+
name: Checkout Repo
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.pull_request.head.sha }}
17+
-
18+
name: Checkout target commit
19+
run: git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.ref }}
20+
-
21+
name: Set up Python 3.11
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.11'
25+
-
26+
# Store the current date to use it as cache key
27+
name: Get current date
28+
id: date
29+
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
30+
-
31+
name: Cache dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
~/.cache/pip
36+
~/.cache/pre-commit
37+
key: ${{ github.event.pull_request.head.ref }}-${{ steps.date.outputs.date }}
38+
restore-keys: |
39+
${{ github.event.pull_request.head.ref }}
40+
${{ github.event.pull_request.base.ref }}
41+
develop
42+
main
43+
-
44+
name: Install pre-commit and hooks
45+
run: |
46+
pip install pre-commit
47+
pre-commit install --install-hooks
48+
-
49+
name: Run pre-commit checks
50+
run: pre-commit run --show-diff-on-failure --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}

doc/guide/Guide_CLIMADA_conventions.ipynb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,16 @@
210210
"\n",
211211
" ```shell\n",
212212
" git fetch -t\n",
213+
" git checkout develop-white\n",
214+
" git checkout develop-black\n",
213215
" ```\n",
214216
" \n",
215217
"2. Switch to your feature branch and merge `develop-white` (in order to get the latest changes in `develop` before switching to `black`):\n",
216218
"\n",
217219
" ```shell\n",
218220
" git checkout YOUR_BRANCH\n",
219221
" git pull\n",
222+
" pre-commit uninstall || pip install pre-commit\n",
220223
" git merge --no-ff develop-white\n",
221224
" ```\n",
222225
" If merge conflicts arise, resolve them and conclude the merge as instructed by Git.\n",
@@ -241,13 +244,13 @@
241244
" ```shell\n",
242245
" git merge --no-ff develop-black\n",
243246
" ```\n",
244-
" * If merge conflicts arise, resolve them and conclude the merge as instructed by Git.\n",
245-
" Most conflicts will probably be resolved by choosing \"Ours\" over \"Theirs\" or the \"Current Change\" over the \"Incoming Change\".\n",
246-
" Still, be careful!\n",
247-
" * Once all conflicts are resolved, check if the tests pass.\n",
248-
" If so, the formatting was successful.\n",
249-
" If you cannot import Climada, one of the merges inflicted erroneous syntax.\n",
250-
" You will have to fix this manually before you commit the merge.\n",
247+
" Resolve all conflicts by choosing \"Ours\" over \"Theirs\" (\"Current Change\" over the \"Incoming Change\").\n",
248+
" \n",
249+
" ```shell\n",
250+
" git checkout --ours .\n",
251+
" git add -u\n",
252+
" git commit\n",
253+
" ```\n",
251254
" \n",
252255
"6. Now, get up to date with the latest `develop` branch:\n",
253256
"\n",
@@ -258,6 +261,9 @@
258261
" git merge --no-ff develop\n",
259262
" ```\n",
260263
" Again, fix merge conflicts if they arise and check if the tests pass.\n",
264+
" Accept the incoming changes for the tutorials 1_main, Exposures, LitPop Impact, Forecast and TropicalCyclone unless you made changes to those.\n",
265+
" Again, the file with the most likely merging conflicts is CHANGELOG.md, which should probably be resolved by accepting both changes.\n",
266+
" \n",
261267
" \n",
262268
"7. Finally, push your latest changes:\n",
263269
"\n",

0 commit comments

Comments
 (0)