Skip to content

Commit

Permalink
(MINOR) simplify workflow when using a custom github repository
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolSpy3 committed Jul 29, 2024
1 parent d0035bd commit 6ad60bb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
include:
- webotsVersion: R2024a
webotsTag: nightly_26_7_2024
- webotsVersion: R2024a
webotsTag: R2024a_DeepBlueSim_2024_07_28
webotsRepository: DeepBlueRobotics/webots
- webotsVersion: R2024a
webotsBaseUrl: https://github.com/DeepBlueRobotics/webots/releases/download/R2024a_DeepBlueSim_2024_07_28
runs-on: ${{ matrix.os }}
Expand Down
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

This GitHub action can be used in a [GitHub workflow](https://docs.github.com/en/free-pro-team@latest/actions) to setup a version of [Webots](https://cyberbotics.com/) on ubuntu-latest, windows-latest, or macos-latest GitHub-hosted runner. Usage:

## Installing Webots

### Install a Stable Webots Release
``` YAML
- name: Setup Webots
id: setupWebots
Expand All @@ -14,8 +17,7 @@ This GitHub action can be used in a [GitHub workflow](https://docs.github.com/en
shell: bash
```
Alternatively, the `webotsTag` option can be used to install a specific tag from the official Webots repository (such as a nightly build).

### Install a Nightly Prerelease from the Official Webots Repository
``` YAML
- name: Setup Webots
id: setupWebots
Expand All @@ -29,9 +31,24 @@ Alternatively, the `webotsTag` option can be used to install a specific tag from
shell: bash
```
Alternatively, the `webotsBaseUrl` option can be used to install from an arbitrary location (such as
a fork of the official repo). Note that if you use the `webotsBaseUrl` option, the `webotsTag`
option will be ignored, so the URL should contain any needed tag information.
### Install a Custom Release from a Webots Fork
``` YAML
- name: Setup Webots
id: setupWebots
uses: DeepBlueRobotics/setup-webots@main
with:
webotsVersion: R2024a # Set this to your Webots version
webotsTag: R2024a_DeepBlueSim_2024_07_28
webotsRepository: DeepBlueRobotics/webots

- name: Run Webots
run: $RUN_WEBOTS /path/to/worlds/MyWorld.wbt
shell: bash
```
### Install a Custom Release from an Arbitrary URL
Note that if you use the `webotsBaseUrl` option, the `webotsTag` and `webotsRepository` options
will be ignored, so the URL should contain any needed tag information.

``` YAML
- name: Setup Webots
Expand All @@ -46,6 +63,7 @@ option will be ignored, so the URL should contain any needed tag information.
shell: bash
```

## Running Webots
In a step that uses the `bash` shell, `$RUN_WEBOTS` will expand to the start of a command line that will start Webots on any of the aforementioned runners with the `--no-rendering --stdout --stderr --minimize --batch` options. Those options allow Webots to run in a headless environment and redirect the controller's output/error to stdout/stderr.

Note:
Expand Down
23 changes: 15 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ inputs:
description: "Version of Webots to install."
required: true
webotsTag:
description: "Optionally specify a specific tag from the Webots repository to install. (Defaults to webotsVersion)"
description: "Optionally specify a specific tag from the Webots repository to install. (Defaults to <webotsVersion>)"
required: false
default: ''
webotsRepository:
description: "Optionally specify a specific repository to download Webots from (Defaults to cyberbotics/webots)"
required: false
default: ''
webotsBaseUrl:
description: "Optionally specify a base URL containing the distribution files (Defaults to https://github.com/cyberbotics/webots/releases/download/<webotsTag>)"
description: "Optionally specify a base URL containing the distribution files (Defaults to https://github.com/<webotsRepository>/releases/download/<webotsTag>)"
required: false
default: ''

Expand Down Expand Up @@ -40,19 +44,21 @@ runs:
id: setup
run: |
webotsOptions="--no-rendering --stdout --stderr --minimize --batch"
if [ -n '${{ inputs.webotsTag }}' ]; then
webotsTag=${{ inputs.webotsTag }}
else
webotsTag=${{ inputs.webotsVersion }}
fi
webotsTag=${{ inputs.webotsTag || inputs.webotsVersion }}
webotsRepository=${{ inputs.webotsRepository || 'cyberbotics/webots' }}
if [ -n '${{ inputs.webotsBaseUrl }}' ]; then
if [ -n '${{ inputs.webotsTag }}' ]; then
echo "WARNING: Ignoring webotsTag=${{ inputs.webotsTag }} because webotsBaseUrl was specified."
fi
if [ -n '${{ inputs.webotsRepository }}' ]; then
echo "WARNING: Ignoring webotsRepository=${{ inputs.webotsRepository }} because webotsBaseUrl was specified."
fi
webotsBaseUrl=${{ inputs.webotsBaseUrl }}
else
webotsBaseUrl="https://github.com/cyberbotics/webots/releases/download/$webotsTag"
webotsBaseUrl="https://github.com/$webotsRepository/releases/download/$webotsTag"
fi
if [ '${{ runner.os }}' = 'Linux' ]; then
webotsCachePath="$HOME/cache/webots"
webotsHome="$HOME/webots"
Expand Down Expand Up @@ -85,6 +91,7 @@ runs:
echo "binDir=${webotsBinDir}" >> $GITHUB_OUTPUT
echo "bin=${webotsBin}" >> $GITHUB_OUTPUT
echo "pkgName=$pkgName" >> $GITHUB_OUTPUT
echo "cacheKey=$cacheKey" >> $GITHUB_OUTPUT
echo "baseUrl=$webotsBaseUrl" >> $GITHUB_OUTPUT
echo "RUN_WEBOTS=$webotsBashCmd" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_SOFTWARE=true" >> $GITHUB_ENV
Expand Down

0 comments on commit 6ad60bb

Please sign in to comment.