Skip to content

Commit

Permalink
Add preflight tests for images
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 committed Oct 30, 2023
1 parent b5dbe65 commit 72801bf
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/preflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: Preflight
'on':
schedule:
- cron: '0 0 * * *'
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
preflight-debug-partner:
runs-on: ubuntu-22.04
env:
SHELL: /bin/bash
IMAGE_NAME: quay.io/testnetworkfunction/debug-partner:latest

steps:
- uses: actions/checkout@v4

- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: 1.21.3

- name: Disable default go problem matcher
run: echo "::remove-matcher owner=go::"

- name: Clone the preflight repository
uses: actions/checkout@v4
with:
repository: redhat-openshift-ecosystem/openshift-preflight
path: openshift-preflight

- name: Run preflight
working-directory: openshift-preflight
run: |
make build
./preflight check container ${{ env.IMAGE_NAME }} --artifacts .
ALLOWED_FAILURES=("HasLicense" "RunAsNonRoot")
FAILURES=$(cat artifacts/amd64/results.json | jq '.results.failed[].name')
for FAILURE in $FAILURES; do
FAILURE=$(echo $FAILURE | tr -d '"')
if [[ ! " ${ALLOWED_FAILURES[@]} " =~ " ${FAILURE} " ]]; then
echo "ERROR: $FAILURE is not an allowed failure"
exit 1
fi
done
preflight-cnf-test-partner:
runs-on: ubuntu-22.04
env:
SHELL: /bin/bash
IMAGE_NAME: quay.io/testnetworkfunction/cnf-test-partner:latest

steps:
- uses: actions/checkout@v4

- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: 1.21.3

- name: Disable default go problem matcher
run: echo "::remove-matcher owner=go::"

- name: Clone the preflight repository
uses: actions/checkout@v4
with:
repository: redhat-openshift-ecosystem/openshift-preflight
path: openshift-preflight

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: Run preflight
working-directory: openshift-preflight
run: |
make build
./preflight check container ${{ env.IMAGE_NAME }} --artifacts .
ALLOWED_FAILURES=()
FAILURES=$(cat artifacts/amd64/results.json | jq '.results.failed[].name')
for FAILURE in $FAILURES; do
FAILURE=$(echo $FAILURE | tr -d '"')
if [[ ! " ${ALLOWED_FAILURES[@]} " =~ " ${FAILURE} " ]]; then
echo "ERROR: $FAILURE is not an allowed failure"
exit 1
fi
done

0 comments on commit 72801bf

Please sign in to comment.