Skip to content

Commit 30ce0c5

Browse files
committed
Actions: Add integration tests for configured path filters
Use the common structure from the existing test for default filters. Check both query output finding workflows and actions, and source archive output showing all extracted YAML files. The test for only `paths-ignore` fails in this commit, demonstrating a bug: we start with all YAML files rather than starting with the default includes. The tests for `paths` reflect current behaviour which is consistent with other languages: `paths` overrides the default inclusions, and only files under `paths` are included. This may not be the best user experience for Actions, since we want to scan all workflow and action files even in the presence of `paths`, but that is not currently addressed.
1 parent bd3342a commit 30ce0c5

10 files changed

+41
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| src/included/action.yml:1:1:11:32 | name: ' ... action' |
2+
| src/included/unreachable-workflow.yml:1:1:12:33 | name: A ... orkflow |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| src/.github/action.yaml:1:1:11:32 | name: ' ... action' |
2+
| src/.github/actions/action-name/action.yml:1:1:11:32 | name: ' ... action' |
3+
| src/.github/workflows/workflow.yml:1:1:12:33 | name: A workflow |
4+
| src/action.yml:1:1:11:32 | name: ' ... action' |
5+
| src/included/action.yml:1:1:11:32 | name: ' ... action' |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| src/included/action.yml:1:1:11:32 | name: ' ... action' |
2+
| src/included/unreachable-workflow.yml:1:1:12:33 | name: A ... orkflow |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
paths:
2+
- 'included'
3+
paths-ignore:
4+
- 'excluded'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
paths-ignore:
2+
- 'excluded'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
paths:
2+
- 'included'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
src/included/action.yml
2+
src/included/not-an-action.yml
3+
src/included/unreachable-workflow.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
src/.github/action.yaml
2+
src/.github/actions/action-name/action.yml
3+
src/.github/workflows/workflow.yml
4+
src/action.yml
5+
src/included/action.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
src/included/action.yml
2+
src/included/not-an-action.yml
3+
src/included/unreachable-workflow.yml

actions/ql/integration-tests/filters/test.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,16 @@
33
@pytest.mark.ql_test(expected=".default-filters.expected")
44
def test_default_filters(codeql, actions, check_source_archive):
55
check_source_archive.expected_suffix = ".default-filters.expected"
6-
codeql.database.create(source_root="src")
6+
codeql.database.create(source_root="src")
7+
8+
@pytest.mark.ql_test(expected=".paths-only.expected")
9+
def test_config_paths_only(codeql, actions):
10+
codeql.database.create(source_root="src", codescanning_config="codeql-config.paths-only.yml")
11+
12+
@pytest.mark.ql_test(expected=".paths-ignore-only.expected")
13+
def test_config_paths_ignore_only(codeql, actions):
14+
codeql.database.create(source_root="src", codescanning_config="codeql-config.paths-ignore-only.yml")
15+
16+
@pytest.mark.ql_test(expected=".paths-and-paths-ignore.expected")
17+
def test_config_paths_and_paths_ignore(codeql, actions):
18+
codeql.database.create(source_root="src", codescanning_config="codeql-config.paths-and-paths-ignore.yml")

0 commit comments

Comments
 (0)