Skip to content

Commit

Permalink
Use sample application setup script for build and bundle (#29)
Browse files Browse the repository at this point in the history
* use vanilla ubuntu image

* remove comment

* pass in --install-ros

* remove gazebo input/output

* commit index.js

* update readme

* use ros2 branch

* remove gazebo-version from test action input

Co-authored-by: chengke <chengke@uefee1b00be3a55.ant.amazon.com>
  • Loading branch information
cheng-kevin and chengke authored Jun 17, 2021
1 parent 865c557 commit bab67e5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 303 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/test-ros2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:

strategy:
matrix:
distro: ['dashing']
gazebo: [9]
distro: ['foxy']
gazebo: [11]
include:
- distro: dashing
gazebo: 9
ubuntu_distro: bionic
- distro: foxy
gazebo: 11
ubuntu_distro: focal

container:
image: rostooling/setup-ros-docker:ubuntu-${{ matrix.ubuntu_distro }}-ros-${{ matrix.distro }}-ros-base-latest
image: ubuntu:${{ matrix.ubuntu_distro }}

# NOTES: We run 2 tests for robot_ws and simulation_ws
# The test steps are duplicated because github workflow does not support reusable step (with parameter yet)
Expand Down Expand Up @@ -65,7 +65,6 @@ jobs:
uses: ./action/robomaker-sample-app-ci
with:
ros-distro: ${{ matrix.distro }}
gazebo-version: ${{ matrix.gazebo }}
workspace-dir: ./robot_ws
generate-sources: true
# Expectation: bundle file, build files, and dependencies all exist
Expand All @@ -81,9 +80,8 @@ jobs:
uses: ./action/robomaker-sample-app-ci
with:
ros-distro: ${{ matrix.distro }}
gazebo-version: ${{ matrix.gazebo }}
workspace-dir: ./simulation_ws
generate-sources: false
generate-sources: false
# Expectation: bundle file, build files, and dependencies all exist
- name: Check simulation_ws file existence
id: check_simulation_ws_files
Expand Down
105 changes: 0 additions & 105 deletions .github/workflows/test-ros2foxy.yml

This file was deleted.

27 changes: 4 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,20 @@ jobs:

strategy:
matrix:
distro: ['kinetic', 'melodic']
gazebo: [7, 9]
distro: ['melodic']
gazebo: [9]
include:
- distro: kinetic
gazebo: 7
ubuntu_distro: xenial
- distro: kinetic
gazebo: 9
ubuntu_distro: xenial
- distro: melodic
gazebo: 9
ubuntu_distro: bionic
exclude:
- distro: 'melodic'
gazebo: 7
ubuntu_distro: bionic

container:
image: rostooling/setup-ros-docker:ubuntu-${{ matrix.ubuntu_distro }}-ros-${{ matrix.distro }}-ros-base-latest
image: ubuntu:${{ matrix.ubuntu_distro }}

# NOTES: We run 2 tests for robot_ws and simulation_ws
# The test steps are duplicated because github workflow does not support reusable step (with parameter yet)
# We also can use matrix to run tests with different parameters but it is overkill for this
steps:
- name: Setup permissions
run: |
# Due to user permisson issue, calling chown is necessary for now
# Related issue: https://github.com/actions/checkout/issues/47
# Note: rosbuild is the user of the docker image
# TODO(ros-tooling/setup-ros-docker#7):
sudo chown -R rosbuild:rosbuild "$HOME" .
# Checkout SA ros1 branch into default root folder
- name: Checkout hello world sample app
uses: actions/checkout@v2
Expand All @@ -68,13 +52,11 @@ jobs:
- name: Build test script
run: npm run build
working-directory: ./action/robomaker-sample-app-ci

# Trigger to run robomaker-sample-app-ci action script
- name: Build and bundle robot_ws
uses: ./action/robomaker-sample-app-ci
with:
ros-distro: ${{ matrix.distro }}
gazebo-version: ${{ matrix.gazebo }}
workspace-dir: ./robot_ws
generate-sources: true
# Expectation: bundle file, build files, and dependencies all exist
Expand All @@ -90,7 +72,6 @@ jobs:
uses: ./action/robomaker-sample-app-ci
with:
ros-distro: ${{ matrix.distro }}
gazebo-version: ${{ matrix.gazebo }}
workspace-dir: ./simulation_ws
generate-sources: false
# Expectation: bundle file, build files, and dependencies all exist
Expand Down
11 changes: 4 additions & 7 deletions robomaker-sample-app-ci/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# AWS RoboMaker Sample Application CI Github Action

This action will build and bundle your AWS RoboMaker Sample Application package.
It must run in an environment that has all core ROS dependencies already installed for the ROS distro you are using (Kinetic, Melodic, Dashing, Foxy etc).

You use a [setup-ros-docker docker container], see usage section to see how to use this container.

## Usage

Using a [setup-ros-docker docker container] docker container:
Using a Ubuntu docker container:

```
jobs:
build-and-bundle-robot_ws-kinetic:
runs-on: ubuntu-latest
name: Build Kinetic
container:
image: rostooling/setup-ros-docker:ubuntu-xenial-ros-kinetic-ros-base-latest
image: ubuntu:bionic
steps:
- name: Build
uses: aws-robotics/aws-robomaker-github-actions/robomaker-sample-app-ci@2.3.0
with:
ros-distro: kinetic
gazebo-version: 7
workspace-dir: robot_ws
generate-sources: true
build-and-bundle-simulation_ws-kinetic:
Expand All @@ -34,18 +32,17 @@ jobs:
uses: aws-robotics/aws-robomaker-github-actions/robomaker-sample-app-ci@2.3.0
with:
ros-distro: kinetic
gazebo-version: 7
workspace-dir: simulation_ws
```

## Inputs

### `ros-distro`

**Required** Distribution of ROS you are using (`[kinetic|melodic|dashing|foxy]`)
**Required** Distribution of ROS you are using (`[melodic|foxy]`)

### `workspace-dir`

Path to the workspace folder of your package (*eg.*: `[robot_ws|simulation_ws]`, *default:* `./`).

[setup-ros-docker container]: https://hub.docker.com/r/rostooling/setup-ros-docker
[ubuntu container]: https://hub.docker.com/_/ubuntu
86 changes: 10 additions & 76 deletions robomaker-sample-app-ci/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ const core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(986));
const fs = __webpack_require__(747);
const ROS_DISTRO = core.getInput('ros-distro', { required: true });
let GAZEBO_VERSION = core.getInput('gazebo-version');
let SAMPLE_APP_VERSION = '';
const WORKSPACE_DIRECTORY = core.getInput('workspace-dir');
const GENERATE_SOURCES = core.getInput('generate-sources');
Expand Down Expand Up @@ -830,36 +829,19 @@ function fetchRosinstallDependencies() {
function setup() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield exec.exec("sudo", ["apt-key", "adv", "--fetch-keys", "http://packages.osrfoundation.org/gazebo.key"]);
let aptPackages = [
"zip",
"cmake",
"lcov",
"libgtest-dev",
"python3-colcon-common-extensions",
"python3-apt",
"python3-pip",
(ROS_DISTRO == "foxy") ? "python3-rosinstall" : "python-rosinstall",
];
if (ROS_DISTRO != "foxy") {
//focal (foxy) does not ship with python2 and does not require python-pip
//using the ros_distro instead of ubuntu_distro saves users from specifying another
//essentially redundant parameter.
aptPackages = aptPackages.concat(["python-pip"]);
if (!fs.existsSync("/etc/timezone")) {
//default to US Pacific if timezone is not set.
const timezone = "US/Pacific";
yield exec.exec("bash", ["-c", `ln -snf /usr/share/zoneinfo/${timezone} /etc/localtime`]);
yield exec.exec("bash", ["-c", `echo ${timezone} > /etc/timezone`]);
}
const python3Packages = [
"setuptools",
"colcon-bundle",
"colcon-ros-bundle"
];
yield exec.exec("sudo", ["apt-get", "update"]);
yield exec.exec("sudo", ["apt-get", "install", "-y"].concat(aptPackages));
yield exec.exec("sudo", ["pip3", "install", "-U"].concat(python3Packages));
yield exec.exec("rosdep", ["update"]);
yield loadROSEnvVariables();
yield exec.exec("bash", ["-c", `scripts/setup.sh --install-ros ${ROS_DISTRO}`]);
loadROSEnvVariables();
yield exec.exec("apt-get", ["update"]);
//zip required for prepare_sources step.
yield exec.exec("apt-get", ["install", "-y", "zip"]);
SAMPLE_APP_VERSION = yield getSampleAppVersion();
console.log(`Sample App version found to be: ${SAMPLE_APP_VERSION}`);
// Update PACKAGES_TO_SKIP_TESTS with the new packages added by 'rosws update'.
let packages = yield fetchRosinstallDependencies();
PACKAGES = packages.join(" ");
}
Expand All @@ -868,29 +850,6 @@ function setup() {
}
});
}
function setup_gazebo_source() {
return __awaiter(this, void 0, void 0, function* () {
try {
const gazebo_apt_file = "/etc/apt/sources.list.d/gazebo-stable.list";
yield exec.exec("sudo", ["rm", "-f", gazebo_apt_file]);
yield exec.exec("bash", ["-c", `echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable \`lsb_release -cs\` main" | sudo tee ${gazebo_apt_file}`]);
yield exec.exec("sudo", ["apt-get", "update"]);
if (ROS_DISTRO == "kinetic") {
const gazebo9_rosdep_file = "/etc/ros/rosdep/sources.list.d/00-gazebo9.list";
yield exec.exec("sudo", ["rm", "-f", gazebo9_rosdep_file]);
yield exec.exec("bash", ["-c", `echo "yaml https://github.com/osrf/osrf-rosdep/raw/master/gazebo9/gazebo.yaml" | sudo tee -a ${gazebo9_rosdep_file}`]);
yield exec.exec("bash", ["-c", `echo "yaml https://github.com/osrf/osrf-rosdep/raw/master/gazebo9/releases/indigo.yaml indigo" | sudo tee -a ${gazebo9_rosdep_file}`]);
yield exec.exec("bash", ["-c", `echo "yaml https://github.com/osrf/osrf-rosdep/raw/master/gazebo9/releases/jade.yaml jade" | sudo tee -a ${gazebo9_rosdep_file}`]);
yield exec.exec("bash", ["-c", `echo "yaml https://github.com/osrf/osrf-rosdep/raw/master/gazebo9/releases/kinetic.yaml kinetic" | sudo tee -a ${gazebo9_rosdep_file}`]);
yield exec.exec("bash", ["-c", `echo "yaml https://github.com/osrf/osrf-rosdep/raw/master/gazebo9/releases/lunar.yaml lunar" | sudo tee -a ${gazebo9_rosdep_file}`]);
yield exec.exec("rosdep", ["update"]);
}
}
catch (error) {
core.setFailed(error.message);
}
});
}
function prepare_sources() {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand All @@ -914,8 +873,6 @@ function prepare_sources() {
function build() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield exec.exec("rosdep", ["install", "--from-paths", ".", "--ignore-src", "-r", "-y", "--rosdistro", ROS_DISTRO], getWorkingDirExecOptions());
console.log(`Building the following packages: ${PACKAGES}`);
yield exec.exec("colcon", ["build", "--build-base", "build", "--install-base", "install"], getWorkingDirExecOptions());
}
catch (error) {
Expand Down Expand Up @@ -951,7 +908,6 @@ function bundle() {
function run() {
return __awaiter(this, void 0, void 0, function* () {
console.log(`ROS_DISTRO: ${ROS_DISTRO}`);
console.log(`GAZEBO_VERSION: ${GAZEBO_VERSION}`);
console.log(`WORKSPACE_DIRECTORY: ${WORKSPACE_DIRECTORY}`);
console.log(`GENERATE_SOURCES: ${GENERATE_SOURCES}`);
console.log(`COLCON_BUNDLE_RETRIES: ${COLCON_BUNDLE_RETRIES}`);
Expand All @@ -960,34 +916,12 @@ function run() {
core.setFailed(`Invalid number of colcon bundle retries. Must be between 0-9 inclusive`);
}
yield setup();
if (ROS_DISTRO == "kinetic" && (GAZEBO_VERSION == "" || GAZEBO_VERSION == "7")) {
GAZEBO_VERSION = "7";
}
else if (ROS_DISTRO == "kinetic" && GAZEBO_VERSION == "9") {
yield setup_gazebo_source();
}
else if (ROS_DISTRO == "melodic" && (GAZEBO_VERSION == "" || GAZEBO_VERSION == "9")) {
GAZEBO_VERSION = "9";
yield setup_gazebo_source();
}
else if (ROS_DISTRO == "dashing" && (GAZEBO_VERSION == "" || GAZEBO_VERSION == "9")) {
GAZEBO_VERSION = "9";
yield setup_gazebo_source();
}
else if (ROS_DISTRO == "foxy" && (GAZEBO_VERSION == "" || GAZEBO_VERSION == "11")) {
GAZEBO_VERSION = "11";
yield setup_gazebo_source();
}
else {
core.setFailed(`Invalid ROS and Gazebo combination`);
}
if (GENERATE_SOURCES == 'true') {
yield prepare_sources();
}
yield build();
yield bundle();
core.setOutput('ros-distro', ROS_DISTRO);
core.setOutput('gazebo-version', "gazebo" + GAZEBO_VERSION);
core.setOutput('sample-app-version', SAMPLE_APP_VERSION);
});
}
Expand Down
Loading

0 comments on commit bab67e5

Please sign in to comment.