Add CI job for running unit tests #655
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: Roblox/setup-foreman@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Lint | |
run: | | |
selene generate-roblox-std | |
selene src/ | |
- name: Format | |
run: stylua --check src/ | |
- name: Install dependencies | |
run: wally install | |
- name: Get model file name | |
run: | | |
name=$(jq -r .name default.project.json) | |
sha=${GITHUB_SHA:0:7} | |
echo "MODEL_FILE=$name-$sha.rbxm" >> $GITHUB_ENV | |
- name: Build | |
run: rojo build -o ${{ env.MODEL_FILE }} | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.MODEL_FILE }} | |
path: ${{ env.MODEL_FILE }} | |
analyze: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: Roblox/setup-foreman@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install dependencies | |
run: wally install | |
- name: Download global Roblox types | |
shell: bash | |
run: curl -s -O https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/master/scripts/globalTypes.d.lua | |
- name: Generate sourcemap for LSP | |
shell: bash | |
run: rojo sourcemap dev.project.json -o sourcemap.json | |
- name: Analyze | |
shell: bash | |
run: luau-lsp analyze --sourcemap=sourcemap.json --defs=globalTypes.d.lua --defs=testez.d.lua --ignore=**/_Index/** src/ | |
scripts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Ensure each script is executable | |
run: | | |
for f in ./bin/*; do | |
if [[ ! -x "$f" ]]; then | |
echo "Script '$f' is not executable" | |
exit 1 | |
fi | |
done | |
tests: | |
runs-on: windows-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check for ROBLOSECURITY secret | |
shell: bash | |
run: ./.github/workflows/validate-secret.sh ROBLOSECURITY "${{ secrets.ROBLOSECURITY }}" | |
- name: Check for MULLVAD_ACCOUNT secret | |
shell: bash | |
run: ./.github/workflows/validate-secret.sh MULLVAD_ACCOUNT "${{ secrets.MULLVAD_ACCOUNT }}" | |
- uses: Roblox/setup-foreman@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install dependencies | |
run: wally install | |
- name: Build place file | |
run: rojo build dev.project.json -o studio-tests.rbxl | |
- name: Install Mullvad | |
run: choco install mullvad-app | |
- name: Update path with Mullvad executable | |
shell: bash | |
run: | | |
BIN="/c/Program Files/Mullvad VPN/resources" | |
echo "$BIN" >> $GITHUB_PATH | |
- name: Login to Mullvad account | |
shell: bash | |
run: mullvad account login ${{ secrets.MULLVAD_ACCOUNT }} | |
- name: Set server to connect to | |
shell: bash | |
run: mullvad relay set location us-sjc-wg-001 | |
- name: Export IP before connecting to VPN | |
shell: bash | |
run: | | |
ip=$(curl -s https://httpbin.org/ip | jq -r .origin) | |
echo "Current IP address: $ip" | |
echo "RUNNER_IP=$ip" >> $GITHUB_ENV | |
- name: Connect to VPN | |
shell: bash | |
run: mullvad connect | |
- name: Export device name | |
shell: bash | |
run: | | |
deviceName=$(mullvad account get | grep "Device name" | cut -d : -f 2 | xargs) | |
echo "Device name: $deviceName" | |
echo "DEVICE_NAME=$deviceName" >> $GITHUB_ENV | |
- name: Poll for IP change | |
uses: nick-fields/[email protected] | |
with: | |
max_attempts: 5 | |
timeout_minutes: 2 | |
retry_wait_seconds: 2 | |
shell: bash | |
command: | | |
ip=$(curl -s https://httpbin.org/ip | jq -r .origin) | |
echo "Original IP: ${{ env.RUNNER_IP }}" | |
echo "Current IP: $ip" | |
if [[ $ip != "" && "${{ env.RUNNER_IP }}" != "$ip" ]]; then | |
echo "IP changed, assuming we're connected now to the VPN" | |
exit 0 | |
else | |
echo "IP has not changed yet. Retrying...." | |
exit 1 | |
fi | |
- name: Log Mullvad status | |
shell: bash | |
run: mullvad status -v | |
- name: List tokens | |
shell: bash | |
run: cmdkey /list:"LegacyGeneric:target=https://www.roblox.com:RobloxStudioAuth*" | |
- name: Set .ROBLOSECURITY token | |
# shell: bash | |
run: cmdkey /generic:"LegacyGeneric:target=https://www.roblox.com:RobloxStudioAuth.ROBLOSECURITY" /user:"Roblox" /pass:"${{ secrets.ROBLOSECURITY }}" | |
- name: Set Cookies token | |
# shell: bash | |
run: cmdkey /generic:"LegacyGeneric:target=https://www.roblox.com:RobloxStudioAuthCookies" /user:"Roblox" /pass:".ROBLOSECURITY" | |
- name: List tokens | |
shell: bash | |
run: cmdkey /list:"LegacyGeneric:target=https://www.roblox.com:RobloxStudioAuth*" | |
- uses: actions/checkout@v3 | |
with: | |
repository: vocksel/roblox-win-installer | |
path: roblox-win-installer | |
- name: Install Roblox Studio | |
shell: bash | |
run: | | |
cd roblox-win-installer | |
pip install --requirement requirements.txt; | |
python install.py "${{ secrets.ROBLOSECURITY }}" | |
- name: Create flag overrides for successful login | |
run: | | |
$flags = @{FFlagSTUDIOPLAT31379MultiAccountCookies3=$true; FLogAuthTokenManager=$true; FLogKeyValueStorage=$true; FLogError=$true; FLogMultiUserKeyValueStorage=$true} | |
New-Item -Path 'C:/Program Files (x86)/Roblox/Versions/version-*/' -Name "ClientSettings" -ItemType "directory" | |
New-Item -Path 'C:/Program Files (x86)/Roblox/Versions/version-*/ClientSettings' -Name "ClientAppSettings.json" | |
$flags | ConvertTo-Json -depth 32| set-content -Path 'C:/Program Files (x86)/Roblox/Versions/version-*/ClientSettings/ClientAppSettings.json' | |
- name: Run tests | |
run: run-in-roblox --place studio-tests.rbxl --script tests/init.server.lua | |
- name: Disconnect from VPN | |
if: always() | |
shell: bash | |
run: | | |
mullvad disconnect | |
mullvad account revoke-device "${{ env.DEVICE_NAME }}" | |
- name: Dump logs | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: studio-logs | |
path: | | |
~/AppData/Local/Roblox/logs/**/* | |
- name: Upload screenshot | |
if: failure() | |
uses: OrbitalOwen/[email protected] | |
with: | |
file-name: 'roblox-studio-${{ github.run_id }}.jpg' |