Skip to content

Commit f3cd5c8

Browse files
feat: set up Syncweaver (#9)
* feat: initialize syncweaver * ci: test syncweaver update-source workflow * chore: rename * ci: update name * fix: urls for repos * ci: resolve source path from repo url
1 parent 90469f5 commit f3cd5c8

2 files changed

Lines changed: 45 additions & 9 deletions

File tree

‎.github/workflows/syncweaver-update-source.yml‎

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
name: update-source
1+
name: syncweaver-update-source
22

33
on:
44
repository_dispatch:
55
workflow_dispatch:
66
inputs:
77
source_path:
88
description: Tracked source path in the host repository.
9-
required: true
9+
required: false
10+
type: string
11+
repo_url:
12+
description: Optional source repository URL used to resolve source_path from lockfile.
13+
required: false
1014
type: string
1115
lockfile:
1216
description: Path to the syncweaver lockfile.
@@ -35,6 +39,7 @@ jobs:
3539
remote_subdir: ${{ steps.update_source.outputs.remote_subdir }}
3640
env:
3741
SOURCE_PATH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.source_path || github.event.client_payload.source_path || '' }}
42+
REPO_URL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.repo_url || github.event.client_payload.repo_url || github.event.client_payload.source_repository || '' }}
3843
LOCKFILE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.lockfile || github.event.client_payload.lockfile || '.syncweaver-lock.json' }}
3944
REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.event.client_payload.ref || '' }}
4045
REMOTE_SUBDIR: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.remote_subdir || github.event.client_payload.remote_subdir || '' }}
@@ -62,11 +67,41 @@ jobs:
6267
python -m pip install --upgrade pip
6368
python -m pip install "git+https://github.com/CCBR/syncweaver.git@main"
6469
70+
- name: Resolve source path
71+
id: resolve_source_path
72+
shell: python
73+
env:
74+
SOURCE_PATH_INPUT: ${{ env.SOURCE_PATH }}
75+
REPO_URL_INPUT: ${{ env.REPO_URL }}
76+
LOCKFILE_PATH: ${{ env.LOCKFILE }}
77+
run: |
78+
import os
79+
import pathlib
80+
81+
from syncweaver.lockfile import resolve_source_path_from_lockfile
82+
83+
source_path_input = os.environ["SOURCE_PATH_INPUT"].strip()
84+
repo_url_input = os.environ["REPO_URL_INPUT"].strip()
85+
lockfile_path = pathlib.Path(os.environ["LOCKFILE_PATH"])
86+
output_path = pathlib.Path(os.environ["GITHUB_OUTPUT"])
87+
88+
try:
89+
resolved_source_path = resolve_source_path_from_lockfile(
90+
lockfile=lockfile_path,
91+
source_path=source_path_input,
92+
repo_url=repo_url_input,
93+
)
94+
except ValueError as exc:
95+
raise SystemExit(f"Error: {exc}") from exc
96+
97+
with output_path.open("a", encoding="utf-8") as fh:
98+
fh.write(f"source_path={resolved_source_path}\n")
99+
65100
- name: Run update-source composite action
66101
id: update_source
67102
uses: CCBR/syncweaver/actions/update-source@latest
68103
with:
69-
source_path: ${{ env.SOURCE_PATH }}
104+
source_path: ${{ steps.resolve_source_path.outputs.source_path }}
70105
lockfile: ${{ env.LOCKFILE }}
71106
ref: ${{ env.REF }}
72107
remote_subdir: ${{ env.REMOTE_SUBDIR }}
@@ -75,15 +110,16 @@ jobs:
75110
uses: peter-evans/create-pull-request@v7
76111
with:
77112
token: ${{ steps.ccbr_bot.outputs.token }}
78-
branch: syncweaver/update-source/${{ env.SOURCE_PATH }}
113+
branch: syncweaver/update-source/${{ steps.resolve_source_path.outputs.source_path }}
79114
delete-branch: true
80-
commit-message: "chore(syncweaver): update ${{ env.SOURCE_PATH}} from ${{ steps.update_source.outputs.source_repo }}@${{ steps.update_source.outputs.ref }}"
81-
title: "chore(syncweaver): update ${{ env.SOURCE_PATH}} from ${{ steps.update_source.outputs.source_repo }}@${{ steps.update_source.outputs.ref }}"
115+
commit-message: "chore(syncweaver): update ${{ steps.resolve_source_path.outputs.source_path }} from ${{ steps.update_source.outputs.source_repo }}@${{ steps.update_source.outputs.ref }}"
116+
title: "chore(syncweaver): update ${{ steps.resolve_source_path.outputs.source_path }} from ${{ steps.update_source.outputs.source_repo }}@${{ steps.update_source.outputs.ref }}"
82117
body: |
83118
Automated source update from the update-source workflow.
84119
85120
Inputs used:
86-
- source_path: ${{ env.SOURCE_PATH }}
121+
- source_path: ${{ steps.resolve_source_path.outputs.source_path }}
122+
- repo_url: ${{ env.REPO_URL }}
87123
- lockfile: ${{ env.LOCKFILE }}
88124
- ref: ${{ env.REF }}
89125
- remote_subdir: ${{ env.REMOTE_SUBDIR }}

‎.syncweaver-lock.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "NIDAP-Community/CodeOcean-MOSuite-create",
3-
"homePage": "https://github.com/NIDAP-Community/CodeOcean-MOSuite-create",
2+
"name": "NIDAP-Community/MOSuite-create",
3+
"homePage": "https://github.com/NIDAP-Community/MOSuite-create",
44
"sources": {
55
"code/MOSuite": {
66
"repo_url": "https://github.com/CCBR/MOSuite",

0 commit comments

Comments
 (0)