Skip to content

Commit 3b9f8b1

Browse files
feat: install MOSuite v0.3.2 via syncweaver (#3)
* refactor: load local MOSuite * Squashed 'code/MOSuite/' content from commit c09ee39 git-subtree-dir: code/MOSuite git-subtree-split: c09ee39f9b282237f13d88dcf4cdfed965209c68 * feat: initialize syncweaver w/ mosuite v0.3.2 * chore: use mosuite-minimal v0.3.2 * chore: remove dupe * test: fix main path * chore: use mosuite-minimal v0.3.2
1 parent 2c8eb8b commit 3b9f8b1

316 files changed

Lines changed: 50761 additions & 156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.codeocean/environment.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"version": 1,
3-
"base_image": "codeocean/mosuite:v0.3.0",
4-
"post_install": true,
3+
"base_image": "codeocean/mosuite-minimal:v0.3.2",
54
"options": {
65
"registry_host_arg": true,
76
"git_ask_pass": true,

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/code/MOSuite linguist-vendored

‎.github/WORDLIST.txt‎

Whitespace-only changes.

‎.github/workflows/auto-format.yml‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,45 @@ name: auto-format
33
on:
44
workflow_dispatch:
55
pull_request:
6+
branches: [dev, main]
67

7-
env:
8-
GH_TOKEN: ${{ github.token }}
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
911

1012
permissions:
1113
contents: write
1214
pull-requests: write
1315

14-
concurrency:
15-
group: ${{ github.workflow }}-${{ github.ref }}
16-
cancel-in-progress: true
17-
1816
jobs:
1917
auto-format:
2018
runs-on: ubuntu-latest
2119

2220
steps:
23-
- uses: actions/checkout@v4
24-
if: github.event_name == 'pull_request'
21+
- name: Generate a token
22+
id: generate-token
23+
uses: actions/create-github-app-token@v2
2524
with:
26-
fetch-depth: 0
27-
ref: ${{ github.head_ref }}
28-
- uses: actions/checkout@v4
29-
if: github.event_name != 'pull_request'
25+
app-id: ${{ vars.CCBR_BOT_APP_ID }}
26+
private-key: ${{ secrets.CCBR_BOT_PRIVATE_KEY }}
27+
owner: ${{ github.repository_owner }}
28+
29+
- uses: actions/checkout@v7
3030
with:
31-
fetch-depth: 0
32-
ref: ${{ github.ref_name }}
31+
token: ${{ steps.generate-token.outputs.token }}
32+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
3333

3434
- name: git config
3535
run: |
36-
git config --global user.name "github-actions[bot]"
37-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
38-
39-
- name: Format R code with air
40-
uses: rstudio/shiny-workflows/format-r-code@v1
36+
git config --global user.name "CCBR-bot"
37+
git config --global user.email "258092125+ccbr-bot@users.noreply.github.com"
4138
39+
- name: format
40+
uses: pre-commit/action@v3.0.1
41+
continue-on-error: true
4242
- name: commit & push
43+
if: ${{ github.event_name == 'pull_request' }}
4344
run: |
4445
git add .
45-
git commit -m "ci: 🤖 auto-format" || echo "nothing to commit"
46+
git commit -m "ci: 🤖 auto-format with pre-commit" || echo "nothing to commit"
4647
git push || echo "nothing to push"
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: syncweaver-contribute-patch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
source_path:
7+
description: Optional tracked source path override; if omitted, source_path is resolved from lockfile.
8+
required: false
9+
type: string
10+
repo_url:
11+
description: Optional source repository identifier (URL or OWNER/REPO) used to resolve source_path from lockfile.
12+
required: false
13+
type: string
14+
source_repository:
15+
description: Optional source repository in OWNER/REPO format; if omitted, derives from lockfile repo_url.
16+
required: false
17+
type: string
18+
lockfile:
19+
description: Path to the syncweaver lockfile.
20+
required: false
21+
default: .syncweaver-lock.json
22+
type: string
23+
patch_path:
24+
description: Optional patch path override; if omitted, uses source entry patch value from lockfile.
25+
required: false
26+
type: string
27+
source_base_ref:
28+
description: Optional source repository base branch for PR; if omitted, uses source entry ref from lockfile.
29+
required: false
30+
type: string
31+
32+
permissions:
33+
contents: read
34+
35+
jobs:
36+
resolve-patch-metadata:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
source_path: ${{ steps.resolve.outputs.source_path }}
40+
repo_url: ${{ steps.resolve.outputs.repo_url }}
41+
source_repository: ${{ steps.resolve.outputs.source_repository }}
42+
patch_path: ${{ steps.resolve.outputs.patch_path }}
43+
source_base_ref: ${{ steps.resolve.outputs.source_base_ref }}
44+
lockfile: ${{ env.LOCKFILE }}
45+
env:
46+
SOURCE_PATH: ${{ github.event.inputs.source_path || '' }}
47+
REPO_URL: ${{ github.event.inputs.repo_url || '' }}
48+
SOURCE_REPOSITORY: ${{ github.event.inputs.source_repository || '' }}
49+
LOCKFILE: ${{ github.event.inputs.lockfile || '.syncweaver-lock.json' }}
50+
PATCH_PATH: ${{ github.event.inputs.patch_path || '' }}
51+
SOURCE_BASE_REF: ${{ github.event.inputs.source_base_ref || '' }}
52+
steps:
53+
- name: Checkout host repository
54+
uses: actions/checkout@v6
55+
56+
- name: Resolve source and patch metadata
57+
id: resolve
58+
shell: bash
59+
env:
60+
SOURCE_PATH_INPUT: ${{ env.SOURCE_PATH }}
61+
REPO_URL_INPUT: ${{ env.REPO_URL }}
62+
SOURCE_REPOSITORY_INPUT: ${{ env.SOURCE_REPOSITORY }}
63+
LOCKFILE_PATH: ${{ env.LOCKFILE }}
64+
PATCH_PATH_INPUT: ${{ env.PATCH_PATH }}
65+
SOURCE_BASE_REF_INPUT: ${{ env.SOURCE_BASE_REF }}
66+
SYNCWEAVER_HOST_CWD: ${{ github.workspace }}
67+
run: |
68+
set -euo pipefail
69+
container_output=".syncweaver-contribute-output"
70+
rm -f "${container_output}"
71+
docker run --rm \
72+
--user "$(id -u):$(id -g)" \
73+
-e SOURCE_PATH_INPUT \
74+
-e REPO_URL_INPUT \
75+
-e SOURCE_REPOSITORY_INPUT \
76+
-e LOCKFILE_PATH \
77+
-e PATCH_PATH_INPUT \
78+
-e SOURCE_BASE_REF_INPUT \
79+
-e SYNCWEAVER_HOST_CWD \
80+
-e GITHUB_OUTPUT="/workspace/${container_output}" \
81+
-v "${PWD}:/workspace" \
82+
-w /workspace \
83+
nciccbr/syncweaver:latest \
84+
python -m syncweaver.contribute_patch
85+
cat "${container_output}" >> "$GITHUB_OUTPUT"
86+
87+
- name: Print resolved metadata
88+
shell: bash
89+
run: |
90+
set -euo pipefail
91+
echo "source_path=${{ steps.resolve.outputs.source_path }}"
92+
echo "repo_url=${{ steps.resolve.outputs.repo_url }}"
93+
echo "source_repository=${{ steps.resolve.outputs.source_repository }}"
94+
echo "patch_path=${{ steps.resolve.outputs.patch_path }}"
95+
echo "source_base_ref=${{ steps.resolve.outputs.source_base_ref }}"
96+
97+
contribute-patch:
98+
runs-on: ubuntu-latest
99+
needs: resolve-patch-metadata
100+
permissions:
101+
contents: read
102+
env:
103+
SOURCE_PATH: ${{ needs.resolve-patch-metadata.outputs.source_path }}
104+
REPO_URL: ${{ needs.resolve-patch-metadata.outputs.repo_url }}
105+
SOURCE_REPOSITORY: ${{ needs.resolve-patch-metadata.outputs.source_repository }}
106+
PATCH_PATH: ${{ needs.resolve-patch-metadata.outputs.patch_path }}
107+
SOURCE_BASE_REF: ${{ needs.resolve-patch-metadata.outputs.source_base_ref }}
108+
LOCKFILE: ${{ needs.resolve-patch-metadata.outputs.lockfile }}
109+
steps:
110+
- name: Generate CCBR-bot token
111+
id: ccbr_bot
112+
uses: actions/create-github-app-token@v1
113+
with:
114+
app-id: ${{ secrets.CCBR_BOT_APP_ID }}
115+
private-key: ${{ secrets.CCBR_BOT_PRIVATE_KEY }}
116+
117+
- name: Checkout host repository
118+
uses: actions/checkout@v6
119+
with:
120+
path: host
121+
122+
- name: Checkout source repository
123+
uses: actions/checkout@v6
124+
with:
125+
repository: ${{ env.SOURCE_REPOSITORY }}
126+
ref: ${{ env.SOURCE_BASE_REF }}
127+
token: ${{ steps.ccbr_bot.outputs.token }}
128+
path: source
129+
130+
- name: Apply patch to source repository
131+
id: apply_patch
132+
shell: bash
133+
run: |
134+
set -euo pipefail
135+
136+
patch_file="$GITHUB_WORKSPACE/host/${PATCH_PATH}"
137+
if [[ ! -f "$patch_file" ]]; then
138+
echo "Error: patch file not found in host repository: ${PATCH_PATH}" >&2
139+
exit 1
140+
fi
141+
142+
branch_stub=$(printf '%s' "$SOURCE_PATH" | tr '/ ' '--' | tr -cd '[:alnum:]._-')
143+
if [[ -z "$branch_stub" ]]; then
144+
branch_stub="patch"
145+
fi
146+
branch_name="syncweaver/contribute-patch/${branch_stub}-${GITHUB_RUN_ID}"
147+
148+
cd "$GITHUB_WORKSPACE/source"
149+
git config user.name "github-actions[bot]"
150+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
151+
git switch -c "$branch_name"
152+
153+
if ! git apply --3way --whitespace=nowarn "$patch_file"; then
154+
echo "Error: patch failed to apply cleanly to ${SOURCE_REPOSITORY}@${SOURCE_BASE_REF}" >&2
155+
exit 1
156+
fi
157+
158+
if git diff --quiet; then
159+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
160+
else
161+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
162+
fi
163+
echo "branch_name=$branch_name" >> "$GITHUB_OUTPUT"
164+
165+
- name: Open pull request in source repository
166+
if: steps.apply_patch.outputs.has_changes == 'true'
167+
uses: peter-evans/create-pull-request@v7
168+
with:
169+
token: ${{ steps.ccbr_bot.outputs.token }}
170+
path: source
171+
base: ${{ env.SOURCE_BASE_REF }}
172+
branch: ${{ steps.apply_patch.outputs.branch_name }}
173+
delete-branch: true
174+
commit-message: "chore(syncweaver): apply host patch for ${{ env.SOURCE_PATH }}"
175+
title: "chore(syncweaver): apply host patch for ${{ env.SOURCE_PATH }}"
176+
body: |
177+
Automated patch contribution from host repository workflow dispatch.
178+
179+
Inputs used:
180+
- source_path: ${{ env.SOURCE_PATH }}
181+
- repo_url: ${{ env.REPO_URL }}
182+
- source_repository: ${{ env.SOURCE_REPOSITORY }}
183+
- source_base_ref: ${{ env.SOURCE_BASE_REF }}
184+
- patch_path: ${{ env.PATCH_PATH }}
185+
- lockfile: ${{ env.LOCKFILE }}
186+
187+
Trigger context:
188+
- host_repository: ${{ github.repository }}
189+
- workflow_run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
190+
191+
- name: Print no-op summary
192+
if: steps.apply_patch.outputs.has_changes == 'false'
193+
shell: bash
194+
run: |
195+
set -euo pipefail
196+
echo "Patch applied cleanly but introduced no source changes. No PR created."

0 commit comments

Comments
 (0)