diff --git a/.github/workflows/simple.yaml b/.github/workflows/simple.yaml new file mode 100644 index 0000000..f92c92d --- /dev/null +++ b/.github/workflows/simple.yaml @@ -0,0 +1,46 @@ +name: Simple Build +on: + push: + # Will trigger on MERGES (or pushes) to main branch. + branches: + - 'main' + pull_request: + # Will ALSO trigger any time a PR is opened merging to main. + # Specify '*' here to merge on PRs being opened against ANY branch. + branches: + - 'main' + +jobs: + # The name of the job is "build". All jobs run in SEPARATE containers, so + # they may run on separate machines and have the workspace wiped inbetween. + build: + # Run on a github-hosted runner. To specify our own, select: + # [self-hosted, linux] instead. + runs-on: ubuntu-latest + # This is the docker container that the image will run in. This is 20.04 + # with ros-noetic-desktop meta-package. + container: osrf/ros:noetic-desktop + steps: + # Name is optional, uses: specify which ACTION is used (basically github + # macros). You can write your own! Use with: to specify extra parameters. + - name: Check out depository + - uses: actions/checkout@v3 + with: + path: ${HOME}/catkin_ws/src/toy_example_package + submodules: recursive + #- name: Install catkin-tools on Noetic + # run: | + # apt update && apt install -y python3-pip + # pip3 install osrf-pycommon + # apt update && apt install -y python3-wstool python3-catkin-tools + - name: Build test + run: | + cd ${HOME}/catkin_ws + catkin init + catkin config --extend "/opt/ros/noetic" + catkin config --merge-devel + rosdep update + rosdep install --from-paths src --ignore-src -y --rosdistro noetic + catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release + catkin build --continue toy_example_package + # shell: bash \ No newline at end of file diff --git a/README.md b/README.md index 2f8bcbe..12d67c9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # asl-actions -Github Actions for ASL +Github Actions and documentation for ASL. + +## Getting Started +First, you can start with the quick-start docs from GitHub: https://docs.github.com/en/actions/quickstart + +Then you can follow along with a few simple tutorial workflows. + diff --git a/Dockerfile b/actions/delete-workspace/Dockerfile similarity index 100% rename from Dockerfile rename to actions/delete-workspace/Dockerfile diff --git a/action.yml b/actions/delete-workspace/action.yml similarity index 99% rename from action.yml rename to actions/delete-workspace/action.yml index ad2dc27..706034d 100644 --- a/action.yml +++ b/actions/delete-workspace/action.yml @@ -5,3 +5,4 @@ description: 'Clean up the workspace state before and/or after running.' runs: using: 'docker' image: 'Dockerfile' + diff --git a/entrypoint.sh b/actions/delete-workspace/entrypoint.sh similarity index 100% rename from entrypoint.sh rename to actions/delete-workspace/entrypoint.sh diff --git a/example_workflows/simple_catkin.yml b/example_workflows/simple_catkin.yml new file mode 100644 index 0000000..b780ec8 --- /dev/null +++ b/example_workflows/simple_catkin.yml @@ -0,0 +1,57 @@ +name: Build and Test Catkin Package +on: + push: + # Will trigger on MERGES (or pushes) to main branch. + branches: + - 'main' + pull_request: + # Will ALSO trigger any time a PR is opened merging to main. + # Specify '*' here to merge on PRs being opened against ANY branch. + branches: + - 'main' + +jobs: + # The name of the job is "build". All jobs run in SEPARATE containers, so + # they may run on separate machines and have the workspace wiped inbetween. + build: + # Run on a github-hosted runner. To specify our own, select: + # [self-hosted, linux] instead. + runs-on: ubuntu-latest + # This is the docker container that the image will run in. This is 20.04 + # with ros-noetic-desktop meta-package. + container: osrf/ros:noetic-desktop + steps: + # Name is optional, uses: specify which ACTION is used (basically github + # macros). You can write your own! Use with: to specify extra parameters. + - name: Check out depository + - uses: actions/checkout@v3 + with: + path: ${HOME}/catkin_ws/src/my_package_name + submodules: recursive + - name: Install catkin-tools on Noetic + run: | + apt update && apt install -y python3-pip + pip3 install osrf-pycommon + apt update && apt install -y python3-wstool python3-catkin-tools + - name: Install Dependencies + run: | + $GITHUB_WORKSPACE/install/prepare-jenkins-slave.sh + shell: bash + - name: Build test + working-directory: + env: + DEBIAN_FRONTEND: noninteractive + run: | + apt update + apt install -y autoconf libtool git qt5-default + mkdir -p ${HOME}/catkin_ws/src; + cd ${HOME}/catkin_ws + catkin init + catkin config --extend "/opt/ros/${{matrix.config.rosdistro}}" + catkin config --merge-devel + cd ${HOME}/catkin_ws + rosdep update + rosdep install --from-paths src --ignore-src -y --rosdistro noetic + catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release + catkin build --continue my_package_name + shell: bash \ No newline at end of file diff --git a/toy_example_package/CMakeLists.txt b/toy_example_package/CMakeLists.txt new file mode 100644 index 0000000..6189bca --- /dev/null +++ b/toy_example_package/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.0.2) +project(toy_example_package) + +add_compile_options(-std=c++11) + +find_package(catkin REQUIRED COMPONENTS roscpp std_msgs) +catkin_package( + CATKIN_DEPENDS std_msgs roscpp +) + +include_directories(include ${catkin_INCLUDE_DIRS}) + +add_executable(publisher_node src/publisher.cpp) +add_dependencies(publisher_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) +target_link_libraries(publisher_node + ${catkin_LIBRARIES} +) + + diff --git a/toy_example_package/package.xml b/toy_example_package/package.xml new file mode 100644 index 0000000..fc2a8a3 --- /dev/null +++ b/toy_example_package/package.xml @@ -0,0 +1,17 @@ + + + toy_example_package + 0.0.0 + Toy example package for Github Actions workflows. + + Helen Oleynikova + + BSD + + roscpp + std_msgs + catkin + + + + diff --git a/toy_example_package/src/publisher.cpp b/toy_example_package/src/publisher.cpp new file mode 100644 index 0000000..94f2e03 --- /dev/null +++ b/toy_example_package/src/publisher.cpp @@ -0,0 +1,36 @@ +#include +#include + +#include + +// All this code is from the publisher tutorial: +// https://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29 +int main(int argc, char **argv) { + ros::init(argc, argv, "toy_example_publisher"); + + ros::NodeHandle nh, nh_private("~"); + + ros::Publisher pub = nh_private.advertise("hello", 1); + + ros::Rate loop_rate(10); // Hz + + int count = 0; + while (ros::ok()) { + std_msgs::String msg; + + std::stringstream ss; + ss << "hello world " << count; + msg.data = ss.str(); + + ROS_INFO("%s", msg.data.c_str()); + + pub.publish(msg); + + ros::spinOnce(); + + loop_rate.sleep(); + ++count; + } + + return 0; +}