Skip to content

Commit 5d54738

Browse files
authored
Add preflight tests for images (#368)
1 parent b5dbe65 commit 5d54738

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

.github/workflows/preflight.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
name: Preflight
3+
'on':
4+
schedule:
5+
- cron: '0 0 * * *'
6+
# pull_request:
7+
# branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
preflight-debug-partner:
12+
runs-on: ubuntu-22.04
13+
env:
14+
SHELL: /bin/bash
15+
IMAGE_NAME: quay.io/testnetworkfunction/debug-partner:latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Go 1.21
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: 1.21.3
24+
25+
- name: Disable default go problem matcher
26+
run: echo "::remove-matcher owner=go::"
27+
28+
- name: Clone the preflight repository
29+
uses: actions/checkout@v4
30+
with:
31+
repository: redhat-openshift-ecosystem/openshift-preflight
32+
path: openshift-preflight
33+
34+
- name: Run preflight
35+
working-directory: openshift-preflight
36+
run: |
37+
make build
38+
./preflight check container ${{ env.IMAGE_NAME }} --artifacts ${GITHUB_WORKSPACE}/openshift-preflight/artifacts
39+
40+
ALLOWED_FAILURES=("HasLicense" "RunAsNonRoot")
41+
FAILURES=$(cat ${GITHUB_WORKSPACE}/openshift-preflight/artifacts/amd64/results.json | jq -r '.results.failed[].name')
42+
43+
for FAILURE in $FAILURES; do
44+
FAILURE=$(echo $FAILURE | tr -d '"')
45+
if [[ ! " ${ALLOWED_FAILURES[@]} " =~ " ${FAILURE} " ]]; then
46+
echo "ERROR: $FAILURE is not an allowed failure"
47+
exit 1
48+
fi
49+
done
50+
51+
52+
preflight-cnf-test-partner:
53+
runs-on: ubuntu-22.04
54+
env:
55+
SHELL: /bin/bash
56+
IMAGE_NAME: quay.io/testnetworkfunction/cnf-test-partner:latest
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Set up Go 1.21
62+
uses: actions/setup-go@v4
63+
with:
64+
go-version: 1.21.3
65+
66+
- name: Disable default go problem matcher
67+
run: echo "::remove-matcher owner=go::"
68+
69+
- name: Clone the preflight repository
70+
uses: actions/checkout@v4
71+
with:
72+
repository: redhat-openshift-ecosystem/openshift-preflight
73+
path: openshift-preflight
74+
75+
# - name: Setup tmate session
76+
# uses: mxschmitt/action-tmate@v3
77+
78+
- name: Run preflight
79+
working-directory: openshift-preflight
80+
run: |
81+
make build
82+
./preflight check container ${{ env.IMAGE_NAME }} --artifacts ${GITHUB_WORKSPACE}/openshift-preflight/artifacts
83+
84+
ALLOWED_FAILURES=()
85+
FAILURES=$(cat ${GITHUB_WORKSPACE}/openshift-preflight/artifacts/amd64/results.json | jq -r '.results.failed[].name')
86+
87+
for FAILURE in $FAILURES; do
88+
FAILURE=$(echo $FAILURE | tr -d '"')
89+
if [[ ! " ${ALLOWED_FAILURES[@]} " =~ " ${FAILURE} " ]]; then
90+
echo "ERROR: $FAILURE is not an allowed failure"
91+
exit 1
92+
fi
93+
done
94+

0 commit comments

Comments
 (0)