test.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. name: Build and Test
  2. on:
  3. pull_request:
  4. push:
  5. branches:
  6. - main
  7. - releases/*
  8. jobs:
  9. build:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/setup-node@v1
  13. with:
  14. node-version: 20.x
  15. - uses: actions/checkout@v3
  16. - run: npm ci
  17. - run: npm run build
  18. - run: npm run format-check
  19. - run: npm run lint
  20. - run: npm test
  21. - name: Verify no unstaged changes
  22. run: __test__/verify-no-unstaged-changes.sh
  23. test:
  24. strategy:
  25. matrix:
  26. runs-on: [ubuntu-latest, macos-latest, windows-latest]
  27. runs-on: ${{ matrix.runs-on }}
  28. steps:
  29. # Clone this repo
  30. - name: Checkout
  31. uses: actions/checkout@v3
  32. # Basic checkout
  33. - name: Checkout basic
  34. uses: ./
  35. with:
  36. ref: test-data/v2/basic
  37. path: basic
  38. - name: Verify basic
  39. shell: bash
  40. run: __test__/verify-basic.sh
  41. # Clean
  42. - name: Modify work tree
  43. shell: bash
  44. run: __test__/modify-work-tree.sh
  45. - name: Checkout clean
  46. uses: ./
  47. with:
  48. ref: test-data/v2/basic
  49. path: basic
  50. - name: Verify clean
  51. shell: bash
  52. run: __test__/verify-clean.sh
  53. # Side by side
  54. - name: Checkout side by side 1
  55. uses: ./
  56. with:
  57. ref: test-data/v2/side-by-side-1
  58. path: side-by-side-1
  59. - name: Checkout side by side 2
  60. uses: ./
  61. with:
  62. ref: test-data/v2/side-by-side-2
  63. path: side-by-side-2
  64. - name: Verify side by side
  65. shell: bash
  66. run: __test__/verify-side-by-side.sh
  67. # Filter
  68. - name: Fetch filter
  69. uses: ./
  70. with:
  71. filter: 'blob:none'
  72. path: fetch-filter
  73. - name: Verify fetch filter
  74. run: __test__/verify-fetch-filter.sh
  75. # Sparse checkout
  76. - name: Sparse checkout
  77. uses: ./
  78. with:
  79. sparse-checkout: |
  80. __test__
  81. .github
  82. dist
  83. path: sparse-checkout
  84. - name: Verify sparse checkout
  85. run: __test__/verify-sparse-checkout.sh
  86. # Sparse checkout (non-cone mode)
  87. - name: Sparse checkout (non-cone mode)
  88. uses: ./
  89. with:
  90. sparse-checkout: |
  91. /__test__/
  92. /.github/
  93. /dist/
  94. sparse-checkout-cone-mode: false
  95. path: sparse-checkout-non-cone-mode
  96. - name: Verify sparse checkout (non-cone mode)
  97. run: __test__/verify-sparse-checkout-non-cone-mode.sh
  98. # LFS
  99. - name: Checkout LFS
  100. uses: ./
  101. with:
  102. repository: actions/checkout # hardcoded, otherwise doesn't work from a fork
  103. ref: test-data/v2/lfs
  104. path: lfs
  105. lfs: true
  106. - name: Verify LFS
  107. shell: bash
  108. run: __test__/verify-lfs.sh
  109. # Submodules false
  110. - name: Checkout submodules false
  111. uses: ./
  112. with:
  113. ref: test-data/v2/submodule-ssh-url
  114. path: submodules-false
  115. - name: Verify submodules false
  116. run: __test__/verify-submodules-false.sh
  117. # Submodules one level
  118. - name: Checkout submodules true
  119. uses: ./
  120. with:
  121. ref: test-data/v2/submodule-ssh-url
  122. path: submodules-true
  123. submodules: true
  124. - name: Verify submodules true
  125. run: __test__/verify-submodules-true.sh
  126. # Submodules recursive
  127. - name: Checkout submodules recursive
  128. uses: ./
  129. with:
  130. ref: test-data/v2/submodule-ssh-url
  131. path: submodules-recursive
  132. submodules: recursive
  133. - name: Verify submodules recursive
  134. run: __test__/verify-submodules-recursive.sh
  135. # Basic checkout using REST API
  136. - name: Remove basic
  137. if: runner.os != 'windows'
  138. run: rm -rf basic
  139. - name: Remove basic (Windows)
  140. if: runner.os == 'windows'
  141. shell: cmd
  142. run: rmdir /s /q basic
  143. - name: Override git version
  144. if: runner.os != 'windows'
  145. run: __test__/override-git-version.sh
  146. - name: Override git version (Windows)
  147. if: runner.os == 'windows'
  148. run: __test__\\override-git-version.cmd
  149. - name: Checkout basic using REST API
  150. uses: ./
  151. with:
  152. ref: test-data/v2/basic
  153. path: basic
  154. - name: Verify basic
  155. run: __test__/verify-basic.sh --archive
  156. test-proxy:
  157. runs-on: ubuntu-latest
  158. container:
  159. image: alpine/git:latest
  160. options: --dns 127.0.0.1
  161. services:
  162. squid-proxy:
  163. image: ubuntu/squid:latest
  164. ports:
  165. - 3128:3128
  166. env:
  167. https_proxy: http://squid-proxy:3128
  168. steps:
  169. # Clone this repo
  170. - name: Checkout
  171. uses: actions/checkout@v3
  172. # Basic checkout using git
  173. - name: Checkout basic
  174. uses: ./
  175. with:
  176. ref: test-data/v2/basic
  177. path: basic
  178. - name: Verify basic
  179. run: __test__/verify-basic.sh
  180. # Basic checkout using REST API
  181. - name: Remove basic
  182. run: rm -rf basic
  183. - name: Override git version
  184. run: __test__/override-git-version.sh
  185. - name: Basic checkout using REST API
  186. uses: ./
  187. with:
  188. ref: test-data/v2/basic
  189. path: basic
  190. - name: Verify basic
  191. run: __test__/verify-basic.sh --archive
  192. test-bypass-proxy:
  193. runs-on: ubuntu-latest
  194. env:
  195. https_proxy: http://no-such-proxy:3128
  196. no_proxy: api.github.com,github.com
  197. steps:
  198. # Clone this repo
  199. - name: Checkout
  200. uses: actions/checkout@v3
  201. # Basic checkout using git
  202. - name: Checkout basic
  203. uses: ./
  204. with:
  205. ref: test-data/v2/basic
  206. path: basic
  207. - name: Verify basic
  208. run: __test__/verify-basic.sh
  209. - name: Remove basic
  210. run: rm -rf basic
  211. # Basic checkout using REST API
  212. - name: Override git version
  213. run: __test__/override-git-version.sh
  214. - name: Checkout basic using REST API
  215. uses: ./
  216. with:
  217. ref: test-data/v2/basic
  218. path: basic
  219. - name: Verify basic
  220. run: __test__/verify-basic.sh --archive
  221. test-git-container:
  222. runs-on: ubuntu-latest
  223. container: bitnami/git:latest
  224. steps:
  225. # Clone this repo
  226. - name: Checkout
  227. uses: actions/checkout@v3
  228. with:
  229. path: v3
  230. # Basic checkout using git
  231. - name: Checkout basic
  232. uses: ./v3
  233. with:
  234. ref: test-data/v2/basic
  235. - name: Verify basic
  236. run: |
  237. if [ ! -f "./basic-file.txt" ]; then
  238. echo "Expected basic file does not exist"
  239. exit 1
  240. fi
  241. # Verify .git folder
  242. if [ ! -d "./.git" ]; then
  243. echo "Expected ./.git folder to exist"
  244. exit 1
  245. fi
  246. # Verify auth token
  247. git config --global --add safe.directory "*"
  248. git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
  249. # needed to make checkout post cleanup succeed
  250. - name: Fix Checkout v3
  251. uses: actions/checkout@v3
  252. with:
  253. path: v3