test.yml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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: 24.x
  18. - uses: actions/checkout@v6
  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@v6
  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. # Fetch tags
  79. - name: Checkout with fetch-tags
  80. uses: ./
  81. with:
  82. ref: test-data/v2/basic
  83. path: fetch-tags-test
  84. fetch-tags: true
  85. - name: Verify fetch-tags
  86. shell: bash
  87. run: __test__/verify-fetch-tags.sh
  88. # Sparse checkout
  89. - name: Sparse checkout
  90. uses: ./
  91. with:
  92. sparse-checkout: |
  93. __test__
  94. .github
  95. dist
  96. path: sparse-checkout
  97. - name: Verify sparse checkout
  98. run: __test__/verify-sparse-checkout.sh
  99. # Disabled sparse checkout in existing checkout
  100. - name: Disabled sparse checkout
  101. uses: ./
  102. with:
  103. path: sparse-checkout
  104. - name: Verify disabled sparse checkout
  105. shell: bash
  106. run: set -x && ls -l sparse-checkout/src/git-command-manager.ts
  107. # Sparse checkout (non-cone mode)
  108. - name: Sparse checkout (non-cone mode)
  109. uses: ./
  110. with:
  111. sparse-checkout: |
  112. /__test__/
  113. /.github/
  114. /dist/
  115. sparse-checkout-cone-mode: false
  116. path: sparse-checkout-non-cone-mode
  117. - name: Verify sparse checkout (non-cone mode)
  118. run: __test__/verify-sparse-checkout-non-cone-mode.sh
  119. # LFS
  120. - name: Checkout LFS
  121. uses: ./
  122. with:
  123. repository: actions/checkout # hardcoded, otherwise doesn't work from a fork
  124. ref: test-data/v2/lfs
  125. path: lfs
  126. lfs: true
  127. - name: Verify LFS
  128. shell: bash
  129. run: __test__/verify-lfs.sh
  130. # Submodules false
  131. - name: Checkout submodules false
  132. uses: ./
  133. with:
  134. ref: test-data/v2/submodule-ssh-url
  135. path: submodules-false
  136. - name: Verify submodules false
  137. run: __test__/verify-submodules-false.sh
  138. # Submodules one level
  139. - name: Checkout submodules true
  140. uses: ./
  141. with:
  142. ref: test-data/v2/submodule-ssh-url
  143. path: submodules-true
  144. submodules: true
  145. - name: Verify submodules true
  146. run: __test__/verify-submodules-true.sh
  147. # Submodules recursive
  148. - name: Checkout submodules recursive
  149. uses: ./
  150. with:
  151. ref: test-data/v2/submodule-ssh-url
  152. path: submodules-recursive
  153. submodules: recursive
  154. - name: Verify submodules recursive
  155. run: __test__/verify-submodules-recursive.sh
  156. # Worktree credentials
  157. - name: Checkout for worktree test
  158. uses: ./
  159. with:
  160. path: worktree-test
  161. - name: Verify worktree credentials
  162. shell: bash
  163. run: __test__/verify-worktree.sh worktree-test worktree-branch
  164. # Worktree credentials in container step
  165. - name: Verify worktree credentials in container step
  166. if: runner.os == 'Linux'
  167. uses: docker://bitnami/git:latest
  168. with:
  169. args: bash __test__/verify-worktree.sh worktree-test container-worktree-branch
  170. # Basic checkout using REST API
  171. - name: Remove basic
  172. if: runner.os != 'windows'
  173. run: rm -rf basic
  174. - name: Remove basic (Windows)
  175. if: runner.os == 'windows'
  176. shell: cmd
  177. run: rmdir /s /q basic
  178. - name: Override git version
  179. if: runner.os != 'windows'
  180. run: __test__/override-git-version.sh
  181. - name: Override git version (Windows)
  182. if: runner.os == 'windows'
  183. run: __test__\\override-git-version.cmd
  184. - name: Checkout basic using REST API
  185. uses: ./
  186. with:
  187. ref: test-data/v2/basic
  188. path: basic
  189. - name: Verify basic
  190. run: __test__/verify-basic.sh --archive
  191. test-proxy:
  192. runs-on: ubuntu-latest
  193. container:
  194. image: ghcr.io/actions/test-ubuntu-git:main.20240221.114913.703z
  195. options: --dns 127.0.0.1
  196. services:
  197. squid-proxy:
  198. image: ubuntu/squid:latest
  199. ports:
  200. - 3128:3128
  201. env:
  202. https_proxy: http://squid-proxy:3128
  203. steps:
  204. # Clone this repo
  205. - name: Checkout
  206. uses: actions/checkout@v6
  207. # Basic checkout using git
  208. - name: Checkout basic
  209. uses: ./
  210. with:
  211. ref: test-data/v2/basic
  212. path: basic
  213. - name: Verify basic
  214. run: __test__/verify-basic.sh
  215. # Basic checkout using REST API
  216. - name: Remove basic
  217. run: rm -rf basic
  218. - name: Override git version
  219. run: __test__/override-git-version.sh
  220. - name: Basic checkout using REST API
  221. uses: ./
  222. with:
  223. ref: test-data/v2/basic
  224. path: basic
  225. - name: Verify basic
  226. run: __test__/verify-basic.sh --archive
  227. test-bypass-proxy:
  228. runs-on: ubuntu-latest
  229. env:
  230. https_proxy: http://no-such-proxy:3128
  231. no_proxy: api.github.com,github.com
  232. steps:
  233. # Clone this repo
  234. - name: Checkout
  235. uses: actions/checkout@v6
  236. # Basic checkout using git
  237. - name: Checkout basic
  238. uses: ./
  239. with:
  240. ref: test-data/v2/basic
  241. path: basic
  242. - name: Verify basic
  243. run: __test__/verify-basic.sh
  244. - name: Remove basic
  245. run: rm -rf basic
  246. # Basic checkout using REST API
  247. - name: Override git version
  248. run: __test__/override-git-version.sh
  249. - name: Checkout basic using REST API
  250. uses: ./
  251. with:
  252. ref: test-data/v2/basic
  253. path: basic
  254. - name: Verify basic
  255. run: __test__/verify-basic.sh --archive
  256. test-git-container:
  257. runs-on: ubuntu-latest
  258. container: bitnami/git:latest
  259. steps:
  260. # Clone this repo
  261. - name: Checkout
  262. uses: actions/checkout@v6
  263. with:
  264. path: localClone
  265. # Basic checkout using git
  266. - name: Checkout basic
  267. uses: ./localClone
  268. with:
  269. ref: test-data/v2/basic
  270. - name: Verify basic
  271. run: |
  272. if [ ! -f "./basic-file.txt" ]; then
  273. echo "Expected basic file does not exist"
  274. exit 1
  275. fi
  276. # Verify .git folder
  277. if [ ! -d "./.git" ]; then
  278. echo "Expected ./.git folder to exist"
  279. exit 1
  280. fi
  281. # Verify auth token
  282. git config --global --add safe.directory "*"
  283. git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
  284. # needed to make checkout post cleanup succeed
  285. - name: Fix Checkout v6
  286. uses: actions/checkout@v6
  287. with:
  288. path: localClone
  289. test-output:
  290. runs-on: ubuntu-latest
  291. steps:
  292. # Clone this repo
  293. - name: Checkout
  294. uses: actions/checkout@v6
  295. with:
  296. path: actions-checkout
  297. # Basic checkout using git
  298. - name: Checkout basic
  299. id: checkout
  300. uses: ./actions-checkout
  301. with:
  302. path: cloned-using-local-action
  303. ref: test-data/v2/basic
  304. # Verify output
  305. - name: Verify output
  306. run: |
  307. echo "Commit: ${{ steps.checkout.outputs.commit }}"
  308. echo "Ref: ${{ steps.checkout.outputs.ref }}"
  309. if [ "${{ steps.checkout.outputs.ref }}" != "test-data/v2/basic" ]; then
  310. echo "Expected ref to be test-data/v2/basic"
  311. exit 1
  312. fi
  313. if [ "${{ steps.checkout.outputs.commit }}" != "82f71901cf8c021332310dcc8cdba84c4193ff5d" ]; then
  314. echo "Expected commit to be 82f71901cf8c021332310dcc8cdba84c4193ff5d"
  315. exit 1
  316. fi