test.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. # Sparse checkout
  68. - name: Sparse checkout
  69. uses: ./
  70. with:
  71. sparse-checkout: |
  72. __test__
  73. .github
  74. dist
  75. path: sparse-checkout
  76. - name: Verify sparse checkout
  77. run: __test__/verify-sparse-checkout.sh
  78. # Sparse checkout (non-cone mode)
  79. - name: Sparse checkout (non-cone mode)
  80. uses: ./
  81. with:
  82. sparse-checkout: |
  83. /__test__/
  84. /.github/
  85. /dist/
  86. sparse-checkout-cone-mode: false
  87. path: sparse-checkout-non-cone-mode
  88. - name: Verify sparse checkout (non-cone mode)
  89. run: __test__/verify-sparse-checkout-non-cone-mode.sh
  90. # LFS
  91. - name: Checkout LFS
  92. uses: ./
  93. with:
  94. repository: actions/checkout # hardcoded, otherwise doesn't work from a fork
  95. ref: test-data/v2/lfs
  96. path: lfs
  97. lfs: true
  98. - name: Verify LFS
  99. shell: bash
  100. run: __test__/verify-lfs.sh
  101. # Submodules false
  102. - name: Checkout submodules false
  103. uses: ./
  104. with:
  105. ref: test-data/v2/submodule-ssh-url
  106. path: submodules-false
  107. - name: Verify submodules false
  108. run: __test__/verify-submodules-false.sh
  109. # Submodules one level
  110. - name: Checkout submodules true
  111. uses: ./
  112. with:
  113. ref: test-data/v2/submodule-ssh-url
  114. path: submodules-true
  115. submodules: true
  116. - name: Verify submodules true
  117. run: __test__/verify-submodules-true.sh
  118. # Submodules recursive
  119. - name: Checkout submodules recursive
  120. uses: ./
  121. with:
  122. ref: test-data/v2/submodule-ssh-url
  123. path: submodules-recursive
  124. submodules: recursive
  125. - name: Verify submodules recursive
  126. run: __test__/verify-submodules-recursive.sh
  127. # Basic checkout using REST API
  128. - name: Remove basic
  129. if: runner.os != 'windows'
  130. run: rm -rf basic
  131. - name: Remove basic (Windows)
  132. if: runner.os == 'windows'
  133. shell: cmd
  134. run: rmdir /s /q basic
  135. - name: Override git version
  136. if: runner.os != 'windows'
  137. run: __test__/override-git-version.sh
  138. - name: Override git version (Windows)
  139. if: runner.os == 'windows'
  140. run: __test__\\override-git-version.cmd
  141. - name: Checkout basic using REST API
  142. uses: ./
  143. with:
  144. ref: test-data/v2/basic
  145. path: basic
  146. - name: Verify basic
  147. run: __test__/verify-basic.sh --archive
  148. test-proxy:
  149. runs-on: ubuntu-latest
  150. container:
  151. image: alpine/git:latest
  152. options: --dns 127.0.0.1
  153. services:
  154. squid-proxy:
  155. image: ubuntu/squid:latest
  156. ports:
  157. - 3128:3128
  158. env:
  159. https_proxy: http://squid-proxy:3128
  160. steps:
  161. # Clone this repo
  162. - name: Checkout
  163. uses: actions/checkout@v3
  164. # Basic checkout using git
  165. - name: Checkout basic
  166. uses: ./
  167. with:
  168. ref: test-data/v2/basic
  169. path: basic
  170. - name: Verify basic
  171. run: __test__/verify-basic.sh
  172. # Basic checkout using REST API
  173. - name: Remove basic
  174. run: rm -rf basic
  175. - name: Override git version
  176. run: __test__/override-git-version.sh
  177. - name: Basic checkout using REST API
  178. uses: ./
  179. with:
  180. ref: test-data/v2/basic
  181. path: basic
  182. - name: Verify basic
  183. run: __test__/verify-basic.sh --archive
  184. test-bypass-proxy:
  185. runs-on: ubuntu-latest
  186. env:
  187. https_proxy: http://no-such-proxy:3128
  188. no_proxy: api.github.com,github.com
  189. steps:
  190. # Clone this repo
  191. - name: Checkout
  192. uses: actions/checkout@v3
  193. # Basic checkout using git
  194. - name: Checkout basic
  195. uses: ./
  196. with:
  197. ref: test-data/v2/basic
  198. path: basic
  199. - name: Verify basic
  200. run: __test__/verify-basic.sh
  201. - name: Remove basic
  202. run: rm -rf basic
  203. # Basic checkout using REST API
  204. - name: Override git version
  205. run: __test__/override-git-version.sh
  206. - name: Checkout basic using REST API
  207. uses: ./
  208. with:
  209. ref: test-data/v2/basic
  210. path: basic
  211. - name: Verify basic
  212. run: __test__/verify-basic.sh --archive
  213. test-git-container:
  214. runs-on: ubuntu-latest
  215. container: bitnami/git:latest
  216. steps:
  217. # Clone this repo
  218. - name: Checkout
  219. uses: actions/checkout@v3
  220. with:
  221. path: v3
  222. # Basic checkout using git
  223. - name: Checkout basic
  224. uses: ./v3
  225. with:
  226. ref: test-data/v2/basic
  227. - name: Verify basic
  228. run: |
  229. if [ ! -f "./basic-file.txt" ]; then
  230. echo "Expected basic file does not exist"
  231. exit 1
  232. fi
  233. # Verify .git folder
  234. if [ ! -d "./.git" ]; then
  235. echo "Expected ./.git folder to exist"
  236. exit 1
  237. fi
  238. # Verify auth token
  239. git config --global --add safe.directory "*"
  240. git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
  241. # needed to make checkout post cleanup succeed
  242. - name: Fix Checkout v3
  243. uses: actions/checkout@v3
  244. with:
  245. path: v3