Skip to content

Commit 0195f71

Browse files
Add first draft of command diff workflow
1 parent aff144b commit 0195f71

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Compare SCT Commands
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
text_url:
7+
description: "URL to text file (e.g. GitHub raw gist link)"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
compare:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Check out repo
17+
uses: actions/checkout@v4
18+
19+
- name: Install Python (for parsing script)
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.11"
23+
24+
- name: Download remote text file
25+
run: |
26+
curl -L "${{ github.event.inputs.text_url }}" -o remote.txt
27+
echo "✅ Downloaded remote file:"
28+
wc -l remote.txt
29+
30+
- name: Extract commands from remote file
31+
run: |
32+
python3 .github/workflows/scripts/extract_sct.py remote.txt -o remote_cmds.txt
33+
sort -u remote_cmds.txt > remote_cmds_sorted.txt
34+
echo "✅ Extracted $(wc -l < remote_cmds_sorted.txt) commands from remote file"
35+
36+
- name: Extract commands from local batch script
37+
run: |
38+
python3 .github/workflows/scripts/extract_sct.py single_subject/batch_single_subject.sh -o local_cmds.txt
39+
sort -u local_cmds.txt > local_cmds_sorted.txt
40+
echo "✅ Extracted $(wc -l < local_cmds_sorted.txt) commands from local script"
41+
42+
- name: Diff commands
43+
run: |
44+
echo "🔍 Diffing remote vs local..."
45+
diff -u local_cmds_sorted.txt remote_cmds_sorted.txt || true
46+
47+
- name: Upload results as artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: command-diff-output
51+
path: |
52+
remote_cmds_sorted.txt
53+
local_cmds_sorted.txt
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import argparse
2+
from pathlib import Path
3+
4+
5+
def extract_sct_commands(paths, output=None):
6+
results = []
7+
8+
for path in paths:
9+
with open(path, "r", encoding="utf-8") as f:
10+
for line in f:
11+
stripped = line.lstrip()
12+
if stripped.startswith("sct_"):
13+
results.append(stripped.rstrip())
14+
15+
if output:
16+
Path(output).write_text("\n".join(results), encoding="utf-8")
17+
else:
18+
print("\n".join(results))
19+
20+
21+
if __name__ == "__main__":
22+
parser = argparse.ArgumentParser(description="Extract SCT commands "
23+
"from TXT files.")
24+
parser.add_argument("files", nargs="+", help="Input text files")
25+
parser.add_argument("-o", "--output", help="Optional output file")
26+
args = parser.parse_args()
27+
28+
extract_sct_commands(args.files, args.output)

0 commit comments

Comments
 (0)