ci.yml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. name: CI
  2. env:
  3. # MIN_SUPPORTED_RUST_VERSION: "1.46.0"
  4. # CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
  5. VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
  6. # vcpkg version: 2024.11.16
  7. # for multiarch gcc compatibility
  8. VCPKG_COMMIT_ID: "b2cb0da531c2f1f740045bfe7c4dac59f0b2b69c"
  9. on:
  10. workflow_dispatch:
  11. pull_request:
  12. paths-ignore:
  13. - "docs/**"
  14. - "README.md"
  15. push:
  16. branches:
  17. - master
  18. paths-ignore:
  19. - ".github/**"
  20. - "docs/**"
  21. - "README.md"
  22. - "res/**"
  23. - "appimage/**"
  24. - "flatpak/**"
  25. jobs:
  26. # ensure_cargo_fmt:
  27. # name: Ensure 'cargo fmt' has been run
  28. # runs-on: ubuntu-20.04
  29. # steps:
  30. # - uses: actions-rs/toolchain@v1
  31. # with:
  32. # toolchain: stable
  33. # default: true
  34. # profile: minimal
  35. # components: rustfmt
  36. # - uses: actions/checkout@v3
  37. # - run: cargo fmt -- --check
  38. # min_version:
  39. # name: Minimum supported rust version
  40. # runs-on: ubuntu-20.04
  41. # steps:
  42. # - name: Checkout source code
  43. # uses: actions/checkout@v3
  44. # with:
  45. # submodules: recursive
  46. # - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
  47. # uses: actions-rs/toolchain@v1
  48. # with:
  49. # toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
  50. # default: true
  51. # profile: minimal # minimal component installation (ie, no documentation)
  52. # components: clippy
  53. # - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
  54. # uses: actions-rs/cargo@v1
  55. # with:
  56. # command: clippy
  57. # args: --locked --all-targets --all-features -- --allow clippy::unknown_clippy_lints
  58. # - name: Run tests
  59. # uses: actions-rs/cargo@v1
  60. # with:
  61. # command: test
  62. # args: --locked
  63. build:
  64. name: ${{ matrix.job.target }} (${{ matrix.job.os }})
  65. runs-on: ${{ matrix.job.os }}
  66. strategy:
  67. fail-fast: false
  68. matrix:
  69. job:
  70. # - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
  71. # - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true }
  72. # - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true }
  73. # - { target: i686-pc-windows-msvc , os: windows-2022 }
  74. # - { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
  75. # - { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
  76. # - { target: x86_64-apple-darwin , os: macos-10.15 }
  77. # - { target: x86_64-pc-windows-gnu , os: windows-2022 }
  78. # - { target: x86_64-pc-windows-msvc , os: windows-2022 }
  79. - { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
  80. # - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
  81. steps:
  82. - name: Export GitHub Actions cache environment variables
  83. uses: actions/github-script@v6
  84. with:
  85. script: |
  86. core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
  87. core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
  88. - name: Checkout source code
  89. uses: actions/checkout@v4
  90. with:
  91. submodules: recursive
  92. - name: Install prerequisites
  93. shell: bash
  94. run: |
  95. case ${{ matrix.job.target }} in
  96. x86_64-unknown-linux-gnu)
  97. sudo apt-get -y update
  98. sudo apt-get install -y \
  99. clang \
  100. cmake \
  101. curl \
  102. gcc \
  103. git \
  104. g++ \
  105. libpam0g-dev \
  106. libasound2-dev \
  107. libgstreamer1.0-dev \
  108. libgstreamer-plugins-base1.0-dev \
  109. libgtk-3-dev \
  110. libpulse-dev \
  111. libva-dev \
  112. libvdpau-dev \
  113. libxcb-randr0-dev \
  114. libxcb-shape0-dev \
  115. libxcb-xfixes0-dev \
  116. libxdo-dev \
  117. libxfixes-dev \
  118. nasm \
  119. wget
  120. ;;
  121. # arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
  122. # aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
  123. esac
  124. - name: Setup vcpkg with Github Actions binary cache
  125. uses: lukka/run-vcpkg@v11
  126. with:
  127. vcpkgDirectory: /opt/artifacts/vcpkg
  128. vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
  129. - name: Install vcpkg dependencies
  130. run: |
  131. $VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed"
  132. shell: bash
  133. - name: Install Rust toolchain
  134. uses: dtolnay/rust-toolchain@v1
  135. with:
  136. toolchain: stable
  137. targets: ${{ matrix.job.target }}
  138. components: ''
  139. - name: Show version information (Rust, cargo, GCC)
  140. shell: bash
  141. run: |
  142. gcc --version || true
  143. rustup -V
  144. rustup toolchain list
  145. rustup default
  146. cargo -V
  147. rustc -V
  148. - uses: Swatinem/rust-cache@v2
  149. - name: Build
  150. uses: actions-rs/cargo@v1
  151. with:
  152. use-cross: ${{ matrix.job.use-cross }}
  153. command: build
  154. args: --locked --target=${{ matrix.job.target }}
  155. - name: clean
  156. shell: bash
  157. run: |
  158. cargo clean
  159. # - name: Strip debug information from executable
  160. # id: strip
  161. # shell: bash
  162. # run: |
  163. # # Figure out suffix of binary
  164. # EXE_suffix=""
  165. # case ${{ matrix.job.target }} in
  166. # *-pc-windows-*) EXE_suffix=".exe" ;;
  167. # esac;
  168. # # Figure out what strip tool to use if any
  169. # STRIP="strip"
  170. # case ${{ matrix.job.target }} in
  171. # arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
  172. # aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
  173. # *-pc-windows-msvc) STRIP="" ;;
  174. # esac;
  175. # # Setup paths
  176. # BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/"
  177. # mkdir -p "${BIN_DIR}"
  178. # BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}"
  179. # BIN_PATH="${BIN_DIR}/${BIN_NAME}"
  180. # # Copy the release build binary to the result location
  181. # cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}"
  182. # # Also strip if possible
  183. # if [ -n "${STRIP}" ]; then
  184. # "${STRIP}" "${BIN_PATH}"
  185. # fi
  186. # # Let subsequent steps know where to find the (stripped) bin
  187. # echo ::set-output name=BIN_PATH::${BIN_PATH}
  188. # echo ::set-output name=BIN_NAME::${BIN_NAME}
  189. - name: Set testing options
  190. id: test-options
  191. shell: bash
  192. run: |
  193. # test only library unit tests and binary for arm-type targets
  194. unset CARGO_TEST_OPTIONS
  195. case ${{ matrix.job.target }} in
  196. arm-* | aarch64-*)
  197. CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}"
  198. ;;
  199. *)
  200. CARGO_TEST_OPTIONS="--workspace --no-fail-fast -- --skip test_get_cursor_pos --skip test_get_key_state"
  201. ;;
  202. esac;
  203. #deprecated echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
  204. echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_ENV
  205. echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT
  206. - name: Run tests
  207. uses: actions-rs/cargo@v1
  208. with:
  209. use-cross: ${{ matrix.job.use-cross }}
  210. command: test
  211. args: --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}