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. # for multiarch gcc compatibility
  7. VCPKG_COMMIT_ID: "6f29f12e82a8293156836ad81cc9bf5af41fe836"
  8. on:
  9. workflow_dispatch:
  10. pull_request:
  11. paths-ignore:
  12. - "docs/**"
  13. - "README.md"
  14. push:
  15. branches:
  16. - master
  17. paths-ignore:
  18. - ".github/**"
  19. - "docs/**"
  20. - "README.md"
  21. - "res/**"
  22. - "appimage/**"
  23. - "flatpak/**"
  24. jobs:
  25. # ensure_cargo_fmt:
  26. # name: Ensure 'cargo fmt' has been run
  27. # runs-on: ubuntu-20.04
  28. # steps:
  29. # - uses: actions-rs/toolchain@v1
  30. # with:
  31. # toolchain: stable
  32. # default: true
  33. # profile: minimal
  34. # components: rustfmt
  35. # - uses: actions/checkout@v3
  36. # - run: cargo fmt -- --check
  37. # min_version:
  38. # name: Minimum supported rust version
  39. # runs-on: ubuntu-20.04
  40. # steps:
  41. # - name: Checkout source code
  42. # uses: actions/checkout@v3
  43. # with:
  44. # submodules: recursive
  45. # - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
  46. # uses: actions-rs/toolchain@v1
  47. # with:
  48. # toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
  49. # default: true
  50. # profile: minimal # minimal component installation (ie, no documentation)
  51. # components: clippy
  52. # - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
  53. # uses: actions-rs/cargo@v1
  54. # with:
  55. # command: clippy
  56. # args: --locked --all-targets --all-features -- --allow clippy::unknown_clippy_lints
  57. # - name: Run tests
  58. # uses: actions-rs/cargo@v1
  59. # with:
  60. # command: test
  61. # args: --locked
  62. build:
  63. name: ${{ matrix.job.target }} (${{ matrix.job.os }})
  64. runs-on: ${{ matrix.job.os }}
  65. strategy:
  66. fail-fast: false
  67. matrix:
  68. job:
  69. # - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
  70. # - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true }
  71. # - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true }
  72. # - { target: i686-pc-windows-msvc , os: windows-2022 }
  73. # - { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
  74. # - { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
  75. # - { target: x86_64-apple-darwin , os: macos-10.15 }
  76. # - { target: x86_64-pc-windows-gnu , os: windows-2022 }
  77. # - { target: x86_64-pc-windows-msvc , os: windows-2022 }
  78. - { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04 }
  79. # - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
  80. steps:
  81. - name: Export GitHub Actions cache environment variables
  82. uses: actions/github-script@v6
  83. with:
  84. script: |
  85. core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
  86. core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
  87. - name: Checkout source code
  88. uses: actions/checkout@v4
  89. with:
  90. submodules: recursive
  91. - name: Install prerequisites
  92. shell: bash
  93. run: |
  94. case ${{ matrix.job.target }} in
  95. x86_64-unknown-linux-gnu)
  96. sudo apt-get -y update
  97. sudo apt-get install -y \
  98. clang \
  99. cmake \
  100. curl \
  101. gcc \
  102. git \
  103. g++ \
  104. libpam0g-dev \
  105. libasound2-dev \
  106. libunwind-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}}