Skip to content

Commit 283503b

Browse files
committed
Actions: Fix handling of paths-ignore in autobuild scripts
Always concatenate the default filters with the user-provided filters. This ensures that when `paths-ignore` is provided, we begin with the default path inclusions, not all YAML files. This makes the `paths-ignore-only` integration test variant under `filters` pass. The handling of `paths` is unchanged: if provided, this overrides the default filters.
1 parent 30ce0c5 commit 283503b

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

actions/extractor/tools/autobuild-impl.ps1

+24-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
if (($null -ne $env:LGTM_INDEX_INCLUDE) -or ($null -ne $env:LGTM_INDEX_EXCLUDE) -or ($null -ne $env:LGTM_INDEX_FILTERS)) {
2-
Write-Output 'Path filters set. Passing them through to the JavaScript extractor.'
3-
} else {
4-
Write-Output 'No path filters set. Using the default filters.'
5-
# Note: We're adding the `reusable_workflows` subdirectories to proactively
6-
# record workflows that were called cross-repo, check them out locally,
7-
# and enable an interprocedural analysis across the workflow files.
8-
# These workflows follow the convention `.github/reusable_workflows/<nwo>/*.ya?ml`
9-
$DefaultPathFilters = @(
10-
'exclude:**/*',
11-
'include:.github/workflows/*.yml',
12-
'include:.github/workflows/*.yaml',
13-
'include:.github/reusable_workflows/**/*.yml',
14-
'include:.github/reusable_workflows/**/*.yaml',
15-
'include:**/action.yml',
16-
'include:**/action.yaml'
17-
)
1+
# Note: We're adding the `reusable_workflows` subdirectories to proactively
2+
# record workflows that were called cross-repo, check them out locally,
3+
# and enable an interprocedural analysis across the workflow files.
4+
# These workflows follow the convention `.github/reusable_workflows/<nwo>/*.ya?ml`
5+
$DefaultPathFilters = @(
6+
'exclude:**/*',
7+
'include:.github/workflows/*.yml',
8+
'include:.github/workflows/*.yaml',
9+
'include:.github/reusable_workflows/**/*.yml',
10+
'include:.github/reusable_workflows/**/*.yaml',
11+
'include:**/action.yml',
12+
'include:**/action.yaml'
13+
)
1814

15+
if ($null -ne $env:LGTM_INDEX_FILTERS) {
16+
Write-Output 'LGTM_INDEX_FILTERS set. Using the default filters together with the user-provided filters, and passing through to the JavaScript extractor.'
17+
# Begin with the default path inclusions only,
18+
# followed by the user-provided filters.
19+
# If the user provided `paths`, those patterns override the default inclusions
20+
# (because `LGTM_INDEX_FILTERS` will begin with `exclude:**/*`).
21+
# If the user provided `paths-ignore`, those patterns are excluded.
22+
$PathFilters = ($DefaultPathFilters -join "`n") + "`n" + $env:LGTM_INDEX_FILTERS
23+
$env:LGTM_INDEX_FILTERS = $PathFilters
24+
} else {
25+
Write-Output 'LGTM_INDEX_FILTERS not set. Using the default filters, and passing through to the JavaScript extractor.'
1926
$env:LGTM_INDEX_FILTERS = $DefaultPathFilters -join "`n"
2027
}
2128

actions/extractor/tools/autobuild.sh

+15-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ include:**/action.yaml
1717
END
1818
)
1919

20-
if [ -n "${LGTM_INDEX_INCLUDE:-}" ] || [ -n "${LGTM_INDEX_EXCLUDE:-}" ] || [ -n "${LGTM_INDEX_FILTERS:-}" ] ; then
21-
echo "Path filters set. Passing them through to the JavaScript extractor."
20+
if [ -n "${LGTM_INDEX_FILTERS:-}" ]; then
21+
echo "LGTM_INDEX_FILTERS set. Using the default filters together with the user-provided filters, and passing through to the JavaScript extractor."
22+
# Begin with the default path inclusions only,
23+
# followed by the user-provided filters.
24+
# If the user provided `paths`, those patterns override the default inclusions
25+
# (because `LGTM_INDEX_FILTERS` will begin with `exclude:**/*`).
26+
# If the user provided `paths-ignore`, those patterns are excluded.
27+
PATH_FILTERS="$(cat << END
28+
${DEFAULT_PATH_FILTERS}
29+
${LGTM_INDEX_FILTERS}
30+
END
31+
)"
32+
LGTM_INDEX_FILTERS="${PATH_FILTERS}"
33+
export LGTM_INDEX_FILTERS
2234
else
23-
echo "No path filters set. Using the default filters."
35+
echo "LGTM_INDEX_FILTERS not set. Using the default filters, and passing through to the JavaScript extractor."
2436
LGTM_INDEX_FILTERS="${DEFAULT_PATH_FILTERS}"
2537
export LGTM_INDEX_FILTERS
2638
fi

0 commit comments

Comments
 (0)