|
| 1 | +--- |
| 2 | +name: CI-FreeBSD |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + release_commit: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + release_version: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + |
| 16 | +env: |
| 17 | + BRANCH: ${{ github.head_ref || github.ref_name }} |
| 18 | + BUILD_VERSION: ${{ inputs.release_version }} |
| 19 | + COMMIT: ${{ inputs.release_commit }} |
| 20 | + FREEBSD_CLANG_VERSION: 19 |
| 21 | + |
| 22 | +jobs: |
| 23 | + setup-matrix: |
| 24 | + name: Setup Build Matrix |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + matrix: ${{ steps.generate-matrix.outputs.matrix }} |
| 28 | + steps: |
| 29 | + - name: Generate Matrix |
| 30 | + id: generate-matrix |
| 31 | + shell: bash |
| 32 | + run: | |
| 33 | + # Base matrix with amd64 build |
| 34 | + matrix='{ |
| 35 | + "include": [ |
| 36 | + { |
| 37 | + "bsd_release": "14.3", |
| 38 | + "arch": "x86_64", |
| 39 | + "cmake_processor": "amd64", |
| 40 | + "runner": "ubuntu-latest" |
| 41 | + } |
| 42 | + ] |
| 43 | + }' |
| 44 | +
|
| 45 | + # Add aarch64 build only if not a pull request event |
| 46 | + if [[ "${{ github.event_name }}" != "pull_request" ]]; then |
| 47 | + matrix=$(echo "$matrix" | jq '.include += [{ |
| 48 | + "bsd_release": "14.3", |
| 49 | + "arch": "aarch64", |
| 50 | + "cmake_processor": "aarch64", |
| 51 | + "runner": "ubuntu-latest" |
| 52 | + }]') |
| 53 | + fi |
| 54 | +
|
| 55 | + # Use heredoc for multiline JSON output |
| 56 | + { |
| 57 | + echo "matrix<<EOF" |
| 58 | + echo "$matrix" |
| 59 | + echo "EOF" |
| 60 | + } >> "${GITHUB_OUTPUT}" |
| 61 | +
|
| 62 | + echo "Generated matrix:" |
| 63 | + echo "$matrix" | jq . |
| 64 | +
|
| 65 | + build_freebsd: |
| 66 | + name: ${{ matrix.cmake_processor }}-${{ matrix.bsd_release }} |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: setup-matrix |
| 69 | + strategy: |
| 70 | + fail-fast: false |
| 71 | + matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }} |
| 72 | + steps: |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@v5 |
| 75 | + with: |
| 76 | + submodules: recursive |
| 77 | + |
| 78 | + - name: Get Processor Count |
| 79 | + id: processor_count |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + PROCESSOR_COUNT=$(nproc) |
| 83 | + echo "PROCESSOR_COUNT=${PROCESSOR_COUNT}" >> "${GITHUB_OUTPUT}" |
| 84 | + echo "PROCESSOR_COUNT: $PROCESSOR_COUNT" |
| 85 | +
|
| 86 | + - name: Setup FreeBSD |
| 87 | + uses: vmactions/freebsd-vm@783ae15c0393f8a2582a139f76cc55f2d887b4a6 # v1.2.6 |
| 88 | + with: |
| 89 | + arch: ${{ matrix.arch }} |
| 90 | + cpu: ${{ steps.processor_count.outputs.PROCESSOR_COUNT }} |
| 91 | + envs: 'BRANCH BUILD_VERSION COMMIT' |
| 92 | + # TODO: there is no libcap for freebsd... we need graphics/libdrm if we find a way to use libcap |
| 93 | + # TODO: docs are off because doxygen is too old: https://www.freshports.org/devel/doxygen/ must be >= 1.10 |
| 94 | + prepare: | |
| 95 | + set -e |
| 96 | +
|
| 97 | + pkg update |
| 98 | + pkg upgrade -y |
| 99 | + pkg install -y \ |
| 100 | + audio/opus \ |
| 101 | + audio/pulseaudio \ |
| 102 | + devel/boost-all \ |
| 103 | + devel/cmake-core \ |
| 104 | + devel/evdev-proto \ |
| 105 | + devel/git \ |
| 106 | + devel/libayatana-appindicator \ |
| 107 | + devel/libevdev \ |
| 108 | + devel/libnotify \ |
| 109 | + devel/llvm${{ env.FREEBSD_CLANG_VERSION }} \ |
| 110 | + devel/ninja \ |
| 111 | + devel/pkgconf \ |
| 112 | + ftp/curl \ |
| 113 | + graphics/libdrm \ |
| 114 | + graphics/wayland \ |
| 115 | + lang/python312 \ |
| 116 | + multimedia/libva \ |
| 117 | + net/miniupnpc \ |
| 118 | + ports-mgmt/pkg \ |
| 119 | + security/openssl \ |
| 120 | + shells/bash \ |
| 121 | + www/npm \ |
| 122 | + x11/libX11 \ |
| 123 | + x11/libxcb \ |
| 124 | + x11/libXfixes \ |
| 125 | + x11/libXrandr \ |
| 126 | + x11/libXtst \ |
| 127 | + x11-servers/xorg-server |
| 128 | +
|
| 129 | + # create symlink for shebang bash compatibility |
| 130 | + ln -s /usr/local/bin/bash /bin/bash |
| 131 | +
|
| 132 | + # setup python |
| 133 | + ln -s /usr/local/bin/python3.12 /usr/local/bin/python |
| 134 | + python -m ensurepip |
| 135 | + release: ${{ matrix.bsd_release }} |
| 136 | + run: | |
| 137 | + set -e |
| 138 | + # install gcvor |
| 139 | + python -m pip install gcovr |
| 140 | +
|
| 141 | + # fix git safe.directory issues |
| 142 | + git config --global --add safe.directory "*" |
| 143 | + sync: nfs # sshfs is used for build-deps; however it's much slower than nfs |
| 144 | + |
| 145 | + - name: Configure |
| 146 | + shell: freebsd {0} |
| 147 | + run: | |
| 148 | + set -e |
| 149 | + cd "${GITHUB_WORKSPACE}" |
| 150 | +
|
| 151 | + cc_path="$(which clang${{ env.FREEBSD_CLANG_VERSION }})" |
| 152 | + cxx_path="$(which clang++${{ env.FREEBSD_CLANG_VERSION }})" |
| 153 | +
|
| 154 | + export CC="${cc_path}" |
| 155 | + export CXX="${cxx_path}" |
| 156 | +
|
| 157 | + mkdir -p build |
| 158 | + cmake \ |
| 159 | + -B build \ |
| 160 | + -G Ninja \ |
| 161 | + -S . \ |
| 162 | + -DBUILD_DOCS=OFF \ |
| 163 | + -DBUILD_WERROR=OFF \ |
| 164 | + -DCMAKE_BUILD_TYPE=Release \ |
| 165 | + -DCMAKE_INSTALL_PREFIX=/usr/local \ |
| 166 | + -DSUNSHINE_ASSETS_DIR=share/assets \ |
| 167 | + -DSUNSHINE_EXECUTABLE_PATH=/usr/local/bin/sunshine \ |
| 168 | + -DSUNSHINE_ENABLE_CUDA=OFF \ |
| 169 | + -DSUNSHINE_ENABLE_DRM=OFF \ |
| 170 | + -DSUNSHINE_ENABLE_WAYLAND=ON \ |
| 171 | + -DSUNSHINE_ENABLE_X11=ON \ |
| 172 | + -DSUNSHINE_PUBLISHER_NAME='${{ github.repository_owner }}' \ |
| 173 | + -DSUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' \ |
| 174 | + -DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' |
| 175 | +
|
| 176 | + - name: Build |
| 177 | + shell: freebsd {0} |
| 178 | + run: | |
| 179 | + set -e |
| 180 | + cd "${GITHUB_WORKSPACE}" |
| 181 | + ninja -C build |
| 182 | +
|
| 183 | + - name: Package |
| 184 | + shell: freebsd {0} |
| 185 | + run: | |
| 186 | + set -e |
| 187 | + cd "${GITHUB_WORKSPACE}" |
| 188 | +
|
| 189 | + mkdir -p artifacts |
| 190 | +
|
| 191 | + cd build |
| 192 | + cpack -G FREEBSD |
| 193 | +
|
| 194 | + # move compiled files to artifacts |
| 195 | + mv ./cpack_artifacts/Sunshine.pkg \ |
| 196 | + ../artifacts/Sunshine-FreeBSD-${{ matrix.bsd_release }}-${{ matrix.cmake_processor }}.pkg |
| 197 | +
|
| 198 | + - name: Debug |
| 199 | + if: always() |
| 200 | + shell: bash |
| 201 | + working-directory: build/cpack_artifacts/_CPack_Packages/FreeBSD/FREEBSD/Sunshine |
| 202 | + run: | |
| 203 | + echo "FreeBSD CPack Debug" |
| 204 | + echo "===== Staging Directory Contents =====" |
| 205 | + ls -la |
| 206 | + echo "" |
| 207 | + echo "===== +MANIFEST Content =====" |
| 208 | + cat +MANIFEST |
| 209 | + echo "" |
| 210 | +
|
| 211 | + # use tar to print the contents of the pkg |
| 212 | + cd "${GITHUB_WORKSPACE}/artifacts" |
| 213 | + echo "===== Package Contents =====" |
| 214 | + tar -tvf Sunshine-FreeBSD-${{ matrix.bsd_release }}-${{ matrix.cmake_processor }}.pkg |
| 215 | + echo "" |
| 216 | + echo "===== Package Statistics =====" |
| 217 | + echo -n "Total files in package: " |
| 218 | + tar -tf Sunshine-FreeBSD-${{ matrix.bsd_release }}-${{ matrix.cmake_processor }}.pkg 2>&1 | wc -l |
| 219 | + echo "" |
| 220 | + echo "Package file size:" |
| 221 | + ls -lh Sunshine-FreeBSD-${{ matrix.bsd_release }}-${{ matrix.cmake_processor }}.pkg |
| 222 | +
|
| 223 | + - name: Test |
| 224 | + id: test |
| 225 | + shell: freebsd {0} |
| 226 | + run: | |
| 227 | + set -e |
| 228 | + cd "${GITHUB_WORKSPACE}/build/tests" |
| 229 | +
|
| 230 | + export DISPLAY=:1 |
| 231 | + Xvfb ${DISPLAY} -screen 0 1024x768x24 & |
| 232 | + XVFB_PID=$! |
| 233 | +
|
| 234 | + ./test_sunshine --gtest_color=yes --gtest_output=xml:test_results.xml |
| 235 | +
|
| 236 | + kill ${XVFB_PID} |
| 237 | +
|
| 238 | + - name: Generate gcov report |
| 239 | + id: test_report |
| 240 | + # any except canceled or skipped |
| 241 | + if: >- |
| 242 | + always() && |
| 243 | + (steps.test.outcome == 'success' || steps.test.outcome == 'failure') |
| 244 | + shell: freebsd {0} |
| 245 | + run: | |
| 246 | + cd "${GITHUB_WORKSPACE}/build" |
| 247 | + python -m gcovr . -r ../src \ |
| 248 | + --exclude-noncode-lines \ |
| 249 | + --exclude-throw-branches \ |
| 250 | + --exclude-unreachable-branches \ |
| 251 | + --verbose \ |
| 252 | + --xml-pretty \ |
| 253 | + -o coverage.xml |
| 254 | +
|
| 255 | + - name: Upload coverage artifact |
| 256 | + if: >- |
| 257 | + always() && |
| 258 | + (steps.test_report.outcome == 'success') |
| 259 | + uses: actions/upload-artifact@v5 |
| 260 | + with: |
| 261 | + name: coverage-FreeBSD-${{ matrix.bsd_release }}-${{ matrix.cmake_processor }} |
| 262 | + path: | |
| 263 | + build/coverage.xml |
| 264 | + build/tests/test_results.xml |
| 265 | + if-no-files-found: error |
| 266 | + |
| 267 | + - name: Upload Artifacts |
| 268 | + uses: actions/upload-artifact@v4 |
| 269 | + with: |
| 270 | + name: build-FreeBSD-${{ matrix.bsd_release }}-${{ matrix.cmake_processor }} |
| 271 | + path: artifacts/ |
| 272 | + if-no-files-found: error |
0 commit comments