From 7738142c69dc9726a99203f151b7794645890367 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 29 Oct 2024 09:22:24 +0300 Subject: [PATCH] CI Workflow Refactor and Fixes (#1016) 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 --- .github/workflows/build.yml | 106 ++++++++++++------------------------ 1 file changed, 34 insertions(+), 72 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b4e80792..e62c178e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: | @@ -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: | @@ -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 @@ -199,18 +172,12 @@ 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 @@ -218,12 +185,12 @@ jobs: 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 @@ -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