CI Workflow Refactor and Fixes #825
Workflow file for this run
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: C/C++ CI | |
on: | |
push: | |
branches: [master] | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
types: [opened, reopened, synchronize] | |
release: | |
types: [published] | |
jobs: | |
windows: | |
name: 'Windows' | |
runs-on: windows-2019 | |
env: | |
solution: 'msvc/ReGameDLL.sln' | |
buildPlatform: 'Win32' | |
buildRelease: 'Release' | |
buildReleasePlay: 'Release Play' | |
buildTests: 'Tests' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v2 | |
with: | |
vs-version: '16' | |
- name: Build and Run unittests | |
run: | | |
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTests }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false | |
.\"msvc\Tests\mp.exe" | |
If ($LASTEXITCODE -ne 0 -And | |
$LASTEXITCODE -ne 3) | |
{[Environment]::Exit(1)} | |
shell: "pwsh" | |
- name: Build | |
run: | | |
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false | |
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildReleasePlay }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false | |
- name: Move files | |
run: | | |
mkdir publish\debug | |
mkdir publish\tests | |
mkdir publish\bin\win32\cstrike\dlls | |
move "msvc\${{ env.buildReleasePlay }}\mp.dll" publish\tests\mp.dll | |
move msvc\${{ env.buildRelease }}\mp.dll publish\bin\win32\cstrike\dlls\mp.dll | |
move msvc\${{ env.buildRelease }}\mp.pdb publish\debug\mp.pdb | |
- name: Deploy artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: win32 | |
path: publish/* | |
testdemos: | |
name: 'Test demos' | |
runs-on: ubuntu-latest | |
container: rehldsorg/testdemos:latest | |
needs: [windows] | |
defaults: | |
run: | |
shell: bash | |
working-directory: /opt/HLDS | |
strategy: | |
fail-fast: false | |
matrix: | |
test: [ | |
{ file: 'cstrike-basic-1', desc: 'CS: Testing jumping, scenarios, shooting etc' }, | |
] | |
steps: | |
- name: Deploying windows artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: win32 | |
- name: Setup dependencies | |
run: | | |
chown root ~ | |
rsync -a deps/regamedll/* . | |
mv $GITHUB_WORKSPACE/tests/mp.dll cstrike/dlls/mp.dll | |
- name: Play test | |
env: | |
demo: ${{ matrix.test.file }} | |
desc: ${{ matrix.test.desc }} | |
run: ./runTest.sh | |
linux: | |
name: 'Linux' | |
runs-on: ubuntu-latest | |
container: debian:11-slim | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: | | |
dpkg --add-architecture i386 | |
apt-get update | |
apt-get install -y \ | |
gcc-multilib g++-multilib \ | |
build-essential \ | |
libc6-dev libc6-dev-i386 \ | |
git cmake rsync \ | |
g++ gcc | |
- name: Build and Run unittests | |
run: | | |
rm -rf build && CC=gcc CXX=g++ cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8 | |
retVal=0 | |
./build/regamedll/cs 2> /dev/null > result.log || retVal=$? | |
while read line; do | |
if [[ ${line} == *"Warning in test"* ]] ; then | |
echo -e "\e[2;38m$line" | |
elif [[ ${line} == *"Failure in test"* ]] ; then | |
echo -e "\e[1;31m$line" | |
else | |
echo -e "\e[0;33m$line" | |
fi | |
done <<< $(cat result.log) | |
if [ $retVal -ne 0 ] && [ $retVal -ne 3 ]; then | |
echo -e "\e[30;41mExit code: $retVal\e[0m" | |
exit 1 # Unittest failed | |
else | |
echo -e "\e[30;43mExit code: $retVal\e[0m" | |
fi | |
shell: bash | |
- name: Build using GCC Compiler | |
run: | | |
rm -rf build && CC=gcc CXX=g++ cmake -B build && cmake --build build -j8 | |
- name: Prepare CSSDK | |
run: | | |
mkdir -p publish/cssdk | |
rsync -a regamedll/extra/cssdk/ publish/cssdk/ --exclude=.git --exclude=LICENSE --exclude=README.md | |
- name: Move files | |
run: | | |
mkdir -p publish/bin/linux32/cstrike/dlls | |
mv build/regamedll/cs.so publish/bin/linux32/cstrike/dlls/cs.so 2>/dev/null || true | |
mv regamedll/version/appversion.h publish/appversion.h | |
mv dist/ publish/ | |
- name: Run GLIBC/ABI version compat test | |
run: | | |
binaries=( | |
"publish/bin/linux32/cstrike/dlls/cs.so" | |
) | |
bash ./regamedll/version/glibc_test.sh ${binaries[@]} | |
if [[ $? -ne 0 ]]; then | |
exit 1 # Assertion failed | |
fi | |
shell: bash | |
- name: Deploy artifacts | |
uses: actions/upload-artifact@v4 | |
id: upload-job | |
with: | |
name: linux32 | |
path: publish/* | |
publish: | |
name: 'Publish' | |
runs-on: ubuntu-latest | |
needs: [windows, testdemos, linux] | |
steps: | |
- name: Deploying linux artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: linux32 | |
- name: Deploying windows artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: win32 | |
- name: Reading appversion.h | |
run: | | |
if [ -e appversion.h ]; then | |
APP_VERSION=$(cat appversion.h | grep -wi '#define APP_VERSION_STRD' | sed -e 's/#define APP_VERSION_STRD[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g') | |
if [ $? -ne 0 ]; then | |
APP_VERSION="" | |
else | |
# Remove quotes | |
APP_VERSION=$(echo $APP_VERSION | xargs) | |
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV | |
fi | |
fi | |
rm -f appversion.h | |
- name: Packaging binaries | |
id: packaging-job | |
if: | | |
github.event_name == 'release' && | |
github.event.action == 'published' && | |
startsWith(github.ref, 'refs/tags/') | |
run: | | |
rsync -a dist/ bin/win32/cstrike | |
rsync -a dist/ bin/linux32/cstrike | |
7z a -tzip regamedll-bin-${{ env.APP_VERSION }}.zip bin/ cssdk/ | |
- name: Publish artifacts | |
uses: softprops/action-gh-release@v2 | |
id: publish-job | |
if: | | |
startsWith(github.ref, 'refs/tags/') && | |
steps.packaging-job.outcome == 'success' | |
with: | |
files: | | |
*.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.API_TOKEN }} | |