Skip to content

Commit

Permalink
feat: sparse-checkout test script unified in only one script
Browse files Browse the repository at this point in the history
  • Loading branch information
dfdez committed Jun 7, 2023
1 parent d8614bd commit 7301241
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 39 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
shell: bash
run: __test__/verify-side-by-side.sh

# Sparse checkout
# Sparse checkout
- name: Sparse checkout
uses: ./
with:
Expand All @@ -82,9 +82,7 @@ jobs:
dist
path: sparse-checkout

- name: Verify sparse checkout basic
run: __test__/verify-sparse-checkout-basic.sh
- name: Verify sparse checkout example
- name: Verify sparse checkout
run: __test__/verify-sparse-checkout.sh

# LFS
Expand Down
32 changes: 0 additions & 32 deletions __test__/verify-sparse-checkout-basic.sh

This file was deleted.

26 changes: 24 additions & 2 deletions __test__/verify-sparse-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ fi
# Verify sparse-checkout
cd sparse-checkout

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 of the sparse checkout exist
for pattern in $SPARSE
do
if [ ! -d "$pattern" ]; then
echo "Expected directory '$pattern' to exist"
exit 1
fi
done

checkSparse () {
if [ ! -d "./$1" ]; then
echo "Expected directory '$1' to exist"
Expand All @@ -24,12 +46,12 @@ checkSparse () {
done
}

# Check that all folders and its childrens has been fetched correctly
# Check that all folders and their children have been checked out
checkSparse __test__
checkSparse .github
checkSparse dist

# Check that only sparse-checkout folders has been fetched
# Check that only sparse-checkout folders have been checked out
for pattern in $(git ls-tree --name-only HEAD)
do
if [ -d "$pattern" ]; then
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inputs:
sparse-checkout:
description: >
Do a sparse checkout on given patterns.
Each pattern should be sepparated with new lines
Each pattern should be separated with new lines
default: null
fetch-depth:
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
Expand Down

0 comments on commit 7301241

Please sign in to comment.