Skip to content

SP-000 add path-suffixes to filter better for frontend E2E and vitests failing tests #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
repository: 'Staffbase/test-flaky'
# optional: name of the branch where it should check, default: main
branch: 'master'
# optional: path suffixes to filter the test files
path-suffixes: ".spec.ts,.spec.tsx,.test.ts,.test.tsx"
# prefix of the test run which should be filtered out
prefix: 'test-'
# URL of the Slack incoming webhooks
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
required: false
type: string
default: 'main'
path-suffixes:
required: false
type: string
prefix:
required: true
type: string
Expand Down Expand Up @@ -45,6 +48,7 @@ runs:
--slack-channel "${{ inputs.slack-channel-id }}" \
--auth-token "${{ inputs.token }}" \
--prefix "${{ inputs.prefix }}" \
--path-suffixes "${{ inputs.path-suffixes }}" \
${{ inputs.repository }} \
${{ inputs.branch }} \
> flaky_tests.json
Expand Down
14 changes: 14 additions & 0 deletions find_flaky_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class AppState:
repo: str
branch: str
slack_channel: str | None
path_suffixes: tuple[str, ...] | None
prefix: str | None
since: datetime | None
until: datetime | None
Expand All @@ -54,6 +55,14 @@ def parse_datetime(s):
else:
return datetime.strptime(s, '%Y-%m-%d')

# parse_suffixes_tuple is used to parse the suffixes argument from CLI
# example: ".spec.ts,.spec.tsx,.test.ts,test.tsx" -> ('.spec.ts', '.spec.tsx', '.test.ts', 'test.tsx')
def parse_suffixes_tuple(s: str | None) -> tuple[str, ...] | None:
if s is None:
return None
else:
return tuple(item.strip() for item in s.split(','))


def validate_and_split_repo(repo: str) -> (str, str):
if '/' not in repo:
Expand All @@ -69,6 +78,7 @@ def parse_args() -> AppState:
parser.add_argument('--auth-token', type=str, help='GitHub auth token (required)', required=True)
parser.add_argument('--slack-channel', type=str,
help='Format output for posting in Slack to given channel')
parser.add_argument('--path-suffixes', type=str, help='file path suffixes to filter annotations by. Could be tuple ".spec.ts,.spec.tsx,.test.ts,.test.tsx"',)
parser.add_argument('--prefix', type=str, help='prefix to filter annotations by', required=True)
parser.add_argument('--since', type=str,
help='date to start from, format YYYY-MM-DD defaults to start of day (midnight UTC), '
Expand All @@ -91,6 +101,7 @@ def parse_args() -> AppState:
since=parse_since(args.since),
until=parse_until(args.until),
slack_channel=args.slack_channel,
path_suffixes=parse_suffixes_tuple(args.path_suffixes),
prefix=args.prefix
)
except Exception as e:
Expand Down Expand Up @@ -221,6 +232,9 @@ def list_occurrences(state: AppState, r: Repository) -> List[Occurrence]:
if ann.path == '.github':
continue
# filter out build errors or other issues, which are not flaky tests
# filter out annotations that do not match the given suffixes in the file path
if state.path_suffixes and not ann.path.endswith(tuple(state.path_suffixes)):
continue
if not ann.message.startswith(state.prefix):
continue
# annotation path contains something like ".../packageA/TestA.xml" or ".../packageB/TestB.kt"
Expand Down