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

Simplify Workflow When Using a Custom GitHub Repository #11

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,30 @@ jobs:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
webotsVersion: [ R2023b, R2024a ]
webotsTag: [ nightly_26_7_2024, '' ]
webotsTag: [ R2024a_DeepBlueSim_2024_07_28, nightly_26_7_2024, '' ]
webotsRepository: [ DeepBlueRobotics/webots, '' ]
webotsBaseUrl: [ 'https://github.com/DeepBlueRobotics/webots/releases/download/R2024a_DeepBlueSim_2024_07_28', '' ]
exclude:
# R2024a has not yet been released
- webotsVersion: R2024a
webotsTag: ''
webotsBaseUrl: ''
# cyberbots/webots#6586
- webotsVersion: R2024a
webotsTag: nightly_26_7_2024
os: windows-latest
# Only use tags on their corresponding repositories
- webotsTag: R2024a_DeepBlueSim_2024_07_28
webotsRepository: ''
- webotsTag: 'nightly_26_7_2024'
webotsRepository: DeepBlueRobotics/webots
- webotsTag: ''
webotsRepository: DeepBlueRobotics/webots
# R2023b Should only be run with default parameters
- webotsVersion: R2023b
webotsTag: nightly_26_7_2024
- webotsVersion: R2023b
webotsRepository: DeepBlueRobotics/webots
- webotsVersion: R2023b
webotsBaseUrl: 'https://github.com/DeepBlueRobotics/webots/releases/download/R2024a_DeepBlueSim_2024_07_28'
runs-on: ${{ matrix.os }}
Expand All @@ -37,6 +50,7 @@ jobs:
with:
webotsVersion: ${{ matrix.webotsVersion }}
webotsTag: ${{ matrix.webotsTag || '' }}
webotsRepository: ${{ matrix.webotsRepository || '' }}
webotsBaseUrl: ${{ matrix.webotsBaseUrl || '' }}

- name: Run Webots
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
Loading