-
Notifications
You must be signed in to change notification settings - Fork 26
100 lines (86 loc) · 3 KB
/
self-test.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# This workflow is provided for testing changes to the action.
# When developing make sure that "Scan 2 - failing" produces expected kube-linter validation logs.
name: kube-linter-action development self-test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test-scan:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
format: [ plain, json, sarif ]
version: [ latest, 0.2.3 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Scan 1 - should succeed
uses: ./
with:
directory: sample/valid-yaml
config: sample/.kube-linter-config.yaml
format: ${{ matrix.format }}
version: ${{ matrix.version }}
- name: Scan 2 - should fail
id: failing-scan
uses: ./
with:
directory: sample/invalid-yaml
config: sample/.kube-linter-config.yaml
format: ${{ matrix.format }}
version: ${{ matrix.version }}
continue-on-error: true
- name: Verify Scan 2 should have failed
shell: bash
run: |
echo "Verifying that kube-linter-action outcome (${{ steps.failing-scan.outcome }}) from Scan 2 is failure."
[[ "${{ steps.failing-scan.outcome }}" == "failure" ]]
test-with-sarif-upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup directory where github/codeql-action/upload-sarif@v3 looks up files by default.
- name: Create ../results directory for sarif files
shell: bash
run: mkdir -p ../results
- name: Scan 1 - should succeed
uses: ./
with:
directory: sample/valid-yaml
config: sample/.kube-linter-config.yaml
format: sarif
output-file: ../results/kube-linter-success.sarif
- name: Scan 2 - should fail
uses: ./
with:
directory: sample/invalid-yaml
config: sample/.kube-linter-config.yaml
format: sarif
output-file: ../results/kube-linter-fail.sarif
continue-on-error: true
- name: Upload SARIF output file to GitHub
uses: github/codeql-action/upload-sarif@v3
test-fail-on-invalid-resource:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scan 1 - should succeed
uses: ./
with:
directory: sample/non-kubernetes-yaml
config: sample/.kube-linter-config.yaml
- name: Scan 2 - should fail
id: failing-scan
uses: ./
with:
directory: sample/non-kubernetes-yaml
config: sample/.kube-linter-config.yaml
fail-on-invalid-resource: "true"
continue-on-error: true
- name: Verify Scan 2 should have failed
shell: bash
run: |
echo "Verifying that kube-linter-action outcome (${{ steps.failing-scan.outcome }}) from Scan 2 is failure."
[[ "${{ steps.failing-scan.outcome }}" == "failure" ]]