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
132 changes: 8 additions & 124 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,129 +1,13 @@
name: XRobot Module Build Test

name: Module CI
on:
push:
pull_request:
schedule:
- cron: '0 3 1 * *' # 每月1日凌晨3点(UTC)自动触发

workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/xrobot-org/docker-image-linux:main
options: --user 0

env:
XR_MODULE_NAME: ${{ github.event.repository.name }}

steps:
- name: Checkout current module repo to ./Modules/${{ env.XR_MODULE_NAME }}
uses: actions/checkout@v4
with:
path: Modules/${{ env.XR_MODULE_NAME }}

- name: Create main.cpp
run: |
cat > main.cpp <<'EOF'
#include <iostream>
#include "xrobot_main.hpp"
#include "libxr.hpp"

int main() {
LibXR::PlatformInit();
LibXR::STDIO::Printf<"This is XRobot Module Template Test\n">();
LibXR::HardwareContainer hw;
XRobotMain(hw);
return 0;
}
EOF

- name: Create minimal CMakeLists.txt
run: |
cat > CMakeLists.txt <<'EOF'
project(xrobot_mod_test CXX)
set(CMAKE_CXX_STANDARD 20)
add_executable(xr_test main.cpp)
set(XROBOT_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Modules/)
add_subdirectory(libxr)
target_include_directories(xr_test PUBLIC $<TARGET_PROPERTY:xr,INTERFACE_INCLUDE_DIRECTORIES> ${CMAKE_SOURCE_DIR}/User)
target_link_libraries(xr_test PUBLIC xr)
EOF

- name: Pull libxr to ./libxr
run: git clone --depth=1 https://github.com/Jiu-xiao/libxr ./libxr

- name: Checkout DR16 module
uses: actions/checkout@v4
with:
repository: QDU-Robomaster/DR16
path: Modules/DR16

- name: Setup Python & Install deps
run: |
python3 -m pip install --upgrade pip
pip3 install pyyaml requests

- name: Add XRobot tools to PATH
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install xrobot toolchain (assumes pyproject/tar.gz/pip install .)
run: |
pip3 install xrobot libxr

- name: Run xrobot_setup
run: |
xrobot_setup || true

- name: Run xrobot_init_mod
run: |
xrobot_init_mod

- name: Add modules
run: |
xrobot_add_mod BlinkLED --instance-id BlinkLED_0

- name: Add this repo module
run: |
xrobot_add_mod ${{ env.XR_MODULE_NAME }} --instance-id cmd
xrobot_add_mod DR16 --instance-id dr16 && cat User/xrobot.yaml

- name: Generate main again
run: |
xrobot_setup

- name: Build
run: |
mkdir -p build
cd build
cmake ..
make

- name: Create Tag via GitHub API
if: ${{ success() && github.event_name != 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const moduleTag = process.env.XR_MODULE_NAME;
const date = new Date();
const yyyy = date.getUTCFullYear();
const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
const dd = String(date.getUTCDate()).padStart(2, '0');
const HH = String(date.getUTCHours()).padStart(2, '0');
const MM = String(date.getUTCMinutes()).padStart(2, '0');
const SS = String(date.getUTCSeconds()).padStart(2, '0');
const tagName = `${moduleTag}-${yyyy}${mm}${dd}-${HH}${MM}${SS}`;

// 获取当前 commit sha
const sha = process.env.GITHUB_SHA;

// 创建 tag reference
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tagName}`,
sha: sha
});
console.log(`Created tag: ${tagName} on sha: ${sha}`);
uses: xrobot-org/XRobot/.github/workflows/module-ci.yml@dev
with:
xrobot-ref: dev
libxr-ref: dev
dependency-ref: refs/heads/dev
template-args: '[]'
Loading
Loading