Skip to content

Commit fee2ee8

Browse files
feat: set up Syncweaver + mosuite v0.3.2 (#3)
* Squashed 'code/MOSuite/' content from commit c09ee39 git-subtree-dir: code/MOSuite git-subtree-split: c09ee39f9b282237f13d88dcf4cdfed965209c68 * refactor: load local MOSuite * feat: intialize syncweaver & mosuite v0.3.2 * chore: remove dupe * chore: use mosuite-minimal v0.3.2 * `air format` (GitHub Actions) * ci: update workflows from template * ci(tests): limit permissions --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent eca7a55 commit fee2ee8

314 files changed

Lines changed: 50638 additions & 37 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: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
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+
syncweaver-version:
32+
description: syncweaver version/ref to install (e.g. version tag, branch name, or commit SHA). Will use docker image if available.
33+
required: false
34+
type: string
35+
default: main
36+
37+
permissions:
38+
contents: read
39+
40+
jobs:
41+
resolve-patch-metadata:
42+
runs-on: ubuntu-latest
43+
outputs:
44+
source_path: ${{ steps.resolve.outputs.source_path }}
45+
repo_url: ${{ steps.resolve.outputs.repo_url }}
46+
source_repository: ${{ steps.resolve.outputs.source_repository }}
47+
patch_path: ${{ steps.resolve.outputs.patch_path }}
48+
source_base_ref: ${{ steps.resolve.outputs.source_base_ref }}
49+
lockfile: ${{ env.LOCKFILE }}
50+
env:
51+
SOURCE_PATH: ${{ github.event.inputs.source_path || '' }}
52+
REPO_URL: ${{ github.event.inputs.repo_url || '' }}
53+
SOURCE_REPOSITORY: ${{ github.event.inputs.source_repository || '' }}
54+
LOCKFILE: ${{ github.event.inputs.lockfile || '.syncweaver-lock.json' }}
55+
PATCH_PATH: ${{ github.event.inputs.patch_path || '' }}
56+
SOURCE_BASE_REF: ${{ github.event.inputs.source_base_ref || '' }}
57+
SYNCWEAVER_VERSION: ${{ github.event.inputs['syncweaver-version'] || github.event.client_payload['syncweaver-version'] || 'main' }}
58+
steps:
59+
- name: Checkout host repository
60+
uses: actions/checkout@v6
61+
62+
- name: Setup syncweaver
63+
uses: CCBR/syncweaver/actions/setup-syncweaver@main
64+
with:
65+
syncweaver-version: ${{ env.SYNCWEAVER_VERSION }}
66+
67+
- name: Resolve source and patch metadata
68+
id: resolve
69+
shell: bash
70+
env:
71+
SOURCE_PATH_INPUT: ${{ env.SOURCE_PATH }}
72+
REPO_URL_INPUT: ${{ env.REPO_URL }}
73+
SOURCE_REPOSITORY_INPUT: ${{ env.SOURCE_REPOSITORY }}
74+
LOCKFILE_PATH: ${{ env.LOCKFILE }}
75+
PATCH_PATH_INPUT: ${{ env.PATCH_PATH }}
76+
SOURCE_BASE_REF_INPUT: ${{ env.SOURCE_BASE_REF }}
77+
SYNCWEAVER_HOST_CWD: ${{ github.workspace }}
78+
run: |
79+
set -euo pipefail
80+
syncweaver-python -m syncweaver.contribute_patch
81+
82+
- name: Print resolved metadata
83+
shell: bash
84+
run: |
85+
set -euo pipefail
86+
echo "source_path=${{ steps.resolve.outputs.source_path }}"
87+
echo "repo_url=${{ steps.resolve.outputs.repo_url }}"
88+
echo "source_repository=${{ steps.resolve.outputs.source_repository }}"
89+
echo "patch_path=${{ steps.resolve.outputs.patch_path }}"
90+
echo "source_base_ref=${{ steps.resolve.outputs.source_base_ref }}"
91+
92+
contribute-patch:
93+
runs-on: ubuntu-latest
94+
needs: resolve-patch-metadata
95+
permissions:
96+
contents: read
97+
env:
98+
SOURCE_PATH: ${{ needs.resolve-patch-metadata.outputs.source_path }}
99+
REPO_URL: ${{ needs.resolve-patch-metadata.outputs.repo_url }}
100+
SOURCE_REPOSITORY: ${{ needs.resolve-patch-metadata.outputs.source_repository }}
101+
PATCH_PATH: ${{ needs.resolve-patch-metadata.outputs.patch_path }}
102+
SOURCE_BASE_REF: ${{ needs.resolve-patch-metadata.outputs.source_base_ref }}
103+
LOCKFILE: ${{ needs.resolve-patch-metadata.outputs.lockfile }}
104+
steps:
105+
- name: Generate CCBR-bot token
106+
id: ccbr_bot
107+
uses: actions/create-github-app-token@v1
108+
with:
109+
app-id: ${{ secrets.CCBR_BOT_APP_ID }}
110+
private-key: ${{ secrets.CCBR_BOT_PRIVATE_KEY }}
111+
112+
- name: Checkout host repository
113+
uses: actions/checkout@v6
114+
with:
115+
path: host
116+
117+
- name: Checkout source repository
118+
uses: actions/checkout@v6
119+
with:
120+
repository: ${{ env.SOURCE_REPOSITORY }}
121+
ref: ${{ env.SOURCE_BASE_REF }}
122+
token: ${{ steps.ccbr_bot.outputs.token }}
123+
path: source
124+
125+
- name: Apply patch to source repository
126+
id: apply_patch
127+
shell: bash
128+
run: |
129+
set -euo pipefail
130+
131+
patch_file="$GITHUB_WORKSPACE/host/${PATCH_PATH}"
132+
if [[ ! -f "$patch_file" ]]; then
133+
echo "Error: patch file not found in host repository: ${PATCH_PATH}" >&2
134+
exit 1
135+
fi
136+
137+
branch_stub=$(printf '%s' "$SOURCE_PATH" | tr '/ ' '--' | tr -cd '[:alnum:]._-')
138+
if [[ -z "$branch_stub" ]]; then
139+
branch_stub="patch"
140+
fi
141+
branch_name="syncweaver/contribute-patch/${branch_stub}-${GITHUB_RUN_ID}"
142+
143+
cd "$GITHUB_WORKSPACE/source"
144+
git config user.name "github-actions[bot]"
145+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
146+
git switch -c "$branch_name"
147+
148+
if ! git apply --3way --whitespace=nowarn "$patch_file"; then
149+
echo "Error: patch failed to apply cleanly to ${SOURCE_REPOSITORY}@${SOURCE_BASE_REF}" >&2
150+
exit 1
151+
fi
152+
153+
if git diff --quiet; then
154+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
155+
else
156+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
157+
fi
158+
echo "branch_name=$branch_name" >> "$GITHUB_OUTPUT"
159+
160+
- name: Open pull request in source repository
161+
if: steps.apply_patch.outputs.has_changes == 'true'
162+
uses: peter-evans/create-pull-request@v7
163+
with:
164+
token: ${{ steps.ccbr_bot.outputs.token }}
165+
path: source
166+
base: ${{ env.SOURCE_BASE_REF }}
167+
branch: ${{ steps.apply_patch.outputs.branch_name }}
168+
delete-branch: true
169+
commit-message: "chore(syncweaver): apply host patch for ${{ env.SOURCE_PATH }}"
170+
title: "chore(syncweaver): apply host patch for ${{ env.SOURCE_PATH }}"
171+
body: |
172+
Automated patch contribution from host repository workflow dispatch.
173+
174+
Inputs used:
175+
- source_path: ${{ env.SOURCE_PATH }}
176+
- repo_url: ${{ env.REPO_URL }}
177+
- source_repository: ${{ env.SOURCE_REPOSITORY }}
178+
- source_base_ref: ${{ env.SOURCE_BASE_REF }}
179+
- patch_path: ${{ env.PATCH_PATH }}
180+
- lockfile: ${{ env.LOCKFILE }}
181+
182+
Trigger context:
183+
- host_repository: ${{ github.repository }}
184+
- workflow_run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
185+
186+
- name: Print no-op summary
187+
if: steps.apply_patch.outputs.has_changes == 'false'
188+
shell: bash
189+
run: |
190+
set -euo pipefail
191+
echo "Patch applied cleanly but introduced no source changes. No PR created."

0 commit comments

Comments
 (0)