11#! /bin/bash
2- set -ex
2+ set -e
33
4+ if [ ! -z " ${DEBUG} " ]; then set -x; fi
45if [ -z " ${GITHUB_ACTIONS} " ]; then
56 exec okv ${@ }
67else
78 strict_mode=' --no-strict'
89 if [ " ${INPUT_STRICT} " = " true" ]; then strict_mode=' ' ; fi
910 INPUT_CPU_NUM=" $( env | sed -n ' s/^INPUT_CPU-NUM=\(.*\)/\1/p' ) "
11+ INPUT_FILE_RESTRICTIONS=" $( env | sed -n ' s/^INPUT_FILE-RESTRICTIONS=\(.*\)/\1/p' ) "
1012 schema_flag=" --ok=${INPUT_OK} "
1113 if [ ! -z " ${INPUT_SCHEMA} " ]; then
1214 schema_flag=" --schema=${INPUT_SCHEMA} "
1315 fi
14- output=$( okv ${schema_flag} --cpu-num=${INPUT_CPU_NUM} --parser=${INPUT_PARSER} ${strict_mode} -path=${INPUT_PATH} )
15- result=$?
16+ output=" "
17+ result=" 0"
18+ set +e
19+ if [ -z " ${INPUT_FILE_RESTRICTIONS} " ]; then
20+ output=$( okv ${schema_flag} --cpu-num=${INPUT_CPU_NUM} --parser=${INPUT_PARSER} ${strict_mode} -path=${INPUT_PATH} )
21+ result=$?
22+ echo " ${output} "
23+ else
24+ # INPUT_FILE_RESTRICTIONS is expected to be a space-separated array
25+ # of files
26+ file_arr=($INPUT_FILE_RESTRICTIONS )
27+ for file in ${file_arr[@]} ; do
28+ # If an input path is also provided, it is expected to serve as an
29+ # enforced prefix for each of the file restrictions. In the case
30+ # of the pull request, this means that added and modified files
31+ # must exist within a particular directory or match a file
32+ if [[ ! -z " ${INPUT_PATH} " ]] && [[ " ${file} " != ${INPUT_PATH} * .y* ml ]]; then
33+ continue
34+ fi
35+ if [ ! -f " ${file} " ]; then
36+ continue
37+ fi
38+ tmp_output=$( okv ${schema_flag} --cpu-num=${INPUT_CPU_NUM} --parser=${INPUT_PARSER} ${strict_mode} -path=${file} )
39+ tmp_result=$?
40+ # Loop over all files before throwing non-zero exit below
41+ if [ " ${tmp_result} " == " 0" ]; then
42+ continue
43+ fi
44+ if [ " ${result} " == " 0" ]; then
45+ result=" $tmp_result "
46+ fi
47+ if [ -z " ${output} " ]; then
48+ output=" ${tmp_output} "
49+ echo " ${output} "
50+ else
51+ echo " ----
52+ ${tmp_output} "
53+ output=" ${output}
54+ ----
55+ ${tmp_output} "
56+ fi
57+ done
58+ fi
59+ set -e
1660 echo " ::set-output name=results::$( echo $output ) "
1761 if [ " ${result} " != " 0" ]; then exit 1; fi
1862fi
0 commit comments