Skip to content

OCP4: Add workflow to test ocp content #2

OCP4: Add workflow to test ocp content

OCP4: Add workflow to test ocp content #2

---
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: 5
max_attempts: 3
retry_wait_seconds: 120
retry_on: error
command: |
mkdir -p content
docker pull quay.io/complianceascode/k8scontent:latest
docker run --rm -v $PWD/content:/content:z quay.io/complianceascode/k8scontent:latest cp /*.xml /content
- name: Clone compliance operator repository
run: |
git clone https://github.com/ComplianceAsCode/compliance-operator.git
- name: Install ginkgo
run: |
go install github.com/onsi/ginkgo/ginkgo@latest
- name: Add GOBIN to PATH
run: |
echo "export PATH=$PATH:/root/go/bin" >> ~/.bashrc
source ~/.bashrc
- name: Run ginkgo tests and check if each XCCDF file is parsed correctly
run: |
for file in content/*.xml; do
export DEFAULT_CONTENT_DS_FILE_PATH=$file
ginkgo --focus "Testing for correct content parsing" /compliance-operator/pkg/utils | tee /tmp/ginkgo_output
if grep -q "0 Failed | 0 Passed" /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