-
Notifications
You must be signed in to change notification settings - Fork 705
53 lines (50 loc) · 1.83 KB
/
k8s-content-pr-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
name: Kubernetes content image test for PR
on:
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
get-xccdf-files:
name: Fetch XCCDF files from existing content image
runs-on: ubuntu-latest
steps:
- name: Copy XCCDF files from existing content image
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 3
retry_wait_seconds: 120
retry_on: error
command: |
mkdir -p content
docker pull ghcr.io/complianceascode/k8scontent:${{ github.event.number }}
docker run --rm -v $PWD/content:/content:z ghcr.io/complianceascode/k8scontent:${{ github.event.number }} bash -c "cp *.xml /content"
- name: Clone compliance operator repository
run: |
git clone https://github.com/ComplianceAsCode/compliance-operator.git
- uses: actions/setup-go@v5
with:
go-version: '>=1.19.0'
- run: go version
- name: Install ginkgo
run: |
go install github.com/onsi/ginkgo/ginkgo@latest
- name: Run ginkgo tests and check if each XCCDF file is parsed correctly
run: |
cd compliance-operator
for file in $PWD/../content/*.xml; do
export DEFAULT_CONTENT_DS_FILE_PATH=$file
ginkgo --focus "Testing for correct content parsing" ./pkg/utils | tee /tmp/ginkgo_output
if grep -q "0 Passed" /tmp/ginkgo_output && grep -q "0 Failed" /tmp/ginkgo_output; then
echo "XCCDF file $file is not parsed correctly"
exit 1
elif grep -q "SUCCESS!" /tmp/ginkgo_output; then
echo "XCCDF file $file is parsed correctly"
else
echo "XCCDF file $file is not parsed correctly"
exit 1
fi
done