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

Add support for arbitrary base URL to fix #9. #10

Merged
merged 9 commits into from
Jul 29, 2024
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
include:
- webotsVersion: R2024a
webotsTag: nightly_26_7_2024
- webotsVersion: R2024a
webotsBaseUrl: https://github.com/DeepBlueRobotics/webots/releases/download/R2024a_DeepBlueSim_2024_07_28
runs-on: ${{ matrix.os }}

steps:
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 Webots repository (such as a nightly build).
Alternatively, the `webotsTag` option can be used to install a specific tag from the official Webots repository (such as a nightly build).

``` YAML
- name: Setup Webots
Expand All @@ -29,6 +29,23 @@ 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.

``` YAML
- name: Setup Webots
id: setupWebots
uses: DeepBlueRobotics/setup-webots@main
with:
webotsVersion: R2024a # Set this to your Webots version
webotsBaseUrl: https://github.com/DeepBlueRobotics/webots/releases/download/R2024a_DeepBlueSim_2024_07_28

- name: Run Webots
run: $RUN_WEBOTS /path/to/worlds/MyWorld.wbt
shell: bash
```

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
18 changes: 15 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
description: "Optionally specify a specific tag from the Webots repository to install. (Defaults to webotsVersion)"
required: false
default: ''
webotsBaseUrl:
description: "Optionally specify a base URL containing the distribution files (Defaults to https://github.com/cyberbotics/webots/releases/download/<webotsTag>)"
required: false
default: ''
CoolSpy3 marked this conversation as resolved.
Show resolved Hide resolved

outputs:
bashCmd:
Expand Down Expand Up @@ -41,6 +45,14 @@ runs:
else
webotsTag=${{ inputs.webotsVersion }}
fi
if [ -n '${{ inputs.webotsBaseUrl }}' ]; then
if [ -n '${{ inputs.webotsTag }}' ]; then
echo "WARNING: Ignoring webotsTag=${{ inputs.webotsTag }} because webotsBaseUrl was specified."
fi
webotsBaseUrl=${{ inputs.webotsBaseUrl }}
else
webotsBaseUrl='https://github.com/cyberbotics/webots/releases/download/${{ inputs.webotsTag }}'
CoolSpy3 marked this conversation as resolved.
Show resolved Hide resolved
fi
if [ '${{ runner.os }}' = 'Linux' ]; then
webotsCachePath="$HOME/cache/webots"
webotsHome="$HOME/webots"
Expand Down Expand Up @@ -73,7 +85,7 @@ runs:
echo "binDir=${webotsBinDir}" >> $GITHUB_OUTPUT
echo "bin=${webotsBin}" >> $GITHUB_OUTPUT
echo "pkgName=$pkgName" >> $GITHUB_OUTPUT
echo "tag=$webotsTag" >> $GITHUB_OUTPUT
echo "baseUrl=$webotsBaseUrl" >> $GITHUB_OUTPUT
CoolSpy3 marked this conversation as resolved.
Show resolved Hide resolved
echo "RUN_WEBOTS=$webotsBashCmd" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_SOFTWARE=true" >> $GITHUB_ENV
echo "WEBOTS_DISABLE_SAVE_SCREEN_PERSPECTIVE_ON_CLOSE=true" >> $GITHUB_ENV
Expand All @@ -83,12 +95,12 @@ runs:
id: cache
with:
path: ${{ steps.setup.outputs.cachePath }}
key: ${{ runner.os }}-webots-${{ steps.setup.outputs.tag }}
key: ${{ runner.os }}-webots-${{ steps.setup.outputs.baseUrl }}
save-always: true
- name: 'Download Webots'
if: steps.cache.outputs.cache-hit != 'true'
run: |
curl -L -o "${{ steps.setup.outputs.cachePath }}/${{ steps.setup.outputs.pkgName }}" --create-dirs "https://github.com/cyberbotics/webots/releases/download/${{ steps.setup.outputs.tag }}/${{ steps.setup.outputs.pkgName }}"
curl -L -o "${{ steps.setup.outputs.cachePath }}/${{ steps.setup.outputs.pkgName }}" --create-dirs "${{ steps.setup.outputs.baseUrl }}/${{ steps.setup.outputs.pkgName }}"
if [ '${{ runner.os }}' = 'Windows' ]; then
curl -L -o "${{ steps.setup.outputs.cachePath }}/Mesa.7z" --create-dirs https://downloads.fdossena.com/geth.php?r=mesa64-latest
fi
Expand Down
Loading