-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCP4: Add workflow to test ocp content
Add this workflow so we can test ocp4 content can be parsed on each PR
- Loading branch information
1 parent
b895bce
commit f027a8c
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
name: Gate / Kubernetes Test Content Parsing | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
datastream-parsing: | ||
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: | | ||
export CONTENT_FOLDER=$PWD/content | ||
cd compliance-operator | ||
for file in $CONTENT_FOLDER/*.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 | ||