diff --git a/.github/actions/install_apt_packages/action.yml b/.github/actions/install_apt_packages/action.yml new file mode 100644 index 0000000..056e6d4 --- /dev/null +++ b/.github/actions/install_apt_packages/action.yml @@ -0,0 +1,33 @@ +name: install_apt_packages +description: 'Install specified APT packages' + +inputs: + packages: + description: 'A space-separated list of APT packages to install.' + required: true + use-sudo: + description: 'Whether to use sudo for installation commands.' + required: false + default: 'true' + use-update: + description: 'Whether to run apt-get update before installing packages.' + required: false + default: 'true' + +runs: + using: composite + steps: + - name: Install APT packages + run: | + if [ "${{ inputs.use-sudo }}" = "true" ]; then + SUDO="sudo" + else + SUDO="" + fi + + if [ "${{ inputs.use-update }}" = "true" ]; then + $SUDO apt-get update + fi + + $SUDO apt-get install -y ${{ inputs.packages }} + shell: bash diff --git a/.github/actions/install_python_packages/action.yml b/.github/actions/install_python_packages/action.yml new file mode 100644 index 0000000..79ed278 --- /dev/null +++ b/.github/actions/install_python_packages/action.yml @@ -0,0 +1,40 @@ +name: install_python_packages +description: 'Install specified Python packages in a virtual environment' + +inputs: + packages: + description: 'A space-separated list of Python packages to install.' + required: true + python-version: + description: 'The Python version to use (e.g., 3.12).' + required: true + venv-path: + description: 'The path where the virtual environment should be created.' + required: false + default: '.venv' + use-sudo: + description: 'Whether to use sudo for installation commands.' + required: false + default: 'true' + +runs: + using: composite + steps: + + - name: Install required APT packages + uses: ./.github/actions/install_apt_packages + with: + packages: "python${{ inputs.python-version }}-venv" + use-sudo: ${{ inputs.use-sudo }} + use-update: "false" + + - name: Setup environment + run: | + python${{ inputs.python-version }} -m venv ${{ inputs.venv-path }} + echo PATH=${GITHUB_WORKSPACE}/.venv/bin:$PATH >> $GITHUB_ENV + shell: bash + + - name: Install Python packages + run: | + pip install ${{ inputs.packages }} + shell: bash diff --git a/.github/actions/install_sdk/action.yml b/.github/actions/install_sdk/action.yml new file mode 100644 index 0000000..088a4e0 --- /dev/null +++ b/.github/actions/install_sdk/action.yml @@ -0,0 +1,57 @@ +name: install_sdk +description: Generate the TivaWare for C Series SDK files + +inputs: + sdk_version: + description: 'The SW-TM4C SDK version to install (See https://www.ti.com/tool/SW-TM4C#downloads).' + required: true + install_path: + description: 'The path where the SDK should be installed.' + required: true + force_reinstall: + description: 'Force reinstallation even if the SDK is already installed.' + required: false + default: 'false' + use-sudo: + description: 'Whether to use sudo for installation commands.' + required: false + default: 'true' + +runs: + using: composite + steps: + + - name: Install APT packages + uses: ./.github/actions/install_apt_packages + with: + packages: "curl p7zip" + use-sudo: ${{ inputs.use-sudo }} + use-update: "false" + + - name: Install TivaWare SDK files + run: | + SDK_VERSION="${{ inputs.sdk_version }}" + INSTALL_PATH="${{ inputs.install_path }}" + FORCE_REINSTALL="${{ inputs.force_reinstall }}" + SDK_EXE="SDK-${SDK_VERSION}.exe" + SDK_URL="https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-oCcDwnGrsI/${SDK_VERSION}/SW-TM4C-${SDK_VERSION}.exe" + + if [ -d "$INSTALL_PATH" ] && [ "$FORCE_REINSTALL" != "true" ]; then + echo "SDK already installed at $INSTALL_PATH. Skipping download and installation." + exit 0 + fi + + mkdir -p "$INSTALL_PATH" + cd "$INSTALL_PATH" + + echo "Downloading TivaWare SDK version $SDK_VERSION..." + curl -L -o "$SDK_EXE" "$SDK_URL" + + echo "Extracting SDK..." + 7z x "$SDK_EXE" -o"$INSTALL_PATH" + + echo "Cleaning up..." + rm "$SDK_EXE" + + echo "TivaWare SDK version $SDK_VERSION installed at $INSTALL_PATH." + shell: bash diff --git a/.github/workflows/humble-ci.yml b/.github/workflows/humble-ci.yml new file mode 100644 index 0000000..248d505 --- /dev/null +++ b/.github/workflows/humble-ci.yml @@ -0,0 +1,14 @@ +name: CI (Humble) + +on: + push: + branches: [ humble ] + pull_request: + branches: [ humble ] + +jobs: + build: + uses: ./.github/workflows/reusable-ci.yml + with: + os: ubuntu-22.04 + branch: ${{ github.ref }} diff --git a/.github/workflows/jazzy-ci.yml b/.github/workflows/jazzy-ci.yml new file mode 100644 index 0000000..5bdc9e8 --- /dev/null +++ b/.github/workflows/jazzy-ci.yml @@ -0,0 +1,14 @@ +name: CI (Jazzy) + +on: + push: + branches: [ jazzy ] + pull_request: + branches: [ jazzy ] + +jobs: + build: + uses: ./.github/workflows/reusable-ci.yml + with: + os: ubuntu-24.04 + branch: ${{ github.ref }} diff --git a/.github/workflows/kilted.ci.yml b/.github/workflows/kilted.ci.yml new file mode 100644 index 0000000..02c4305 --- /dev/null +++ b/.github/workflows/kilted.ci.yml @@ -0,0 +1,14 @@ +name: CI (Kilted) + +on: + push: + branches: [ kilted ] + pull_request: + branches: [ kilted ] + +jobs: + build: + uses: ./.github/workflows/reusable-ci.yml + with: + os: ubuntu-24.04 + branch: ${{ github.ref }} diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml new file mode 100644 index 0000000..e80e003 --- /dev/null +++ b/.github/workflows/nightly-ci.yml @@ -0,0 +1,28 @@ +name: Nightly CI (all distros) + +on: + schedule: + - cron: '59 23 * * *' # Runs every day at 23:59 UTC + workflow_dispatch: + +jobs: + humble-ci: + uses: ./.github/workflows/reusable-ci.yml + with: + branch: humble + os: ubuntu-22.04 + jazzy-ci: + uses: ./.github/workflows/reusable-ci.yml + with: + branch: jazzy + os: ubuntu-24.04 + kilted-ci: + uses: ./.github/workflows/reusable-ci.yml + with: + branch: kilted + os: ubuntu-24.04 + rolling-ci: + uses: ./.github/workflows/reusable-ci.yml + with: + branch: rolling + os: ubuntu-24.04 diff --git a/.github/workflows/reusable-ci.yml b/.github/workflows/reusable-ci.yml new file mode 100644 index 0000000..38b1b9b --- /dev/null +++ b/.github/workflows/reusable-ci.yml @@ -0,0 +1,57 @@ +name: Reusable CI Workflow + +on: + workflow_call: + inputs: + os: + description: "The OS to use for the workflow" + required: true + type: string + branch: + description: "The branch to use for the workflow" + required: true + type: string + +jobs: + build: + runs-on: ${{ inputs.os }} + strategy: + fail-fast: false + steps: + + - name: Sync repository + uses: actions/checkout@v5 + with: + ref: ${{ inputs.branch }} + submodules: recursive + + - name: Install APT packages + uses: ./.github/actions/install_apt_packages + with: + packages: "build-essential cmake gcc-arm-none-eabi rsync" + use-sudo: "true" + use-update: "true" + + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: "3.10" + + - name: Install required python packages + uses: ./.github/actions/install_python_packages + with: + packages: "catkin_pkg lark-parser empy==3.3.4 colcon-common-extensions" + python-version: "3.10" + use-sudo: "true" + + - name: Install TivaWare SDK + uses: ./.github/actions/install_sdk + with: + sdk_version: "2.1.4.178" + install_path: "${{ github.workspace }}/tivaware_c_series" + force_reinstall: "false" + use-sudo: "true" + + - name: Build project + run: make -j$(nproc) + shell: bash diff --git a/.github/workflows/rolling-ci.yml b/.github/workflows/rolling-ci.yml new file mode 100644 index 0000000..646bea9 --- /dev/null +++ b/.github/workflows/rolling-ci.yml @@ -0,0 +1,14 @@ +name: CI (Rolling) + +on: + push: + branches: [ rolling ] + pull_request: + branches: [ rolling ] + +jobs: + build: + uses: ./.github/workflows/reusable-ci.yml + with: + os: ubuntu-24.04 + branch: ${{ github.ref }} diff --git a/README.md b/README.md index 41b534e..cc6791c 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,16 @@ This example application has been tested in TI Tiva™ C Series TM4C123GXL Launc ## Dependencies +This component needs the following packages to setup Micro-ROS: + +```bash +sudo apt install -y rsync pip git gcc-arm-none-eabi cmake +``` + This component needs `colcon` and other Python 3 packages in order to build micro-ROS packages: ```bash -pip3 install catkin_pkg lark-parser empy colcon-common-extensions +pip3 install catkin_pkg lark-parser empy==3.3.4 colcon-common-extensions ``` ## Usage diff --git a/microros/generate_microros_library.sh b/microros/generate_microros_library.sh index 1e022a7..828139c 100755 --- a/microros/generate_microros_library.sh +++ b/microros/generate_microros_library.sh @@ -132,10 +132,11 @@ pushd $INSTALL_DIR/micro_ros_src > /dev/null INCLUDE_ROS2_PACKAGES=$(colcon list | awk '{print $1}' | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}') popd > /dev/null -apt -y install rsync for var in ${INCLUDE_ROS2_PACKAGES}; do - rsync -r $INSTALL_DIR/include/${var}/${var}/* $INSTALL_DIR/include/${var}/ - rm -rf $INSTALL_DIR/include/${var}/${var}/ + if [ -d "$INSTALL_DIR/include/${var}/${var}/" ]; then + rsync -r "$INSTALL_DIR/include/${var}/${var}/" "$INSTALL_DIR/include/${var}/" + rm -rf "$INSTALL_DIR/include/${var}/${var}/" + fi done # Print compiler info