diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 000000000..b95037993 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,50 @@ +name: GitHub CI + +# Execute this for every pull request (opened, reopened, and synchronized) +on: [pull_request] + +jobs: + pre-commit-checks: + name: 'Core / Pre-Commit Checks' + runs-on: ubuntu-latest + + steps: + - + name: Checkout Repo + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - + name: Checkout target commit + run: git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.ref }} + - + name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - + # Store the current date to use it as cache key + name: Get current date + id: date + run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" + - + name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cache/pip + ~/.cache/pre-commit + key: ${{ github.event.pull_request.head.ref }}-${{ steps.date.outputs.date }} + restore-keys: | + ${{ github.event.pull_request.head.ref }} + ${{ github.event.pull_request.base.ref }} + develop + main + - + name: Install pre-commit and hooks + run: | + pip install pre-commit + pre-commit install --install-hooks + - + name: Run pre-commit checks + run: pre-commit run --show-diff-on-failure --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} diff --git a/doc/guide/Guide_CLIMADA_conventions.ipynb b/doc/guide/Guide_CLIMADA_conventions.ipynb index 71bbe8078..6b4e4c290 100644 --- a/doc/guide/Guide_CLIMADA_conventions.ipynb +++ b/doc/guide/Guide_CLIMADA_conventions.ipynb @@ -210,6 +210,8 @@ "\n", " ```shell\n", " git fetch -t\n", + " git checkout develop-white\n", + " git checkout develop-black\n", " ```\n", " \n", "2. Switch to your feature branch and merge `develop-white` (in order to get the latest changes in `develop` before switching to `black`):\n", @@ -217,6 +219,7 @@ " ```shell\n", " git checkout YOUR_BRANCH\n", " git pull\n", + " pre-commit uninstall || pip install pre-commit\n", " git merge --no-ff develop-white\n", " ```\n", " If merge conflicts arise, resolve them and conclude the merge as instructed by Git.\n", @@ -241,13 +244,13 @@ " ```shell\n", " git merge --no-ff develop-black\n", " ```\n", - " * If merge conflicts arise, resolve them and conclude the merge as instructed by Git.\n", - " Most conflicts will probably be resolved by choosing \"Ours\" over \"Theirs\" or the \"Current Change\" over the \"Incoming Change\".\n", - " Still, be careful!\n", - " * Once all conflicts are resolved, check if the tests pass.\n", - " If so, the formatting was successful.\n", - " If you cannot import Climada, one of the merges inflicted erroneous syntax.\n", - " You will have to fix this manually before you commit the merge.\n", + " Resolve all conflicts by choosing \"Ours\" over \"Theirs\" (\"Current Change\" over the \"Incoming Change\").\n", + " \n", + " ```shell\n", + " git checkout --ours .\n", + " git add -u\n", + " git commit\n", + " ```\n", " \n", "6. Now, get up to date with the latest `develop` branch:\n", "\n", @@ -258,6 +261,9 @@ " git merge --no-ff develop\n", " ```\n", " Again, fix merge conflicts if they arise and check if the tests pass.\n", + " Accept the incoming changes for the tutorials 1_main, Exposures, LitPop Impact, Forecast and TropicalCyclone unless you made changes to those.\n", + " Again, the file with the most likely merging conflicts is CHANGELOG.md, which should probably be resolved by accepting both changes.\n", + " \n", " \n", "7. Finally, push your latest changes:\n", "\n",