Skip to content

Commit df4bb66

Browse files
authored
ci: reuse each submission score for its summary (#174)
1 parent 4d2c564 commit df4bb66

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎scripts/validate-security-signals-submission.go‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ func main() {
1616
}
1717

1818
func run(args []string, stdout io.Writer) error {
19-
var submissionDir string
19+
var submissionDir, scorePath string
2020
jsonOutput := false
21-
for _, arg := range args {
21+
for len(args) > 0 {
22+
arg := args[0]
23+
args = args[1:]
2224
switch arg {
2325
case "--help", "-h":
2426
fmt.Fprint(stdout, helpText())
2527
return nil
28+
case "--score-file":
29+
if len(args) == 0 || args[0] == "" {
30+
return fmt.Errorf("--score-file requires a path")
31+
}
32+
scorePath = args[0]
33+
args = args[1:]
2634
case "--json":
2735
jsonOutput = true
2836
default:
@@ -45,6 +53,11 @@ func run(args []string, stdout io.Writer) error {
4553
if err != nil {
4654
return err
4755
}
56+
if scorePath != "" {
57+
if err := runner.WriteJSONFile(scorePath, result); err != nil {
58+
return err
59+
}
60+
}
4861
if jsonOutput {
4962
return runner.WriteJSON(stdout, result)
5063
}
@@ -61,7 +74,7 @@ func printSubmissionSummary(w io.Writer, result runner.SecuritySignalsSubmission
6174
}
6275

6376
func helpText() string {
64-
return `Usage: go run ./scripts/validate-security-signals-submission.go <submission-dir> [--json]
77+
return `Usage: go run ./scripts/validate-security-signals-submission.go <submission-dir> [--json] [--score-file <path>]
6578
6679
Validates one Security Signals leaderboard submission directory for CI and
6780
repository maintenance. The directory must contain metadata.json and

‎scripts/validate-security-signals-submissions.sh‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ for dir in "${submission_dirs[@]}"; do
142142
safe_name="$(echo "$dir" | tr '/ ' '__')"
143143
score_path="$score_dir/$safe_name.score.json"
144144
echo "Validating $dir"
145-
"${validator_cmd[@]}" "$dir" --json >"$score_path"
146-
summary="$("${validator_cmd[@]}" "$dir")"
145+
summary="$("${validator_cmd[@]}" "$dir" --score-file "$score_path")"
147146
echo "$summary"
148147

149148
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then

0 commit comments

Comments
 (0)