Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions .github/workflows/auto-pr-from-team.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,29 @@ jobs:
- name: Get changed files
id: changed_files
run: |
set -e
git fetch origin main --prune --unshallow || git fetch origin main --prune

CHANGED_FILES=$(git diff --name-only origin/main...HEAD)

if [ -z "$CHANGED_FILES" ]; then
CHANGED_FILES=$(git diff --name-only $(git merge-base origin/main HEAD) HEAD)
fi

set -euo pipefail

for d in 50 200 1000; do
echo "fetch origin main with depth=$d"
git fetch origin main --depth=$d --prune

if git merge-base origin/main HEAD >/dev/null 2>&1; then
echo "merge-base found with depth=$d"
break
fi
done

CHANGED_FILES=$(git diff --name-only origin/main...HEAD || true)

echo "Changed files:"
echo "$CHANGED_FILES"
echo "$CHANGED_FILES" > /tmp/changed_files.txt

# 루트 파일은 'root'로, 나머지는 폴더명만 추출
CHANGED_DIRS=$(echo "$CHANGED_FILES" | awk -F/ '{if (NF==1) print "root"; else print $1}' | sort -u | tr '\n' ' ')


CHANGED_DIRS=$(echo "$CHANGED_FILES" \
| awk -F/ '{if (NF==1) print "root"; else print $1}' \
| sort -u \
| tr '\n' ' ')

echo "Final Dirs: [$CHANGED_DIRS]"
echo "dirs=$CHANGED_DIRS" >> "$GITHUB_OUTPUT"

Expand Down
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,32 @@ SCHEMA_REMOTE_URL := https://github.com/RainbowRobotics/message-schema.git

.PHONY: schema-subtree-init
schema-subtree-init: ## schema subtree 최초 1회 초기화
@[ ! -d "$(SCHEMA_DIR)" ] || (echo "❌ $(SCHEMA_DIR) 이라는 디렉토리가 이미 존재합니다. 지워주시고 커밋/푸시 후 진행해주세요!"; exit 1)
@[ ! -d "$(SCHEMA_DIR)" ] || (echo "❌ $(SCHEMA_DIR) 이라는 디렉토리가 이미 존재합니다. 지워주시고 커밋/푸시 후 진행해주세요!"; exit 1)
@git remote get-url $(SCHEMA_REMOTE) >/dev/null 2>&1 \
|| git remote add $(SCHEMA_REMOTE) $(SCHEMA_REMOTE_URL)
@git subtree add --prefix=$(SCHEMA_DIR) $(SCHEMA_REMOTE) main --squash

.PHONY: schema-remote-add
schema-remote-add: ## schema remote add
@if ! git remote get-url "$(SCHEMA_REMOTE)" >/dev/null 2>&1; then \
echo "remote '$(SCHEMA_REMOTE)' 를 찾을 수 없습니다. remote를 추가합니다."; \
git remote add "$(SCHEMA_REMOTE)" "$(SCHEMA_REMOTE_URL)"; \
fi
@git fetch "$(SCHEMA_REMOTE)" --prune

.PHONY: schema-update
schema-update: ## schemas 변경사항을 현재 레포와 서브레포로 push 그리고 자동 PR 진행
schema-update: schema-remote-add ## schemas 변경사항을 현재 레포와 서브레포로 push 그리고 자동 PR 진행
@bash "$(SCHEMA_DIR)/schema-update.sh" --dir $(SCHEMA_DIR) --remote $(SCHEMA_REMOTE)

.PHONY: schema-sync
schema-sync: ## message-schema의 main 브랜치 내용을 현재 SCHEMA_DIR에 그대로 가져오기 (변경 사항이 있다면 진짜 덮어씌울건지 물어봄)
schema-sync: schema-remote-add ## message-schema의 main 브랜치 내용을 현재 SCHEMA_DIR에 그대로 가져오기 (변경 사항이 있다면 진짜 덮어씌울건지 물어봄)
@bash "$(SCHEMA_DIR)/schema-sync.sh" --dir $(SCHEMA_DIR) --remote $(SCHEMA_REMOTE)


.PHONY: schema-sync-force
schema-sync-force: schema-remote-add ## message-schema의 main 브랜치 내용을 현재 SCHEMA_DIR에 그대로 가져오기 (변경 사항이 있다면 강제 덮어씌우기)
@bash "$(SCHEMA_DIR)/schema-sync.sh" --dir $(SCHEMA_DIR) --remote $(SCHEMA_REMOTE) -y

```

### 2. message-schema를 Subtree로 추가
Expand Down Expand Up @@ -75,7 +89,11 @@ message-schema 레포에서 **리뷰 후 수동 Apply** 되어야 main에 반영
### 📥 message-schema에 main 브랜치 내용으로 가져오기

```sh
make schema-sync
make schema-sync

#or

make schema-sync-force # main 브랜치와 달라도 덮어씌울건지 안물어보고 강제로 main 브랜치 내용으로 덮어버림
```

#### 동작 요약
Expand All @@ -91,8 +109,17 @@ make schema-sync
📌 `schema-sync`는 `schema/from-* `**브랜치를 가져오지 않으며,
PR이 `main`에 머지된 내용만** 반영됩니다.

📌 `message-schema/main`에 이제까지 제대로 위 시나리오대로 `make schema-update`를 하고 Merge 하는 방식을 잘 따라줬더라면,
작업이 끝나고 배포할때 무조건 `message-schema/main`꺼를 가져다가 쓰는 것이 더욱 안전하고 확실합니다.

📌 `schemas/`에서 작업 중인 내용이 있다면, 동기화 시 **사라질 수 있습니다.**
필요하면 먼저 `make schema-update`로 PR을 올리거나, 별도 백업 후 진행하세요.

📌 `make schema-sync`(git subtree pull)는 prefix(schemas)만 깨끗하면 되는 게 아니라, “레포 전체 working tree가 clean” 이어야 실행됩니다.
지금 스크립트는 schemas/만 restore/clean 했고, 다른 경로(예: Makefile, backend, 뭐든) 에 수정/스테이징/untracked가 남아있으면:

> fatal: working tree has modifications. Cannot add.

<br />

## 3️⃣ 디렉토리 구조
Expand Down
4 changes: 2 additions & 2 deletions nexus/v1/common_network.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ table Response_Network_GetNetwork {
}

// 네트워크 설정 ------------------------------------------------
table Request_Network_SetPD {
table Request_Network_SetNetwork {
ssid: string;
dhcp: bool;
address: string;
Expand All @@ -42,7 +42,7 @@ table Request_Network_SetPD {
dns: [string];
}

table Response_Network_SetPD {
table Response_Network_SetNetwork {
ssid: string;
dhcp: bool;
address: string;
Expand Down
11 changes: 11 additions & 0 deletions nexus/v1/program.fbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include "flow_manager.fbs";

attribute optional;

namespace program;

enum RB_Program_Sub_Task_Type: byte {
Expand Down Expand Up @@ -60,3 +62,12 @@ table Request_Update_Sub_Task_State {
sub_task_type: RB_Program_Sub_Task_Type;
state: flow_manager.RB_Flow_Manager_ProgramState;
}

table Request_Exec_Control_Program {
robot_model: string(optional);
program_id: string(optional);
}

table Response_Exec_Control_Program {
manipulate_return_value: int(optional);
}
1 change: 1 addition & 0 deletions nexus/v1/test.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ table Test_General {

table Test_Advanced {
test: float;
test1: int;
}

root_type Test_General;
Expand Down
6 changes: 3 additions & 3 deletions schema-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ while [[ $# -gt 0 ]]; do
case $1 in
--dir) SCHEMA_DIR="$2"; shift 2 ;;
--remote) REMOTE_NAME="$2"; shift 2 ;;
--yes) ASSUME_YES=1; shift 1 ;;
-y|--yes) ASSUME_YES=1; shift 1 ;;
*) print_string "error" "Unknown option: $1"; exit 1 ;;
esac
done
Expand Down Expand Up @@ -103,10 +103,10 @@ if [ "$TREE_DIFF" -eq 0 ] && [ "$HAS_CHANGES" -eq 0 ]; then
exit 0
fi

if [ "$HAS_CHANGES" -eq 1 ]; then
if [ "$HAS_CHANGES" -eq 1 ] && [ "$ASSUME_YES" -eq 0 ]; then
confirm_or_exit \
"'$SCHEMA_DIR' 아래에 로컬 변경이 있습니다. 동기화하면 '$SCHEMA_DIR'의 로컬 변경(수정/추가/untracked/staged)이 삭제됩니다."
else
elif [ "$HAS_CHANGES" -eq 0 ]; then
# 로컬 작업은 없지만, 커밋된 상태(워킹트리 clean)라도 현재 schemas 상태가 덮일 수 있음
confirm_or_exit \
"'$SCHEMA_DIR'의 현재 커밋 상태가 '$REMOTE_NAME/main'과 다릅니다. 최신 main을 반영하기 위해 동기화합니다.
Expand Down