-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
137 lines (133 loc) · 6.35 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: 'Setup Webots'
description: 'Installs Webots on the runner'
inputs:
webotsVersion:
description: "Version of Webots to install."
required: true
webotsTag:
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/<webotsRepository>/releases/download/<webotsTag>)"
required: false
default: ''
outputs:
bashCmd:
description: "Start of a command line in bash which will run webots on all runners with options suitable for headless execution. This is also put in the RUN_WEBOTS environment variable."
value: ${{ steps.setup.outputs.bashCmd }}
cachePath:
description: "Path to cache."
value: ${{ steps.setup.outputs.cachePath }}
home:
description: "Path of the Webots installation, suitable for putting in WEBOTS_HOME environment variable"
value: ${{ steps.setup.outputs.home }}
binDir:
description: "Directory containing the Webots executable, suitable for adding to the PATH environment variable"
value: ${{ steps.setup.outputs.binDir }}
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 }}
baseUrl:
description: "The location of the Webots release being used"
value: ${{ steps.setup.outputs.baseUrl }}
runs:
using: 'composite'
steps:
- name: Setup Webots Environment
id: setup
run: |
webotsOptions="--no-rendering --stdout --stderr --minimize --batch"
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/$webotsRepository/releases/download/$webotsTag"
fi
if [ '${{ runner.os }}' = 'Linux' ]; then
webotsCachePath="$HOME/cache/webots"
webotsHome="$HOME/webots"
webotsBinDir="${webotsHome}"
webotsBin="${webotsBinDir}/webots"
webotsBashCmd="xvfb-run -a ${webotsBin} ${webotsOptions}"
pkgName=webots-${{ inputs.webotsVersion }}-x86-64.tar.bz2
elif [ '${{ runner.os }}' = 'Windows' ]; then
webotsCachePath="${USERPROFILE}/cache/webots"
webotsHome="${LOCALAPPDATA}/Programs/Webots"
webotsBinDir="${webotsHome}/msys64/mingw64/bin"
webotsBin="${webotsBinDir}/webots"
webotsBashCmd="${webotsBin} ${webotsOptions}"
echo "MESA_GL_VERSION_OVERRIDE=3.3" >> $GITHUB_ENV
pkgName=webots-${{ inputs.webotsVersion }}_setup.exe
elif [ '${{ runner.os }}' = 'macOS' ]; then
webotsCachePath="$HOME/cache/webots"
webotsHome="$HOME/Applications/Webots.app/Contents/MacOS"
webotsBinDir="${webotsHome}"
webotsBin="${webotsBinDir}/webots"
webotsBashCmd="${webotsBin} ${webotsOptions}"
pkgName=webots-${{ inputs.webotsVersion }}.dmg
else
echo "Unrecognized runner OS"
exit -1
fi
echo "bashCmd=$webotsBashCmd" >> $GITHUB_OUTPUT
echo "cachePath=${webotsCachePath}" >> $GITHUB_OUTPUT
echo "home=${webotsHome}" >> $GITHUB_OUTPUT
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
echo "WEBOTS_DISABLE_SAVE_SCREEN_PERSPECTIVE_ON_CLOSE=true" >> $GITHUB_ENV
shell: bash
- name: Cache Webots
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.setup.outputs.cachePath }}
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 "${{ 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
shell: bash
- name: Install Webots
run: |
cachedWebotsBin="${{ steps.setup.outputs.cachePath }}/${{ steps.setup.outputs.pkgName }}"
if [ '${{ runner.os }}' = 'Linux' ]; then
sudo apt update
sudo apt-get install lsb-release g++ make libavcodec-extra libglu1-mesa libxkbcommon-x11-dev execstack libusb-dev libxcb-keysyms1 libxcb-image0 libxcb-icccm4 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcomposite-dev libxtst6 libnss3 libegl1 libqt5gui5
tar xjf $cachedWebotsBin -C "$HOME"
chmod +x "${{ steps.setup.outputs.bin }}"
elif [ '${{ runner.os }}' = 'Windows' ]; then
"$cachedWebotsBin" //VERYSILENT //SP- //SUPPRESSMSGBOXES //CURRENTUSER
7z e -o${LOCALAPPDATA}/Programs/Webots/msys64/mingw64/bin "${{ steps.setup.outputs.cachePath }}/Mesa.7z"
elif [ '${{ runner.os }}' = 'macOS' ]; then
mkdir ~/Mount
mkdir -p ~/Applications
hdiutil attach $cachedWebotsBin -noverify -mountpoint ~/Mount
cp -R ~/Mount/Webots.app ~/Applications
hdiutil detach ~/Mount
rmdir ~/Mount
else
echo "Unrecognized runner OS"
exit -1
fi
shell: bash