Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions actions/go-flaky-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
description: "Include only the top K flaky tests by distinct branches count in analysis"
required: false
default: "3"
ignored-tests:
description: "Comma-delimited test names to skip failures for"
required: false
default: ""

runs:
using: "composite"
Expand Down Expand Up @@ -67,3 +71,4 @@ runs:
REPOSITORY_DIRECTORY: ${{ inputs.repository-directory }}
SKIP_POSTING_ISSUES: ${{ inputs.skip-posting-issues }}
TOP_K: ${{ inputs.top-k }}
IGNORED_TESTS: ${{ inputs.ignored-tests }}
21 changes: 21 additions & 0 deletions actions/go-flaky-tests/cmd/go-flaky-tests/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ func (t *TestFailureAnalyzer) AnalyzeFailures(config Config) (*FailuresReport, e
if err != nil {
return nil, fmt.Errorf("failed to parse test failures: %w", err)
}

// Filter out ignored tests
if len(config.IgnoredTests) > 0 {
log.Printf("🚫 Filtering out %d ignored tests: %v", len(config.IgnoredTests), config.IgnoredTests)
var filteredTests []FlakyTest
for _, test := range flakyTests {
ignored := false
for _, ignoredTest := range config.IgnoredTests {
if test.TestName == ignoredTest {
ignored = true
break
}
}
if !ignored {
filteredTests = append(filteredTests, test)
}
}
log.Printf("📊 Filtered tests: %d -> %d (removed %d ignored tests)", len(flakyTests), len(filteredTests), len(flakyTests)-len(filteredTests))
flakyTests = filteredTests
}

if len(flakyTests) > config.TopK {
flakyTests = flakyTests[:config.TopK]
}
Expand Down
19 changes: 19 additions & 0 deletions actions/go-flaky-tests/cmd/go-flaky-tests/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"os"
"strconv"
"strings"
)

type Config struct {
Expand All @@ -14,6 +15,7 @@ type Config struct {
RepositoryDirectory string
SkipPostingIssues bool
TopK int
IgnoredTests []string
}

func getConfigFromEnv() Config {
Expand All @@ -26,6 +28,7 @@ func getConfigFromEnv() Config {
RepositoryDirectory: getEnvWithDefault("REPOSITORY_DIRECTORY", "."),
SkipPostingIssues: getBoolEnvWithDefault("SKIP_POSTING_ISSUES", true),
TopK: getIntEnvWithDefault("TOP_K", 3),
IgnoredTests: getStringSliceFromEnv("IGNORED_TESTS"),
}
}

Expand All @@ -51,3 +54,19 @@ func getIntEnvWithDefault(key string, defaultValue int) int {
}
return defaultValue
}

func getStringSliceFromEnv(key string) []string {
value := os.Getenv(key)
if value == "" {
return []string{}
}

var result []string
for _, item := range strings.Split(value, ",") {
trimmed := strings.TrimSpace(item)
if trimmed != "" {
result = append(result, trimmed)
}
}
return result
}
8 changes: 7 additions & 1 deletion actions/go-flaky-tests/run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ usage() {
echo " --repository-directory DIR Repository directory (default: current directory)"
echo " --skip-posting-issues BOOL Skip creating GitHub issues (default: ${DEFAULT_SKIP_POSTING_ISSUES})"
echo " --top-k NUM Number of top flaky tests to analyze (default: ${DEFAULT_TOP_K})"
echo " --ignored-tests TESTS Comma-delimited test names to skip failures for"
echo ""
echo "Environment variables:"
echo " LOKI_URL, LOKI_USERNAME, LOKI_PASSWORD, REPOSITORY, TIME_RANGE,"
echo " REPOSITORY_DIRECTORY, GITHUB_TOKEN, SKIP_POSTING_ISSUES, TOP_K"
echo " REPOSITORY_DIRECTORY, GITHUB_TOKEN, SKIP_POSTING_ISSUES, TOP_K, IGNORED_TESTS"
echo ""
echo "Example:"
echo " $0 --loki-url http://localhost:3100 --repository myorg/myrepo --time-range 7d"
Expand Down Expand Up @@ -77,6 +78,10 @@ while [[ $# -gt 0 ]]; do
TOP_K="$2"
shift 2
;;
--ignored-tests)
IGNORED_TESTS="$2"
shift 2
;;
*)
echo "Unknown option: $1"
usage
Expand Down Expand Up @@ -111,6 +116,7 @@ export GITHUB_TOKEN
export REPOSITORY_DIRECTORY
export SKIP_POSTING_ISSUES
export TOP_K
export IGNORED_TESTS

echo "🔧 Running go-flaky-tests locally..."
echo "📊 Repository: $REPOSITORY"
Expand Down
Loading