ci.yml 7.5 KB

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