mirror of
https://github.com/actions/checkout.git
synced 2025-03-28 11:00:05 +01:00
feat: added test for sparse-checkout
This commit is contained in:
parent
d963058cca
commit
360aefd1c1
3 changed files with 84 additions and 1 deletions
22
.github/workflows/test.yml
vendored
22
.github/workflows/test.yml
vendored
|
@ -113,6 +113,26 @@ jobs:
|
|||
- name: Verify submodules recursive
|
||||
run: __test__/verify-submodules-recursive.sh
|
||||
|
||||
# Sparse checkout basic example
|
||||
- name: Sparse checkout basic example
|
||||
uses: ./
|
||||
with:
|
||||
sparse-checkout: .
|
||||
- name: Verify sparse checkout basic
|
||||
run: __test__/verify-sparse-checkout-basic.sh
|
||||
|
||||
# Sparse checkout example
|
||||
- name: Sparse checkout example
|
||||
uses: ./
|
||||
with:
|
||||
sparse-checkout: |
|
||||
.github
|
||||
src
|
||||
- name: Verify sparse checkout basic
|
||||
run: __test__/verify-sparse-checkout-basic.sh
|
||||
- name: Verify sparse checkout example
|
||||
run: __test__/verify-sparse-checkout.sh
|
||||
|
||||
# Basic checkout using REST API
|
||||
- name: Remove basic
|
||||
if: runner.os != 'windows'
|
||||
|
@ -205,7 +225,7 @@ jobs:
|
|||
path: basic
|
||||
- name: Verify basic
|
||||
run: __test__/verify-basic.sh --archive
|
||||
|
||||
|
||||
test-git-container:
|
||||
runs-on: ubuntu-latest
|
||||
container: bitnami/git:latest
|
||||
|
|
23
__test__/verify-sparse-checkout-basic.sh
Executable file
23
__test__/verify-sparse-checkout-basic.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
SPARSE=$(git sparse-checkout list)
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Failed to validate sparse-checkout"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check that sparse-checkout list is not empty
|
||||
if [ -z "$SPARSE" ]; then
|
||||
echo "Expected sparse-checkout list to not be empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check that all folders from sparse-checkout exists
|
||||
for pattern in $(git sparse-checkout list)
|
||||
do
|
||||
if [ ! -d "$pattern" ]; then
|
||||
echo "Expected directory '$pattern' to exist"
|
||||
exit 1
|
||||
fi
|
||||
done
|
40
__test__/verify-sparse-checkout.sh
Executable file
40
__test__/verify-sparse-checkout.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check that only sparse-checkout folders has been fetched
|
||||
for pattern in $(git ls-tree --name-only HEAD)
|
||||
do
|
||||
if [ -d "$pattern" ]; then
|
||||
if [[ "$pattern" != ".github" && "$pattern" != "src" ]]; then
|
||||
echo "Expected directory '$pattern' to not exist"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Check that .github and its childrens has been fetched correctly
|
||||
if [ ! -d "./.github" ]; then
|
||||
echo "Expected directory '.github' to exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for file in $(git ls-tree -r --name-only HEAD .github)
|
||||
do
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "Expected file '$file' to exist"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Check that src and its childrens has been fetched correctly
|
||||
if [ ! -d "./src" ]; then
|
||||
echo "Expected directory 'src' to exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for file in $(git ls-tree -r --name-only HEAD src)
|
||||
do
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "Expected file '$file' to exist"
|
||||
exit 1
|
||||
fi
|
||||
done
|
Loading…
Add table
Reference in a new issue