Skip to content

Commit 159eb6d

Browse files
committed
Automated process to sync with upstream repository
1 parent aeb7cf5 commit 159eb6d

6 files changed

Lines changed: 622 additions & 14 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Sync Upstream
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: 'Upstream ref (branch/tag or pull/<num>/head)'
8+
required: false
9+
default: ''
10+
clean:
11+
description: 'Remove files deleted upstream'
12+
required: false
13+
default: 'false'
14+
# schedule:
15+
# - cron: '17 5 * * *'
16+
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
21+
jobs:
22+
sync:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.11'
34+
35+
- name: Run upstream sync
36+
env:
37+
SYNC_REF: ${{ github.event.inputs.ref }}
38+
run: |
39+
if [ "${{ github.event.inputs.clean }}" = "true" ]; then CLEAN_ARG="--clean"; else CLEAN_ARG=""; fi
40+
python scripts/sync_upstream.py $CLEAN_ARG
41+
42+
- name: Create Pull Request
43+
uses: peter-evans/create-pull-request@v6
44+
with:
45+
commit-message: |
46+
chore(sync): apply upstream changes with pyballistic transforms
47+
title: 'Sync from upstream with transformations'
48+
body: |
49+
This PR was created automatically by the Sync Upstream workflow.
50+
51+
- Pulls latest from upstream and applies configured transformations
52+
- Preserves files listed in `sync_config.json` under `exclude_paths`
53+
- See script at `scripts/sync_upstream.py` for details
54+
55+
If there are unexpected changes, adjust `sync_config.json` or update the script.
56+
branch: ci/sync-upstream
57+
delete-branch: true
58+
signoff: true
59+
add-paths: |
60+
**/*

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
.vscode
1010
.coverage
1111
htmlcov
12-
debug
13-
/site/
12+
**/debug
13+
**/site
1414
.env
1515
.testall
1616
compile_flags.txt
1717
# Mirror of Cython sources for coverage lookup:
1818
/pyballistic_exts/*
19+
/.sync_upstream/
20+
/.sync_diff/

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,16 @@ The calculation results MUST NOT be considered as completely and reliably reflec
140140

141141
THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
142142
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
143+
144+
## Keeping in sync with upstream
145+
146+
This repository tracks the upstream project [`py-ballisticcalc`](https://github.com/o-murphy/py-ballisticcalc) while preserving a few local differences (package name, URLs, and select docs like this README).
147+
148+
- Sync locally:
149+
- `python scripts/sync_upstream.py` to sync latest `master` from upstream.
150+
- `python scripts/sync_upstream.py --ref pull/219/head` to sync a specific PR.
151+
- Add `--clean` to remove files deleted upstream (excluded paths remain).
152+
- Automation:
153+
- GitHub Action `Sync Upstream` runs on-demand, opening a PR with changes. It can also be scheduled to run regularly (uncomment the `schedule` block).
154+
- Configuration:
155+
- See `sync_config.json` for upstream repo/branch, text/path replacements, and excluded files. Adjust `exclude_paths` if you want additional files to remain customized here.

0 commit comments

Comments
 (0)