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
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ jobs:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
webotsVersion: [ R2023b, R2024a ]
include:
webotsTag: [ nightly_26_7_2024, '' ]
webotsBaseUrl: [ 'https://github.com/DeepBlueRobotics/webots/releases/download/R2024a_DeepBlueSim_2024_07_28', '' ]
exclude:
- webotsVersion: R2024a
webotsTag: ''
webotsBaseUrl: ''
- webotsVersion: R2024a
webotsTag: nightly_26_7_2024
os: windows-latest
- webotsVersion: R2023b
webotsTag: nightly_26_7_2024
- webotsVersion: R2023b
webotsBaseUrl: 'https://github.com/DeepBlueRobotics/webots/releases/download/R2024a_DeepBlueSim_2024_07_28'
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -27,6 +37,7 @@ jobs:
with:
webotsVersion: ${{ matrix.webotsVersion }}
webotsTag: ${{ matrix.webotsTag || '' }}
webotsUrl: ${{ matrix.webotsUrl || '' }}
brettle marked this conversation as resolved.
Show resolved Hide resolved

- name: Run Webots
run: $RUN_WEBOTS --sysinfo
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
24 changes: 18 additions & 6 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 All @@ -25,9 +29,9 @@ outputs:
bin:
description: "Full path to the Webots executable, suitable for running webots directly (albeit probably not succesfully, that's what bashCmd or $RUN_WEBOTS is for)"
value: ${{ steps.setup.outputs.bin }}
tag:
description: "The git tag of the Webots release being used"
value: ${{ steps.setup.outputs.bin }}
baseUrl:
description: "The location of the Webots release being used"
value: ${{ steps.setup.outputs.baseUrl }}

runs:
using: 'composite'
Expand All @@ -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/$webotsTag"
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