Skip to content

Commit

Permalink
CI Workflow Refactor and Fixes (#1016)
Browse files Browse the repository at this point in the history
chore(ci): standardize and update CI workflows for compatibility and consistency

- Updated action versions (`checkout@v4`, `upload-artifact@v4`, `download-artifact@v4`) for enhanced compatibility and security
- Removed unsecure Node.js version allowance to align with *-latest OS requirements
- Migrated test demos to `rehldsorg/testdemos:latest` container with a streamlined testing approach via matrix strategy and `runTest.sh`
- Standardized Linux dependency installation for consistent build environment across jobs
- Unified CI workflow structure with `rehlds` and `regamedll` repositories for better consistency
- Optimized artifact deployment steps and removed unnecessary cleanup operations

Co-authored-by: s1lentq <[email protected]>
  • Loading branch information
SergeyShorokhov and s1lentq authored Oct 29, 2024
1 parent 535ea84 commit 7738142
Showing 1 changed file with 34 additions and 72 deletions.
106 changes: 34 additions & 72 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
with:
vs-version: '16.8'
vs-version: '16'

- name: Build and Run unittests
run: |
Expand All @@ -58,95 +58,68 @@ jobs:
move msvc\${{ env.buildRelease }}\mp.pdb publish\debug\mp.pdb
- name: Deploy artifacts
uses: actions/upload-artifact@v3.1.1
uses: actions/upload-artifact@v4
with:
name: win32
path: publish/*

testdemos:
name: 'Test demos'
runs-on: ubuntu-20.04
container: s1lentq/testdemos:latest
runs-on: ubuntu-latest
container: rehldsorg/testdemos:latest
needs: [windows]

env:
WINEDEBUG: -all
WINEDLLOVERRIDES: mshtml=
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

defaults:
run:
shell: bash
working-directory: ../../../opt/HLDS
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@v3
uses: actions/download-artifact@v4
with:
name: win32

- name: Play demos
- name: Setup dependencies
run: |
chown root ~
rsync -a deps/regamedll/* .
mv $GITHUB_WORKSPACE/tests/mp.dll cstrike/dlls/mp.dll
descs=(
"CS: Testing jumping, scenarios, shooting etc"
)
demos=(
"cstrike-basic-1"
)
retVal=0
for i in "${!demos[@]}"; do
params=$(cat "testdemos/${demos[i]}.params")
echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[0m"
echo -e " - \e[0;33mParameters $params\e[0m"
wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/${demos[i]}.bin" $params &> result.log || retVal=$?
if [ $retVal -ne 777 ] && [ $retVal -ne 9 ]; then
# Print with catchy messages
while read line; do
echo -e " \e[0;33m$line"
done <<< $(cat result.log | sed '0,/demo failed/I!d;/wine:/d;/./,$!d')
echo " 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸"
while read line; do
echo -e " \e[1;31m$line";
done < rehlds_demo_error.txt
echo -e " \e[30;41mExit code: $retVal\e[0m"
echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;31m Failed ❌"
exit 6 # Test demo failed
else
# Print result HLDS console
while read line; do
echo -e " \e[0;33m$line"
done <<< $(cat result.log | sed '/wine:/d;/./,$!d')
echo -e " \e[30;43mExit code: $retVal\e[0m"
echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;32m Succeed ✔"
fi
done
- name: Play test
env:
demo: ${{ matrix.test.file }}
desc: ${{ matrix.test.desc }}
run: ./runTest.sh

linux:
name: 'Linux'
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
container: debian:11-slim

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: Check dependencies
- name: Install dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib
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: |
Expand All @@ -171,7 +144,7 @@ jobs:
fi
shell: bash

- name: Build
- name: Build using GCC Compiler
run: |
rm -rf build && CC=gcc CXX=g++ cmake -B build && cmake --build build -j8
Expand Down Expand Up @@ -199,31 +172,25 @@ jobs:
shell: bash

- name: Deploy artifacts
uses: actions/upload-artifact@v3.1.1
uses: actions/upload-artifact@v4
id: upload-job
with:
name: linux32
path: publish/*

- name: Cleanup temporary artifacts
if: success() && steps.upload-job.outcome == 'success'
run: |
rm -rf cssdk
rm -f appversion.h
publish:
name: 'Publish'
runs-on: ubuntu-latest
needs: [windows, testdemos, linux]

steps:
- name: Deploying linux artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: linux32

- name: Deploying windows artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: win32

Expand Down Expand Up @@ -264,8 +231,3 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.API_TOKEN }}

- name: Cleanup temporary artifacts
if: success() && steps.publish-job.outcome == 'success'
run: |
rm -rf bin dist debug cssdk
rm -f *.zip appversion.h

0 comments on commit 7738142

Please sign in to comment.