Skip to content

Commit c04eae9

Browse files
committed
Merge branch 'feature/test-refactoring' into feature/CSPL-3775-extract-common-code-in-tests
2 parents 4519fb0 + fca64c5 commit c04eae9

42 files changed

Lines changed: 3254 additions & 94 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ EKSCTL_VERSION=v0.215.0
88
EKS_CLUSTER_K8_VERSION=1.34
99
EKS_INSTANCE_TYPE=m5.2xlarge
1010
EKS_INSTANCE_TYPE_ARM64=c6g.4xlarge
11-
SPLUNK_ENTERPRISE_RELEASE_IMAGE=splunk/splunk:10.0.0
11+
SPLUNK_ENTERPRISE_RELEASE_IMAGE=splunk/splunk:10.2.0

.gitattributes

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by kubebuilder/operator-sdk (scaffolding)
2+
PROJECT linguist-generated=true
3+
4+
# Generated by controller-gen (make generate)
5+
api/**/zz_generated.deepcopy.go linguist-generated=true
6+
7+
# Generated by controller-gen (make manifests)
8+
config/crd/bases/*.yaml linguist-generated=true
9+
config/rbac/role.yaml linguist-generated=true
10+
config/rbac/role_binding.yaml linguist-generated=true
11+
config/webhook/manifests.yaml linguist-generated=true
12+
13+
# Generated by operator-sdk (make bundle)
14+
config/manifests/bases/splunk-operator.clusterserviceversion.yaml linguist-generated=true
15+
bundle/manifests/*.yaml linguist-generated=true
16+
bundle/metadata/annotations.yaml linguist-generated=true

.github/workflows/arm-AL2023-build-test-push-workflow-AL2023.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ jobs:
5151
run: make test
5252
- name: Run Code Coverage
5353
run: goveralls -coverprofile=coverage.out -service=circle-ci -repotoken ${{ secrets.COVERALLS_TOKEN }}
54-
continue-on-error: true
5554
- name: Upload Coverage artifacts
5655
uses: actions/upload-artifact@v6
5756
with:

.github/workflows/arm-Ubuntu-build-test-push-workflow.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ jobs:
5151
run: make test
5252
- name: Run Code Coverage
5353
run: goveralls -coverprofile=coverage.out -service=circle-ci -repotoken ${{ secrets.COVERALLS_TOKEN }}
54-
continue-on-error: true
5554
- name: Upload Coverage artifacts
5655
uses: actions/upload-artifact@v6
5756
with:

.github/workflows/automated-release-workflow.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
permissions:
2424
contents: write
25+
id-token: write
2526
pull-requests: write
2627
if: github.ref == 'refs/heads/main'
2728
env:
@@ -111,31 +112,35 @@ jobs:
111112
112113
- name: Sign Splunk Operator image with a key
113114
run: |
114-
cosign sign --yes --key env://COSIGN_PRIVATE_KEY splunk/splunk-operator:${{ github.event.inputs.operator_image_tag }}
115+
cosign sign --yes --recursive --key env://COSIGN_PRIVATE_KEY splunk/splunk-operator:${{ github.event.inputs.operator_image_tag }}
115116
env:
116117
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
117118
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
119+
COSIGN_DOCKER_MEDIA_TYPES: "1"
118120

119121
- name: Verify Splunk Operator image with a key
120122
run: |
121123
cosign verify --key env://COSIGN_PUBLIC_KEY splunk/splunk-operator:${{ github.event.inputs.operator_image_tag }}
122124
env:
123125
COSIGN_PUBLIC_KEY: ${{ secrets.COSIGN_PUBLIC_KEY }}
126+
COSIGN_DOCKER_MEDIA_TYPES: "1"
124127

125128
- name: Promote Distroless RC Image to Release
126129
run: |
127130
regctl image copy ${{ secrets.PUBLIC_ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_RC_IMAGE_NAME }}:${{ github.event.inputs.release_version }}-RC-distroless splunk/splunk-operator:${{ github.event.inputs.operator_image_tag }}-distroless
128131
129132
- name: Sign Distroless Splunk Operator image with a key
130133
run: |
131-
cosign sign --yes --key env://COSIGN_PRIVATE_KEY splunk/splunk-operator:${{ github.event.inputs.operator_image_tag }}-distroless
134+
cosign sign --yes --recursive --key env://COSIGN_PRIVATE_KEY splunk/splunk-operator:${{ github.event.inputs.operator_image_tag }}-distroless
132135
env:
133136
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
134137
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
138+
COSIGN_DOCKER_MEDIA_TYPES: "1"
135139

136140
- name: Verify Distroless Splunk Operator image with a key
137141
run: |
138142
cosign verify --key env://COSIGN_PUBLIC_KEY splunk/splunk-operator:${{ github.event.inputs.operator_image_tag }}-distroless
139143
env:
140144
COSIGN_PUBLIC_KEY: ${{ secrets.COSIGN_PUBLIC_KEY }}
145+
COSIGN_DOCKER_MEDIA_TYPES: "1"
141146

.github/workflows/build-test-push-workflow.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ jobs:
6363
make test
6464
- name: Run Code Coverage
6565
run: goveralls -shallow -coverprofile=coverage.out -service=circle-ci -repotoken ${{ secrets.COVERALLS_TOKEN }}
66-
continue-on-error: true
6766
- name: Upload Coverage artifacts
6867
uses: actions/upload-artifact@v6
6968
with:
@@ -82,9 +81,28 @@ jobs:
8281
report_paths: 'unit_test*.xml'
8382
check_name: 'Unit Test Results'
8483
detailed_summary: true
84+
check-generated:
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v2
88+
- name: Dotenv Action
89+
id: dotenv
90+
uses: falti/dotenv-action@v1
91+
- name: Setup Go
92+
uses: actions/setup-go@v2
93+
with:
94+
go-version: ${{ steps.dotenv.outputs.GO_VERSION }}
95+
- name: Run code generation
96+
run: make manifests generate
97+
- name: Check for uncommitted changes
98+
run: |
99+
if ! git diff --exit-code; then
100+
echo "::error::Generated files are out of date. Run 'make manifests generate' and commit the result."
101+
exit 1
102+
fi
85103
build-operator-image:
86104
runs-on: ubuntu-latest
87-
needs: [check-formating, unit-tests]
105+
needs: [check-formating, unit-tests, check-generated]
88106
env:
89107
SPLUNK_ENTERPRISE_IMAGE: ${{ secrets.SPLUNK_ENTERPRISE_IMAGE }}
90108
SPLUNK_OPERATOR_IMAGE_NAME: splunk/splunk-operator

.github/workflows/distroless-build-test-push-workflow.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ jobs:
5757
run: make test
5858
- name: Run Code Coverage
5959
run: goveralls -shallow -coverprofile=coverage.out -service=circle-ci -repotoken ${{ secrets.COVERALLS_TOKEN }}
60-
continue-on-error: true
6160
- name: Upload Coverage artifacts
6261
uses: actions/upload-artifact@v6
6362
with:
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Flaky Test Analysis
2+
permissions:
3+
contents: read
4+
actions: read
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
start_date:
9+
description: 'Start date (YYYY-MM-DD). Defaults to 7 days before yesterday.'
10+
required: false
11+
end_date:
12+
description: 'End date (YYYY-MM-DD). Defaults to yesterday.'
13+
required: false
14+
top_n:
15+
description: 'Number of flakiest tests to report'
16+
required: false
17+
default: '20'
18+
window_size:
19+
description: 'Window size in days for flip rate calculation'
20+
required: false
21+
default: '1'
22+
branch:
23+
description: 'Only include runs from this branch (e.g. develop). All branches if empty.'
24+
required: false
25+
jobs:
26+
analyze:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.12'
34+
35+
- name: Install dependencies
36+
run: pip install flaky-tests-detection
37+
38+
- name: Run flaky test analysis
39+
id: run
40+
env:
41+
GH_TOKEN: ${{ github.token }}
42+
START_DATE: ${{ inputs.start_date }}
43+
END_DATE: ${{ inputs.end_date }}
44+
TOP_N: ${{ inputs.top_n }}
45+
WINDOW_SIZE: ${{ inputs.window_size }}
46+
BRANCH: ${{ inputs.branch }}
47+
RESULTS_FILE: flaky-results.txt
48+
run: |
49+
./tools/flaky-test-analysis.sh
50+
echo "start=${START_DATE:-$(date -u -d '7 days ago' +%Y-%m-%d)}" >> "$GITHUB_OUTPUT"
51+
echo "end=${END_DATE:-$(date -u -d 'yesterday' +%Y-%m-%d)}" >> "$GITHUB_OUTPUT"
52+
53+
- name: Generate job summary
54+
if: always()
55+
run: |
56+
{
57+
echo "## Flaky Test Analysis"
58+
echo ""
59+
echo "**Date range:** \`${{ steps.run.outputs.start }}\` .. \`${{ steps.run.outputs.end }}\`"
60+
BRANCH_INFO="${{ inputs.branch }}"
61+
if [[ -n "$BRANCH_INFO" ]]; then
62+
echo "**Branch:** \`${BRANCH_INFO}\` | **Top N:** ${{ inputs.top_n || '20' }} | **Window size:** ${{ inputs.window_size || '1' }} day(s)"
63+
else
64+
echo "**Top N:** ${{ inputs.top_n || '20' }} | **Window size:** ${{ inputs.window_size || '1' }} day(s)"
65+
fi
66+
echo ""
67+
68+
if [[ ! -f flaky-results.txt ]]; then
69+
echo "> No results produced. Check the workflow logs."
70+
exit 0
71+
fi
72+
73+
# Extract the score lines (format: suite::[It] description --- score: N)
74+
flaky_lines=$(grep -E ' --- score: ' flaky-results.txt || true)
75+
76+
if [[ -z "$flaky_lines" ]]; then
77+
echo "> No flaky tests detected in this period."
78+
else
79+
echo "| Score | Suite | Test |"
80+
echo "|------:|-------|------|"
81+
echo "$flaky_lines" | while IFS= read -r line; do
82+
score=$(echo "$line" | sed -E 's/.* --- score: (.+)/\1/')
83+
suite=$(echo "$line" | sed -E 's/^([^:]+)::.*/\1/')
84+
test_name=$(echo "$line" | sed -E 's/^[^:]+::\[It\] (.*) --- score:.*/\1/')
85+
echo "| ${score} | ${suite} | ${test_name} |"
86+
done
87+
fi
88+
89+
} >> "$GITHUB_STEP_SUMMARY"
90+
91+
- name: Generate failure stats summary
92+
if: always()
93+
run: python3 tools/test-failure-stats.py ./junit-reports >> "$GITHUB_STEP_SUMMARY"
94+
95+
- name: Upload results
96+
if: always()
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: flaky-test-results-${{ steps.run.outputs.start }}-to-${{ steps.run.outputs.end }}
100+
path: |
101+
flaky-results.txt
102+
*_flip_rate_*.png
103+
if-no-files-found: ignore
104+
retention-days: 30

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ release-*
9393
deploy/olm-certified
9494
report-junit*.xml
9595
unit_test*.xml
96+
junit-reports/
9697
# Bias Language Linter
9798
.biaslanguage/
9899
bin/

cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ func main() {
303303
Validators: validation.DefaultValidators,
304304
ReadTimeout: readTimeout,
305305
WriteTimeout: writeTimeout,
306+
Client: mgr.GetClient(),
306307
})
307308

308309
// Add webhook server as a runnable to the manager

0 commit comments

Comments
 (0)