-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (173 loc) · 5.65 KB
/
push-validate_workflows.yaml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: push-validate_workflows
# Validates workflow files on push
# yamllint disable-line rule:truthy
on:
push:
branches-ignore:
- v0
jobs:
init:
runs-on: 'ubuntu-latest'
steps:
- name: 'Write Report Header'
if: always()
uses: OXID-eSales/github-actions/begin_report@v4
with:
prefix: 'validate'
title: 'Workflow validation on ${{ github.repository }} by ${{ github.actor }}'
repository: '${{ github.server_url }}/${{ github.repository }}'
job: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
testplan: ''
debug: false
- name: 'Write Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
header: true
phase: lint
priority: '001'
debug: false
yamllint:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Lint yaml files
id: yamllint
uses: oxid-esales/github-actions/yamllint@v4
with:
format: 'github'
config_data: |
extends: default
ignore: .git/*
rules:
document-start: disable
line-length:
max: 160
level: warning
new-line-at-end-of-file:
level: warning
trailing-spaces:
level: warning
- name: 'Write yamllint Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
priority: '010'
phase: lint
title: ''
job: 'yamllint'
php: ''
mysql: ''
testplan: ''
status: ${{job.status}}
debug: false
actionlint:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Run actionlint
id: actionlint
uses: raven-actions/actionlint@v2
- name: actionlint Summary
if: always()
run: |
echo "Used actionlint version ${{ steps.actionlint.outputs.version-semver }}"
echo "Used actionlint release ${{ steps.actionlint.outputs.version-tag }}"
echo "actionlint ended with ${{ steps.actionlint.outputs.exit-code }} exit code"
echo "actionlint ended because '${{ steps.actionlint.outputs.exit-message }}'"
echo "actionlint found ${{ steps.actionlint.outputs.total-errors }} errors"
echo "actionlint checked ${{ steps.actionlint.outputs.total-files }} files"
echo "actionlint cache used: ${{ steps.actionlint.outputs.cache-hit }}"
- name: 'Write actionlint Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
priority: '020'
phase: lint
job: 'actionlint'
title: ''
php: ''
mysql: ''
testplan: ''
status: ${{job.status}}
debug: false
matchingyaml:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Run Check that yaml files always match theiy yml counterpart
if: always()
run: |
RESULT=0
YML_FILES=$(find . -iname '*.yml')
for YML in ${YML_FILES}; do
COUNTERPART="${YML//.yml/.yaml}"
echo "Checking, if ${YML} matches ${COUNTERPART}"
if diff -y --suppress-common-lines --color=always "${YML}" "${COUNTERPART}"; then
echo -e "\033[0;32mOK: Files ${YML} and ${COUNTERPART} match!${LINE}"
else
echo -e "\033[0;31mError: Files ${YML} and ${COUNTERPART} differ!\033[0m"
RESULT=1
fi
done
YAML_FILES=$(find . -iname '*.yaml')
for YAML in ${YAML_FILES}; do
COUNTERPART="${YAML//.yaml/.yml}"
if [ -f "${COUNTERPART}" ]; then
echo "Checking, if ${YAML} matches ${COUNTERPART}"
if diff -y --suppress-common-lines --color=always "${YAML}" "${COUNTERPART}"; then
echo -e "\033[0;32mOK: Files ${YAML} and ${COUNTERPART} match!${LINE}"
else
echo -e "\033[0;31mError: Files ${YAML} and ${COUNTERPART} differ!\033[0m"
RESULT=1
fi
else
echo "No matching counterpart (${COUNTERPART}) for ${YAML}"
fi
done
if [ ${RESULT} -ne 0 ]; then
echo -e "\033[0;31mCheck failed, there are mismatches between yaml and yml files!\033[0m"
exit 1
fi
- name: 'Write actionlint Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
priority: '030'
phase: lint
job: 'matchingyaml'
title: ''
php: ''
mysql: ''
testplan: ''
status: ${{job.status}}
debug: false
finish:
if: always()
needs:
- init
- yamllint
- actionlint
- matchingyaml
runs-on: 'ubuntu-latest'
env:
SLACK_WEBHOOK: "${{ secrets.SLACK_WEBHOOK_URL }}"
steps:
- name: 'Output report'
uses: 'OXID-eSales/github-actions/generate_report@v4'
with:
prefix: 'validate'
slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
title: 'Workflow validation on ${{ github.repository }} by ${{ github.actor }}'
compact: true
debug: false