test.yml 8.7 KB

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