Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test PR to debug macOS support for action #8

Closed
wants to merge 10 commits into from
Closed
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
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,24 @@ jobs:
use-gazebo-nightly: 'true'
- name: 'Test Gazebo installation'
run: 'gz sim --versions'

test_gazebo_install_macos:
name: 'Check installation of Gazebo on MacOS'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-12
- macos-13
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.2
with:
node-version: '20.x'
- name: 'Check Gazebo installation on MacOS runner'
uses: ./
with:
required-gazebo-distributions: 'harmonic'
- name: 'Test Gazebo installation'
run: 'gz sim --versions'
42 changes: 32 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This action sets up a Gazebo release inside a Linux environment.
1. [Setting up worker and installing a compatible Gazebo and Ubuntu combination](#Setting-up-worker-and-installing-a-compatible-Gazebo-and-Ubuntu-combination)
1. [Iterating on all Gazebo and Ubuntu combinations](#Iterating-on-all-gazebo-ubuntu-combinations)
1. [Using pre-release and/or nightly Gazebo binaries](#Using-pre-release-and/or-nightly-Gazebo-binaries)
1. [Setting up worker to install Gazebo on macOS](#Setting-up-worker-to-install-Gazebo-on-macOS)
1. [License](#License)

## Overview
Expand All @@ -19,18 +20,20 @@ It is recommended to use the `setup-gazebo` action inside a Docker container due

## Supported platforms

`setup-gazebo` action works for all non-EOL Gazebo [releases] on [officially] supported platforms (Ubuntu).

> [!NOTE]
> There is a plan to implement this action for the [best-effort] supported platforms.
`setup-gazebo` action works for all non-EOL Gazebo [releases] on the following platforms:
- Ubuntu
- macOS

## Tasks performed by the action

The `setup-gazebo` action performs the following tasks on an Ubuntu system:
- Installs `sudo` in case it is missing
- Sets the locale to `en_US.UTF-8` and timezone to `UTC`
- Install necessary APT packages
- Registers the Open Robotics APT repository
The `setup-gazebo` action performs the following tasks:
- On Ubuntu:
- Installs `sudo` in case it is missing
- Sets the locale to `en_US.UTF-8` and timezone to `UTC`
- Install necessary APT packages
- Registers the Open Robotics APT repository
- On macOS:
- Tapping into OSRF repository using Homebrew

## Usage

Expand Down Expand Up @@ -131,7 +134,6 @@ This workflow shows how to use binaries from [pre-release] or [nightly] Gazebo r
```yaml
jobs:
test_gazebo:
name: 'Check installation of Gazebo nightly binary on Ubuntu'
runs-on: ubuntu-latest
container:
image: ubuntu:noble
Expand All @@ -150,6 +152,26 @@ This workflow shows how to use binaries from [pre-release] or [nightly] Gazebo r
run: 'gz sim --versions'
```

### Setting up worker to install Gazebo on macOS

This workflow shows how to install Gazebo on a macOS worker. The action needs an input for `required-gazebo-distributions` parameter.

```yaml
test_gazebo:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.2
with:
node-version: '20.x'
- name: 'Check Gazebo installation on MacOS runner'
uses: gazebo-tooling/setup-gazebo@<full_commit_hash>
with:
required-gazebo-distributions: 'harmonic'
- name: 'Test Gazebo installation'
run: 'gz sim --versions'
```

## License

The scripts and documentation in this project are released under the [Apache 2](LICENSE) license.
Expand Down
13 changes: 13 additions & 0 deletions __test__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from "@actions/core";
import * as exec from "@actions/exec";

import * as linux from "../src/setup-gazebo-linux";
import * as macOs from "../src/setup-gazebo-macos";
import * as utils from "../src/utils";

describe("workflow test without input", () => {
Expand All @@ -16,6 +17,10 @@ describe("workflow test without input", () => {
it("run Linux workflow without input", async () => {
await expect(linux.runLinux()).rejects.toThrow();
});

it("run macOS workflow without input", async () => {
await expect(macOs.runMacOs()).rejects.toThrow();
});
});

describe("workflow test with a invalid distro input", () => {
Expand All @@ -31,6 +36,10 @@ describe("workflow test with a invalid distro input", () => {
it("run Linux workflow with invalid distro input", async () => {
await expect(linux.runLinux()).rejects.toThrow();
});

it("run macOS workflow with invalid distro input", async () => {
await expect(macOs.runMacOs()).rejects.toThrow();
});
});

describe("workflow test with a valid distro input", () => {
Expand All @@ -46,6 +55,10 @@ describe("workflow test with a valid distro input", () => {
it("run Linux workflow with valid distro input", async () => {
await expect(linux.runLinux()).resolves.not.toThrow();
});

it("run macOS workflow with valid distro input", async () => {
await expect(macOs.runMacOs()).resolves.not.toThrow();
});
});

describe("validate distribution test", () => {
Expand Down
140 changes: 133 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26200,12 +26200,7 @@ const aptCommandLine = [
*
* This invokation guarantees that APT install will be non-blocking.
*
* In particular, it automatically accepts the RTI Connext license, which would block forever otherwise.
* Skipping the license agreement page requires RTI_NC_LICENSE_ACCEPTED to be set to "yes".
* This package would normally be installed automatically by rosdep, but
* there is no way to pass RTI_NC_LICENSE_ACCEPTED through rosdep.
*
* @param packages list of Debian pacakges to be installed
* @param packages list of Debian pacakges to be installed
* @returns Promise<number> exit code
*/
function runAptGetInstall(packages) {
Expand All @@ -26216,6 +26211,62 @@ function runAptGetInstall(packages) {
exports.runAptGetInstall = runAptGetInstall;


/***/ }),

/***/ 9586:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.runBrew = void 0;
const utils = __importStar(__nccwpck_require__(1314));
/**
* Run brew install on a list of specified packages.
*
* @param packages list of Homebrew packages to be installed
* @returns Promise<number> exit code
*/
function runBrew(packages) {
return __awaiter(this, void 0, void 0, function* () {
return utils.exec("brew", ["install"].concat(packages));
});
}
exports.runBrew = runBrew;


/***/ }),

/***/ 5467:
Expand Down Expand Up @@ -26367,6 +26418,71 @@ function runLinux() {
exports.runLinux = runLinux;


/***/ }),

/***/ 8247:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.runMacOs = void 0;
const utils = __importStar(__nccwpck_require__(1314));
const brew = __importStar(__nccwpck_require__(9586));
/**
* Tap into OSRF repository
*/
function addBrewRepo() {
return __awaiter(this, void 0, void 0, function* () {
yield utils.exec("brew", ["tap", "osrf/simulation"]);
});
}
/**
* Install Gazebo on MacOS worker
*/
function runMacOs() {
return __awaiter(this, void 0, void 0, function* () {
yield addBrewRepo();
for (const gazeboDistro of utils.getRequiredGazeboDistributions()) {
yield brew.runBrew([`gz-${gazeboDistro}`]);
}
});
}
exports.runMacOs = runMacOs;


/***/ }),

/***/ 525:
Expand Down Expand Up @@ -26409,10 +26525,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const linux = __importStar(__nccwpck_require__(5467));
const macOs = __importStar(__nccwpck_require__(8247));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
linux.runLinux();
const platform = process.platform;
if (platform === "darwin") {
macOs.runMacOs();
}
else if (platform === "linux") {
linux.runLinux();
}
else {
throw new Error(`Unsupported platform ${platform}`);
}
}
catch (error) {
let errorMessage = "Unknown error";
Expand Down
7 changes: 1 addition & 6 deletions src/package_manager/apt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ const aptCommandLine: string[] = [
*
* This invokation guarantees that APT install will be non-blocking.
*
* In particular, it automatically accepts the RTI Connext license, which would block forever otherwise.
* Skipping the license agreement page requires RTI_NC_LICENSE_ACCEPTED to be set to "yes".
* This package would normally be installed automatically by rosdep, but
* there is no way to pass RTI_NC_LICENSE_ACCEPTED through rosdep.
*
* @param packages list of Debian pacakges to be installed
* @param packages list of Debian pacakges to be installed
* @returns Promise<number> exit code
*/
export async function runAptGetInstall(packages: string[]): Promise<number> {
Expand Down
11 changes: 11 additions & 0 deletions src/package_manager/brew.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as utils from "../utils";

/**
* Run brew install on a list of specified packages.
*
* @param packages list of Homebrew packages to be installed
* @returns Promise<number> exit code
*/
export async function runBrew(packages: string[]): Promise<number> {
return utils.exec("brew", ["install"].concat(packages));
}
20 changes: 20 additions & 0 deletions src/setup-gazebo-macos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as utils from "./utils";
import * as brew from "./package_manager/brew";

/**
* Tap into OSRF repository
*/
async function addBrewRepo() {
await utils.exec("brew", ["tap", "osrf/simulation"]);
}

/**
* Install Gazebo on MacOS worker
*/
export async function runMacOs() {
await addBrewRepo();

for (const gazeboDistro of utils.getRequiredGazeboDistributions()) {
await brew.runBrew([`gz-${gazeboDistro}`]);
}
}
10 changes: 9 additions & 1 deletion src/setup-gazebo.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import * as core from "@actions/core";
import * as linux from "./setup-gazebo-linux";
import * as macOs from "./setup-gazebo-macos";

async function run() {
try {
linux.runLinux();
const platform = process.platform;
if (platform === "darwin") {
macOs.runMacOs();
} else if (platform === "linux") {
linux.runLinux();
} else {
throw new Error(`Unsupported platform ${platform}`);
}
} catch (error) {
let errorMessage = "Unknown error";
if (error instanceof Error) {
Expand Down