Skip to content

Run Server Tests

Run Server Tests #15

name: Run Server Tests
on:
workflow_dispatch:
inputs:
os:
type: choice
options:
- windows
- ubuntu
required: true
jobs:
test:
name: Server Tests - ${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- os: ${{ github.event.inputs.os == 'windows' && 'windows-latest' || 'ubuntu-24.04' }}
steps:
- name: Set Initial Workflow Status
run: echo "WORKFLOW_STATUS=success" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
- name: Download Pragma (Windows)
if: runner.os == 'Windows'
run: |
$repo = $env:GITHUB_REPOSITORY
Invoke-WebRequest -Uri "https://github.com/$repo/releases/download/nightly/pragma-win64.zip" -OutFile "pragma-win64.zip"
Expand-Archive -Path "pragma-win64.zip" -DestinationPath "pragma"
- name: Download Pragma (Linux)
if: runner.os == 'Linux'
run: |
wget https://github.com/$GITHUB_REPOSITORY/releases/download/nightly/pragma-lin64.tar.gz
mkdir pragma
tar -xzvf pragma-lin64.tar.gz -C pragma
- name: Run Test Scripts
shell: bash
run: |
cd "pragma"
if [ "$RUNNER_OS" == "Linux" ]; then
./pragma_server -luaext -log 2 2 +map "test_physics" +"lua_exec tests/ci_runner_tests.lua"
else
./pragma_server.exe -luaext -log 2 2 +map "test_physics" +"lua_exec tests/ci_runner_tests.lua"
fi
EXIT_CODE=$?
# Check the exit code
if [ $EXIT_CODE -eq 0 ]; then
echo "Tests were successful."
else
echo "Tests have failed with exit code $EXIT_CODE."
exit 1 # Exit the step with an error status
fi
- name: Check Result
shell: bash
run: |
CI_CONTENTS=$(cat "pragma/ci.txt")
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
if [ "$CI_CONTENTS" == "0" ]; then
echo "ci.txt contains '0'. Step failed."
exit 1
fi
- name: Upload Log
uses: actions/upload-artifact@v4
if: always()
with:
name: log_server
path: "pragma/log_server.txt"
- name: Upload Crashdumps
uses: actions/upload-artifact@v4
if: always()
with:
name: crashdumps
path: "pragma/crashdumps"
- name: Set Failure Workflow Status
if: failure()
run: echo "WORKFLOW_STATUS=failure" >> $GITHUB_ENV
- name: Set Failure Workflow Status
if: always()
shell: bash
run: |
echo "WORKFLOW_STATUS=failure" >> $GITHUB_ENV
- uses: LouisBrunner/checks-action@v2.0.0
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ env.WORKFLOW_STATUS }}
name: "Server Tests - ${{ matrix.config.os }}"
output: |
{"summary":"Test result is '${{ env.WORKFLOW_STATUS }}'."}