Skip to content

Commit 31a11b5

Browse files
shellcheck fixes
1 parent 85158b2 commit 31a11b5

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

.github/scripts/handle_warning_violations.sh

100644100755
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if [ "$DRY_RUN" = "true" ]; then
2828
echo "Would create Jira ticket with:"
2929
echo "Summary: Warning-level IPA violations found - $WARNING_COUNT violations"
3030
echo "Description:"
31-
echo "Warning-level violations were found during IPA validation.
31+
echo "Warning-level violations were found during IPA validation. Please review and add exceptions if valid, or address false positives.
3232
3333
Violation Summary:
3434
$VIOLATION_DETAILS
@@ -37,13 +37,10 @@ Total violations: $WARNING_COUNT"
3737
echo ""
3838
echo "Would send Slack message:"
3939
SLACK_SUMMARY=$(echo "$VIOLATION_DETAILS" | head -3)
40-
if [ $(echo "$VIOLATION_DETAILS" | wc -l) -gt 3 ]; then
40+
if [ "$(echo "$VIOLATION_DETAILS" | wc -l)" -gt 3 ]; then
4141
SLACK_SUMMARY="$SLACK_SUMMARY\n... and more"
4242
fi
43-
echo "Warning-level IPA violations found ($WARNING_COUNT violations).
44-
45-
Top violations:
46-
$SLACK_SUMMARY
43+
echo "Warning-level IPA violations found ($WARNING_COUNT violations).
4744
4845
Jira ticket: [DRY RUN - no ticket created]"
4946
exit 0
@@ -90,16 +87,13 @@ if [ "$TICKET_KEY" != "null" ]; then
9087
SLACK_SUMMARY=""
9188
if [ -n "$VIOLATION_DETAILS" ]; then
9289
SLACK_SUMMARY=$(echo "$VIOLATION_DETAILS" | head -3)
93-
if [ $(echo "$VIOLATION_DETAILS" | wc -l) -gt 3 ]; then
90+
if [ "$(echo "$VIOLATION_DETAILS" | wc -l)" -gt 3 ]; then
9491
SLACK_SUMMARY="$SLACK_SUMMARY\n... and more"
9592
fi
9693
fi
9794

9895
# Send Slack notification with violation summary
99-
SLACK_MESSAGE="Warning-level IPA violations found ($WARNING_COUNT violations).
100-
101-
Top violations:
102-
$SLACK_SUMMARY
96+
SLACK_MESSAGE="Warning-level IPA violations found ($WARNING_COUNT violations).
10397
10498
Jira ticket: https://jira.mongodb.org/browse/$TICKET_KEY"
10599

.github/workflows/release-IPA-metrics.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ jobs:
4343
run: |
4444
node runMetricCollection.js "${{ github.workspace }}/v2.json"
4545
if [ -f "../outputs/warning-count.txt" ]; then
46-
warning_count=$(cat ../outputs/warning-count.txt)
47-
echo "warning_count=${warning_count}" >> $GITHUB_OUTPUT
46+
warning_count=$(cat "../outputs/warning-count.txt")
47+
echo "warning_count=${warning_count}" >> "$GITHUB_OUTPUT"
4848
else
49-
echo "warning_count=0" >> $GITHUB_OUTPUT
49+
echo "warning_count=0" >> "$GITHUB_OUTPUT"
5050
fi
5151
5252
- name: aws configure

tools/spectral/ipa/__tests__/metrics/metricCollection.test.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ describe('tools/spectral/ipa/metrics/metricCollection.js runMetricCollectionJob'
3030

3131
expect(results).not.toBe(undefined);
3232
expect(results.metrics.length).toEqual(expectedResults.length);
33+
results.metrics.forEach((entry, index) => {
34+
const expectedEntry = getEntry(expectedResults, entry['component_id'], entry['ipa_rule']);
35+
expect(entry['component_id']).toEqual(expectedEntry['component_id']);
36+
expect(entry['adoption_status']).toEqual(expectedEntry['adoption_status']);
37+
expect(entry['ipa']).toEqual(expectedEntry['ipa']);
38+
expect(entry['ipa_rule']).toEqual(expectedEntry['ipa_rule']);
39+
expect(entry['exception_reason']).toEqual(expectedEntry['exception_reason']);
40+
expect(entry['owner_team']).toEqual(expectedEntry['owner_team']);
41+
expect(entry['severity_level']).toEqual(expectedEntry['severity_level']);
42+
});
3343

3444
expect(results.warnings.count).toEqual(1);
3545
const violations = [
@@ -41,17 +51,6 @@ describe('tools/spectral/ipa/metrics/metricCollection.js runMetricCollectionJob'
4151
},
4252
];
4353
expect(results.warnings.violations).toEqual(violations);
44-
45-
results.metrics.forEach((entry, index) => {
46-
const expectedEntry = getEntry(expectedResults, entry['component_id'], entry['ipa_rule']);
47-
expect(entry['component_id']).toEqual(expectedEntry['component_id']);
48-
expect(entry['adoption_status']).toEqual(expectedEntry['adoption_status']);
49-
expect(entry['ipa']).toEqual(expectedEntry['ipa']);
50-
expect(entry['ipa_rule']).toEqual(expectedEntry['ipa_rule']);
51-
expect(entry['exception_reason']).toEqual(expectedEntry['exception_reason']);
52-
expect(entry['owner_team']).toEqual(expectedEntry['owner_team']);
53-
expect(entry['severity_level']).toEqual(expectedEntry['severity_level']);
54-
});
5554
});
5655
});
5756

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"code": "xgen-IPA-104-valid-operation-id",
4+
"message": "IPA rule xgen-IPA-104-valid-operation-id violated",
5+
"path": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
6+
"source": null
7+
}
8+
]

0 commit comments

Comments
 (0)