test.yaml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. name: test
  2. concurrency:
  3. # For PRs, later CI runs preempt previous ones. e.g. a force push on a PR
  4. # cancels running CI jobs and starts all new ones.
  5. #
  6. # For non-PR pushes, concurrency.group needs to be unique for every distinct
  7. # CI run we want to have happen. Use run_id, which in practice means all
  8. # non-PR CI runs will be allowed to run without preempting each other.
  9. group: ${{ github.workflow }}-$${{ github.pull_request.number || github.run_id }}
  10. cancel-in-progress: true
  11. on:
  12. pull_request:
  13. paths:
  14. - '**/*'
  15. - '!docs/**'
  16. - '!README.md'
  17. jobs:
  18. changes:
  19. runs-on: ubuntu-latest
  20. outputs:
  21. changed: ${{ steps.changes.outputs.changed }}
  22. steps:
  23. - uses: actions/checkout@v4
  24. with:
  25. fetch-depth: 0
  26. - id: changes
  27. run: |
  28. changed() {
  29. local BASE=${{ github.event.pull_request.base.sha }}
  30. local HEAD=${{ github.event.pull_request.head.sha }}
  31. local MERGE_BASE=$(git merge-base $BASE $HEAD)
  32. git diff-tree -r --no-commit-id --name-only "$MERGE_BASE" "$HEAD" \
  33. | xargs python3 -c "import sys; from pathlib import Path; print(any(Path(x).match(glob) for x in sys.argv[1:] for glob in '$*'.split(' ')))"
  34. }
  35. echo changed=$(changed 'llama/llama.cpp/**' 'ml/backend/ggml/ggml/**') | tee -a $GITHUB_OUTPUT
  36. linux:
  37. needs: [changes]
  38. if: needs.changes.outputs.changed == 'True'
  39. strategy:
  40. matrix:
  41. include:
  42. - preset: CPU
  43. - preset: CUDA
  44. container: nvidia/cuda:11.8.0-devel-ubuntu22.04
  45. flags: '-DCMAKE_CUDA_ARCHITECTURES=87'
  46. - preset: ROCm
  47. container: rocm/dev-ubuntu-22.04:6.1.2
  48. extra-packages: rocm-libs
  49. flags: '-DAMDGPU_TARGETS=gfx1010 -DCMAKE_PREFIX_PATH=/opt/rocm'
  50. runs-on: linux
  51. container: ${{ matrix.container }}
  52. steps:
  53. - uses: actions/checkout@v4
  54. - run: |
  55. [ -n "${{ matrix.container }}" ] || sudo=sudo
  56. $sudo apt-get update
  57. $sudo apt-get install -y cmake ccache ${{ matrix.extra-packages }}
  58. env:
  59. DEBIAN_FRONTEND: noninteractive
  60. - uses: actions/cache@v4
  61. with:
  62. path: /github/home/.cache/ccache
  63. key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }}
  64. - run: |
  65. cmake --preset ${{ matrix.preset }} ${{ matrix.flags }}
  66. cmake --build --preset ${{ matrix.preset }} --parallel
  67. windows:
  68. needs: [changes]
  69. if: needs.changes.outputs.changed == 'True'
  70. strategy:
  71. matrix:
  72. include:
  73. - preset: CPU
  74. - preset: CUDA
  75. install: https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe
  76. flags: '-DCMAKE_CUDA_ARCHITECTURES=87'
  77. - preset: ROCm
  78. install: https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe
  79. flags: '-DAMDGPU_TARGETS=gfx1010'
  80. runs-on: windows
  81. steps:
  82. - run: |
  83. choco install -y --no-progress ccache ninja
  84. ccache -o cache_dir=${{ github.workspace }}\.ccache
  85. - if: matrix.preset == 'CUDA' || matrix.preset == 'ROCm'
  86. id: cache-install
  87. uses: actions/cache/restore@v4
  88. with:
  89. path: |
  90. C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA
  91. C:\Program Files\AMD\ROCm
  92. key: ${{ matrix.install }}
  93. - if: matrix.preset == 'CUDA'
  94. name: Install CUDA ${{ matrix.cuda-version }}
  95. run: |
  96. $ErrorActionPreference = "Stop"
  97. if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') {
  98. Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe"
  99. Start-Process -FilePath .\install.exe -ArgumentList (@("-s", "cudart_11.8", "nvcc_11.8", "cublas_11.8", "cublas_dev_11.8")) -NoNewWindow -Wait
  100. }
  101. $cudaPath = (Resolve-Path "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\*").path
  102. echo "$cudaPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  103. - if: matrix.preset == 'ROCm'
  104. name: Install ROCm ${{ matrix.rocm-version }}
  105. run: |
  106. $ErrorActionPreference = "Stop"
  107. if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') {
  108. Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe"
  109. Start-Process -FilePath .\install.exe -ArgumentList '-install' -NoNewWindow -Wait
  110. }
  111. $hipPath = (Resolve-Path "C:\Program Files\AMD\ROCm\*").path
  112. echo "$hipPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  113. echo "CC=$hipPath\bin\clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append
  114. echo "CXX=$hipPath\bin\clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append
  115. - if: ${{ !cancelled() && steps.cache-install.outputs.cache-hit != 'true' }}
  116. uses: actions/cache/save@v4
  117. with:
  118. path: |
  119. C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA
  120. C:\Program Files\AMD\ROCm
  121. key: ${{ matrix.install }}
  122. - uses: actions/checkout@v4
  123. - uses: actions/cache@v4
  124. with:
  125. path: ${{ github.workspace }}\.ccache
  126. key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }}
  127. - run: |
  128. Import-Module 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll'
  129. Enter-VsDevShell -VsInstallPath 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise' -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'
  130. cmake --preset "${{ matrix.preset }}" ${{ matrix.flags }}
  131. cmake --build --parallel --preset "${{ matrix.preset }}"
  132. env:
  133. CMAKE_GENERATOR: Ninja
  134. test:
  135. strategy:
  136. matrix:
  137. os: [ubuntu-latest, macos-latest, windows-latest]
  138. runs-on: ${{ matrix.os }}
  139. env:
  140. CGO_ENABLED: '1'
  141. GOEXPERIMENT: 'synctest'
  142. steps:
  143. - uses: actions/checkout@v4
  144. - uses: actions/setup-go@v5
  145. with:
  146. go-version-file: go.mod
  147. - uses: golangci/golangci-lint-action@v6
  148. with:
  149. args: --timeout 10m0s -v
  150. - run: go test ./...
  151. patches:
  152. runs-on: ubuntu-latest
  153. steps:
  154. - uses: actions/checkout@v4
  155. - name: Verify patches apply cleanly and do not change files
  156. run: |
  157. make -f Makefile.sync clean sync
  158. git diff --compact-summary --exit-code