2
0

test.yml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. # 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. # Worktree credentials
  147. - name: Checkout for worktree test
  148. uses: ./
  149. with:
  150. path: worktree-test
  151. - name: Verify worktree credentials
  152. shell: bash
  153. run: __test__/verify-worktree.sh worktree-test worktree-branch
  154. # Worktree credentials in container step
  155. - name: Verify worktree credentials in container step
  156. if: runner.os == 'Linux'
  157. uses: docker://bitnami/git:latest
  158. with:
  159. args: bash __test__/verify-worktree.sh worktree-test container-worktree-branch
  160. # Basic checkout using REST API
  161. - name: Remove basic
  162. if: runner.os != 'windows'
  163. run: rm -rf basic
  164. - name: Remove basic (Windows)
  165. if: runner.os == 'windows'
  166. shell: cmd
  167. run: rmdir /s /q basic
  168. - name: Override git version
  169. if: runner.os != 'windows'
  170. run: __test__/override-git-version.sh
  171. - name: Override git version (Windows)
  172. if: runner.os == 'windows'
  173. run: __test__\\override-git-version.cmd
  174. - name: Checkout basic using REST API
  175. uses: ./
  176. with:
  177. ref: test-data/v2/basic
  178. path: basic
  179. - name: Verify basic
  180. run: __test__/verify-basic.sh --archive
  181. test-proxy:
  182. runs-on: ubuntu-latest
  183. container:
  184. image: ghcr.io/actions/test-ubuntu-git:main.20240221.114913.703z
  185. options: --dns 127.0.0.1
  186. services:
  187. squid-proxy:
  188. image: ubuntu/squid:latest
  189. ports:
  190. - 3128:3128
  191. env:
  192. https_proxy: http://squid-proxy:3128
  193. steps:
  194. # Clone this repo
  195. - name: Checkout
  196. uses: actions/checkout@v6
  197. # Basic checkout using git
  198. - name: Checkout basic
  199. uses: ./
  200. with:
  201. ref: test-data/v2/basic
  202. path: basic
  203. - name: Verify basic
  204. run: __test__/verify-basic.sh
  205. # Basic checkout using REST API
  206. - name: Remove basic
  207. run: rm -rf basic
  208. - name: Override git version
  209. run: __test__/override-git-version.sh
  210. - name: Basic checkout using REST API
  211. uses: ./
  212. with:
  213. ref: test-data/v2/basic
  214. path: basic
  215. - name: Verify basic
  216. run: __test__/verify-basic.sh --archive
  217. test-bypass-proxy:
  218. runs-on: ubuntu-latest
  219. env:
  220. https_proxy: http://no-such-proxy:3128
  221. no_proxy: api.github.com,github.com
  222. steps:
  223. # Clone this repo
  224. - name: Checkout
  225. uses: actions/checkout@v6
  226. # Basic checkout using git
  227. - name: Checkout basic
  228. uses: ./
  229. with:
  230. ref: test-data/v2/basic
  231. path: basic
  232. - name: Verify basic
  233. run: __test__/verify-basic.sh
  234. - name: Remove basic
  235. run: rm -rf basic
  236. # Basic checkout using REST API
  237. - name: Override git version
  238. run: __test__/override-git-version.sh
  239. - name: Checkout basic using REST API
  240. uses: ./
  241. with:
  242. ref: test-data/v2/basic
  243. path: basic
  244. - name: Verify basic
  245. run: __test__/verify-basic.sh --archive
  246. test-git-container:
  247. runs-on: ubuntu-latest
  248. container: bitnami/git:latest
  249. steps:
  250. # Clone this repo
  251. - name: Checkout
  252. uses: actions/checkout@v6
  253. with:
  254. path: localClone
  255. # Basic checkout using git
  256. - name: Checkout basic
  257. uses: ./localClone
  258. with:
  259. ref: test-data/v2/basic
  260. - name: Verify basic
  261. run: |
  262. if [ ! -f "./basic-file.txt" ]; then
  263. echo "Expected basic file does not exist"
  264. exit 1
  265. fi
  266. # Verify .git folder
  267. if [ ! -d "./.git" ]; then
  268. echo "Expected ./.git folder to exist"
  269. exit 1
  270. fi
  271. # Verify auth token
  272. git config --global --add safe.directory "*"
  273. git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
  274. # needed to make checkout post cleanup succeed
  275. - name: Fix Checkout v6
  276. uses: actions/checkout@v6
  277. with:
  278. path: localClone
  279. test-output:
  280. runs-on: ubuntu-latest
  281. steps:
  282. # Clone this repo
  283. - name: Checkout
  284. uses: actions/checkout@v6
  285. with:
  286. path: actions-checkout
  287. # Basic checkout using git
  288. - name: Checkout basic
  289. id: checkout
  290. uses: ./actions-checkout
  291. with:
  292. path: cloned-using-local-action
  293. ref: test-data/v2/basic
  294. # Verify output
  295. - name: Verify output
  296. run: |
  297. echo "Commit: ${{ steps.checkout.outputs.commit }}"
  298. echo "Ref: ${{ steps.checkout.outputs.ref }}"
  299. if [ "${{ steps.checkout.outputs.ref }}" != "test-data/v2/basic" ]; then
  300. echo "Expected ref to be test-data/v2/basic"
  301. exit 1
  302. fi
  303. if [ "${{ steps.checkout.outputs.commit }}" != "82f71901cf8c021332310dcc8cdba84c4193ff5d" ]; then
  304. echo "Expected commit to be 82f71901cf8c021332310dcc8cdba84c4193ff5d"
  305. exit 1
  306. fi