Skip to content

Commit cb97568

Browse files
authored
chore: fix lint github action (GoogleCloudPlatform#1925)
* use files changed github action * fix yaml syntax * use files instead of dirs * testing modifying a file * debug info * format files changed correctly * Revert "testing modifying a file" This reverts commit 22da5ea. * get rid of skipped dir (redundant)
1 parent 4aabf82 commit cb97568

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v4
25-
with:
26-
ref: ${{ github.event.pull_request.head.ref }}
27-
fetch-depth: 5
2825
- name: Install PHP
2926
uses: shivammathur/setup-php@v2
3027
with:
3128
php-version: '8.0'
29+
- name: Get changed files
30+
id: changedFiles
31+
uses: tj-actions/changed-files@v39
3232
- uses: jwalton/gh-find-current-pr@v1
3333
id: findPr
3434
with:
@@ -39,5 +39,5 @@ jobs:
3939
git fetch --no-tags --prune --depth=5 origin main
4040
bash testing/run_staticanalysis_check.sh
4141
env:
42-
PULL_REQUEST_NUMBER: ${{ steps.findPr.outputs.pr }}
43-
42+
FILES_CHANGED: ${{ steps.changedFiles.outputs.all_changed_files }}
43+
PULL_REQUEST_NUMBER: ${{ steps.findPr.outputs.pr }}

testing/run_staticanalysis_check.sh

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ if [ "${BASH_DEBUG}" = "true" ]; then
1717
set -x
1818
fi
1919

20-
if [ "${TEST_DIRECTORIES}" = "" ]; then
21-
TEST_DIRECTORIES="*"
22-
fi
23-
2420
SKIP_DIRS=(
2521
dialogflow
2622
iot
@@ -29,11 +25,15 @@ SKIP_DIRS=(
2925
TMP_REPORT_DIR=$(mktemp -d)
3026
SUCCEEDED_FILE=${TMP_REPORT_DIR}/succeeded
3127
FAILED_FILE=${TMP_REPORT_DIR}/failed
32-
SKIPPED_FILE=${TMP_REPORT_DIR}/skipped
3328

34-
# Determine all files changed on this branch
35-
# (will be empty if running from "main").
36-
FILES_CHANGED=$(git diff --name-only HEAD origin/main)
29+
if [ "${TEST_DIRECTORIES}" = "" ]; then
30+
TEST_DIRECTORIES="*"
31+
fi
32+
33+
if [ "${FILES_CHANGED}" = "" ]; then
34+
FILES_CHANGED=""
35+
fi
36+
FILES_CHANGED=$(echo $FILES_CHANGED | tr " " "\n")
3737

3838
# If the label `kokoro:run-all` is added, or if we were not triggered from a Pull
3939
# Request, run the whole test suite.
@@ -56,13 +56,11 @@ do
5656
if [ "$RUN_ALL_TESTS" -ne "1" ]; then
5757
if ! grep -q ^$dir <<< "$FILES_CHANGED" ; then
5858
echo "Skipping tests in $dir (unchanged)"
59-
echo "$dir: skipped" >> "${SKIPPED_FILE}"
6059
continue
6160
fi
6261
fi
6362
if [[ " ${SKIP_DIRS[@]} " =~ " ${dir} " ]]; then
6463
printf "Skipping $dir (explicitly flagged to be skipped)\n\n"
65-
echo "$dir: skipped" >> "${SKIPPED_FILE}"
6664
continue
6765
fi
6866
composer update --working-dir=$dir --ignore-platform-reqs -q
@@ -90,13 +88,6 @@ if [ -f "${SUCCEEDED_FILE}" ]; then
9088
echo "-------------------------------"
9189
fi
9290

93-
if [ -f "${SKIPPED_FILE}" ]; then
94-
echo "--------- SKIPPED --------------"
95-
cat "${SKIPPED_FILE}"
96-
echo "--------------------------------"
97-
# Report any skips
98-
fi
99-
10091
if [ -f "${FAILED_FILE}" ]; then
10192
echo "--------- Failed --------------"
10293
cat "${FAILED_FILE}"

0 commit comments

Comments
 (0)