Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 1af13f0

Browse files
authored
Better retrieval of frontend path keyword (#19)
- Improved retrieval of frontend path keyword using awk to retrieve final element - Improved handling of field separator to avoid confusion
1 parent f0dfb6a commit 1af13f0

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

.github/workflows/code-coverage.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,19 @@ jobs:
104104
fi
105105
106106
PLUGIN_COVERAGE=""
107-
## Set field delimiter so that we can easily split the path
108-
IFS='/'
107+
## Store original field delimiter value
108+
BACKUP_IFS=$IFS
109109
for i in "${!PATHS[@]}"; do
110-
read -a splitpath <<<${PATHS[i]}
111-
FINAL_ELEMENT=-1
112-
if [[ ${#PATHS[@]} -eq 1 ]]; then
113-
FINAL_ELEMENT=0
114-
fi
110+
## Reset field delimiter
111+
IFS=$BACKUP_IFS
112+
keyword=$(echo ${PATHS[i]} | awk -F '/' '{ print $NF }')
113+
## Set field delimiter so that we can easily grep the correct path in coverage result
114+
IFS='/'
115115
## Retrive line coverage from result
116116
if [ $i -lt $((${#PATHS[@]} - 1)) ]; then
117-
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep ${splitpath[$FINAL_ELEMENT]} | head -1 | cut -d '|' -f 1,5) + "
117+
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep $keyword | head -1 | cut -d '|' -f 1,5) + "
118118
else
119-
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep ${splitpath[$FINAL_ELEMENT]} | head -1 | cut -d '|' -f 1,5)"
119+
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep $keyword | head -1 | cut -d '|' -f 1,5)"
120120
fi
121121
done
122122
echo "::set-output name=coverage::$(echo -e $PLUGIN_COVERAGE)"
@@ -193,19 +193,19 @@ jobs:
193193
fi
194194
195195
PLUGIN_COVERAGE=""
196-
## Set field delimiter so that we can easily split the path
197-
IFS='/'
196+
## Store original field delimiter value
197+
BACKUP_IFS=$IFS
198198
for i in "${!PATHS[@]}"; do
199-
read -a splitpath <<<${PATHS[i]}
200-
FINAL_ELEMENT=-1
201-
if [[ ${#PATHS[@]} -eq 1 ]]; then
202-
FINAL_ELEMENT=0
203-
fi
199+
## Reset field delimiter
200+
IFS=$BACKUP_IFS
201+
keyword=$(echo ${PATHS[i]} | awk -F '/' '{ print $NF }')
202+
## Set field delimiter so that we can easily grep the correct path in coverage result
203+
IFS='/'
204204
## Retrive line coverage from result
205205
if [ $i -lt $((${#PATHS[@]} - 1)) ]; then
206-
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep ${splitpath[$FINAL_ELEMENT]} | head -1 | cut -d '|' -f 1,5) + "
206+
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep $keyword | head -1 | cut -d '|' -f 1,5) + "
207207
else
208-
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep ${splitpath[$FINAL_ELEMENT]} | head -1 | cut -d '|' -f 1,5)"
208+
PLUGIN_COVERAGE="$PLUGIN_COVERAGE$(echo $RESULT | grep $keyword | head -1 | cut -d '|' -f 1,5)"
209209
fi
210210
done
211211
echo "::set-output name=coverage::$(echo -e $PLUGIN_COVERAGE)"

0 commit comments

Comments
 (0)