|
| 1 | +name: C/C++ CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + paths-ignore: |
| 7 | + - '**.md' |
| 8 | + |
| 9 | + pull_request: |
| 10 | + types: [opened, reopened, synchronize] |
| 11 | + release: |
| 12 | + types: [published] |
| 13 | + |
| 14 | +jobs: |
| 15 | + windows: |
| 16 | + name: 'Windows' |
| 17 | + runs-on: windows-latest |
| 18 | + |
| 19 | + env: |
| 20 | + solution: 'msvc/ReGameDLL.sln' |
| 21 | + buildPlatform: 'Win32' |
| 22 | + buildRelease: 'Release' |
| 23 | + buildReleasePlay: 'Release Play' |
| 24 | + buildTests: 'Tests' |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v2 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Setup Nuget |
| 33 | + uses: nuget/setup-nuget@v1 |
| 34 | + with: |
| 35 | + nuget-api-key: ${{ secrets.NuGetAPIKey }} |
| 36 | + nuget-version: '5.x' |
| 37 | + |
| 38 | + - run: nuget restore '${{ env.solution }}' |
| 39 | + |
| 40 | + - name: Setup MSBuild |
| 41 | + |
| 42 | + with: |
| 43 | + vs-version: '16.8' |
| 44 | + |
| 45 | + - name: Build and Run unittests |
| 46 | + run: | |
| 47 | + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTests }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false |
| 48 | + .\"msvc\Tests\mp.exe" |
| 49 | + If ($LASTEXITCODE -ne 0 -And |
| 50 | + $LASTEXITCODE -ne 3) |
| 51 | + {[Environment]::Exit(1)} |
| 52 | + shell: "pwsh" |
| 53 | + |
| 54 | + - name: Build |
| 55 | + run: | |
| 56 | + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false |
| 57 | + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildReleasePlay }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false |
| 58 | +
|
| 59 | + - name: Move files |
| 60 | + run: | |
| 61 | + mkdir publish\debug |
| 62 | + mkdir publish\tests |
| 63 | + mkdir publish\bin\win32\cstrike\dlls |
| 64 | + move "msvc\${{ env.buildReleasePlay }}\mp.dll" publish\tests\mp.dll |
| 65 | + move msvc\${{ env.buildRelease }}\mp.dll publish\bin\win32\cstrike\dlls\mp.dll |
| 66 | + move msvc\${{ env.buildRelease }}\mp.pdb publish\debug\mp.pdb |
| 67 | +
|
| 68 | + - name: Deploy artifacts |
| 69 | + uses: actions/upload-artifact@v2 |
| 70 | + with: |
| 71 | + name: win32 |
| 72 | + path: publish/* |
| 73 | + |
| 74 | + testdemos: |
| 75 | + name: 'Test demos' |
| 76 | + runs-on: ubuntu-latest |
| 77 | + container: s1lentq/testdemos:latest |
| 78 | + needs: [windows] |
| 79 | + |
| 80 | + env: |
| 81 | + WINEDEBUG: -all |
| 82 | + WINEDLLOVERRIDES: mshtml= |
| 83 | + |
| 84 | + defaults: |
| 85 | + run: |
| 86 | + shell: bash |
| 87 | + working-directory: ../../../opt/HLDS |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Deploying windows artifacts |
| 91 | + uses: actions/download-artifact@v2 |
| 92 | + with: |
| 93 | + name: win32 |
| 94 | + |
| 95 | + - name: Play demos |
| 96 | + run: | |
| 97 | + chown root ~ |
| 98 | + cp -r deps/regamedll/* . |
| 99 | + mv $GITHUB_WORKSPACE/tests/mp.dll cstrike/dlls/mp.dll |
| 100 | +
|
| 101 | + descs=( |
| 102 | + "CS: Testing jumping, scenarios, shooting etc" |
| 103 | + ) |
| 104 | +
|
| 105 | + demos=( |
| 106 | + "cstrike-basic-1" |
| 107 | + ) |
| 108 | +
|
| 109 | + retVal=0 |
| 110 | + for i in "${!demos[@]}"; do |
| 111 | + params=$(cat "testdemos/${demos[i]}.params") |
| 112 | +
|
| 113 | + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[0m" |
| 114 | + echo -e " - \e[0;33mParameters $params\e[0m" |
| 115 | +
|
| 116 | + wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/${demos[i]}.bin" $params &> result.log || retVal=$? |
| 117 | +
|
| 118 | + if [ $retVal -ne 777 ] && [ $retVal -ne 9 ]; then |
| 119 | + # Print with catchy messages |
| 120 | + while read line; do |
| 121 | + echo -e " \e[0;33m$line" |
| 122 | + done <<< $(cat result.log | sed '0,/demo failed/I!d;/wine:/d;/./,$!d') |
| 123 | +
|
| 124 | + echo " 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸" |
| 125 | + while read line; do |
| 126 | + echo -e " \e[1;31m$line"; |
| 127 | + done < rehlds_demo_error.txt |
| 128 | + echo -e " \e[30;41mExit code: $retVal\e[0m" |
| 129 | + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;31m Failed ❌" |
| 130 | + exit 6 # Test demo failed |
| 131 | + else |
| 132 | + # Print result HLDS console |
| 133 | + while read line; do |
| 134 | + echo -e " \e[0;33m$line" |
| 135 | + done <<< $(cat result.log | sed '/wine:/d;/./,$!d') |
| 136 | + echo -e " \e[30;43mExit code: $retVal\e[0m" |
| 137 | + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;32m Succeed ✔" |
| 138 | + fi |
| 139 | + done |
| 140 | +
|
| 141 | + linux: |
| 142 | + name: 'Linux' |
| 143 | + runs-on: ubuntu-latest |
| 144 | + container: s1lentq/linux86buildtools:latest |
| 145 | + |
| 146 | + steps: |
| 147 | + - name: Checkout |
| 148 | + uses: actions/checkout@v2 |
| 149 | + with: |
| 150 | + fetch-depth: 0 |
| 151 | + submodules: true |
| 152 | + |
| 153 | + - name: Build and Run unittests |
| 154 | + run: | |
| 155 | + rm -rf build && CC=icc CXX=icpc cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8 |
| 156 | + retVal=0 |
| 157 | + ./build/regamedll/cs 2> /dev/null > result.log || retVal=$? |
| 158 | + while read line; do |
| 159 | + if [[ ${line} == *"Warning in test"* ]] ; then |
| 160 | + echo -e "\e[2;38m$line" |
| 161 | + elif [[ ${line} == *"Failure in test"* ]] ; then |
| 162 | + echo -e "\e[1;31m$line" |
| 163 | + else |
| 164 | + echo -e "\e[0;33m$line" |
| 165 | + fi |
| 166 | + done <<< $(cat result.log) |
| 167 | +
|
| 168 | + if [ $retVal -ne 0 ] && [ $retVal -ne 3 ]; then |
| 169 | + echo -e "\e[30;41mExit code: $retVal\e[0m" |
| 170 | + exit 1 # Unittest failed |
| 171 | + else |
| 172 | + echo -e "\e[30;43mExit code: $retVal\e[0m" |
| 173 | + fi |
| 174 | + shell: bash |
| 175 | + |
| 176 | + - name: Build using Intel C++ Compiler 19.0 |
| 177 | + run: | |
| 178 | + rm -rf build-icc && CC=icc CXX=icpc cmake -B build-icc && cmake --build build-icc -j8 |
| 179 | +
|
| 180 | + - name: Build using GCC Compiler 9.3 |
| 181 | + run: | |
| 182 | + rm -rf build-gcc && CC=gcc CXX=g++ cmake -B build-gcc && cmake --build build-gcc -j8 |
| 183 | +
|
| 184 | + - name: Prepare CSSDK |
| 185 | + run: | |
| 186 | + mkdir -p publish/cssdk |
| 187 | + rsync -a regamedll/extra/cssdk/ publish/cssdk/ --exclude=.git --exclude=LICENSE --exclude=README.md |
| 188 | +
|
| 189 | + - name: Move files |
| 190 | + run: | |
| 191 | + mkdir -p publish/bin/linux32/cstrike/dlls |
| 192 | + mv build-icc/regamedll/cs.so publish/bin/linux32/cstrike/dlls/cs.so |
| 193 | + mv build-gcc/regamedll/cs.so publish/cs-gcc.so |
| 194 | + mv regamedll/version/appversion.h publish/appversion.h |
| 195 | +
|
| 196 | + - name: Run GLIBC/ABI version compat test |
| 197 | + run: | |
| 198 | + binaries=( |
| 199 | + "publish/bin/linux32/cstrike/dlls/cs.so" |
| 200 | + "publish/cs-gcc.so" |
| 201 | + ) |
| 202 | + bash ./regamedll/version/glibc_test.sh ${binaries[@]} |
| 203 | + if [[ $? -ne 0 ]]; then |
| 204 | + exit 1 # Assertion failed |
| 205 | + fi |
| 206 | + shell: bash |
| 207 | + |
| 208 | + - name: Deploy artifacts |
| 209 | + uses: actions/upload-artifact@v2 |
| 210 | + id: upload-job |
| 211 | + with: |
| 212 | + name: linux32 |
| 213 | + path: publish/* |
| 214 | + |
| 215 | + - name: Cleanup temporary artifacts |
| 216 | + if: success() && steps.upload-job.outcome == 'success' |
| 217 | + run: | |
| 218 | + rm -rf cssdk |
| 219 | + rm -f appversion.h |
| 220 | +
|
| 221 | + publish: |
| 222 | + name: 'Publish' |
| 223 | + runs-on: ubuntu-latest |
| 224 | + needs: [windows, testdemos, linux] |
| 225 | + |
| 226 | + steps: |
| 227 | + - name: Deploying linux artifacts |
| 228 | + uses: actions/download-artifact@v2 |
| 229 | + with: |
| 230 | + name: linux32 |
| 231 | + |
| 232 | + - name: Deploying windows artifacts |
| 233 | + uses: actions/download-artifact@v2 |
| 234 | + with: |
| 235 | + name: win32 |
| 236 | + |
| 237 | + - name: Reading appversion.h |
| 238 | + run: | |
| 239 | + if [ -e appversion.h ]; then |
| 240 | + 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') |
| 241 | + if [ $? -ne 0 ]; then |
| 242 | + APP_VERSION="" |
| 243 | + else |
| 244 | + # Remove quotes |
| 245 | + APP_VERSION=$(echo $APP_VERSION | xargs) |
| 246 | + echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV |
| 247 | + fi |
| 248 | + fi |
| 249 | + rm -f appversion.h |
| 250 | +
|
| 251 | + - name: Packaging bin/dbg |
| 252 | + id: packaging-job |
| 253 | + if: | |
| 254 | + github.event_name == 'release' && |
| 255 | + github.event.action == 'published' && |
| 256 | + startsWith(github.ref, 'refs/tags/') |
| 257 | + run: | |
| 258 | + 7z a -tzip regamedll-bin-${{ env.APP_VERSION }}.zip bin/ cssdk/ |
| 259 | +
|
| 260 | + - name: Publish artifacts |
| 261 | + uses: softprops/action-gh-release@v1 |
| 262 | + id: publish-job |
| 263 | + if: | |
| 264 | + startsWith(github.ref, 'refs/tags/') && |
| 265 | + steps.packaging-job.outcome == 'success' |
| 266 | + with: |
| 267 | + files: | |
| 268 | + *.zip |
| 269 | + env: |
| 270 | + GITHUB_TOKEN: ${{ secrets.API_TOKEN }} |
| 271 | + |
| 272 | + - name: Cleanup temporary artifacts |
| 273 | + if: success() && steps.publish-job.outcome == 'success' |
| 274 | + run: | |
| 275 | + rm -rf bin debug cssdk |
| 276 | + rm -f *.zip appversion.h |
0 commit comments