-
Notifications
You must be signed in to change notification settings - Fork 34
93 lines (71 loc) · 2.71 KB
/
run-yaml-verification.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
name: Run YAML verification
on:
workflow_dispatch:
workflow_run:
workflows: ["Run Python Files"]
types:
- completed
push:
paths:
- 'submissions/**.yaml'
branches:
- '**'
pull_request:
paths:
- 'submissions/**.yaml'
branches:
- '**'
jobs:
verification:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v2
with:
fetch-depth: 0
# can also specify python version if needed
- name: setup python
uses: actions/setup-python@v4
- name: install python packages
run: |
python -m pip install --upgrade pip
pip install PyYAML
- name: get .yaml files, run verification
id: run-script
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
# triggered on pull request, get all changed / added files from forked repo
export FILES=$(git diff --name-only --diff-filter=ACM FETCH_HEAD | grep -E '\.(yaml|yml)$' | sed 's|^submissions/||')
else
# triggered push, locate the changed / added .yaml files in the submission folder
export FILES=$(git diff --name-status --diff-filter=ACM --relative=submissions ${{ github.event.before }} ${{ github.sha }} submissions | grep -E '\.(yaml|yml)$' | awk '{print $2}')
fi
IFS=$'\n'
# print the names of the files
echo "Files for verification; $FILES"
files_with_errors=""
# run verification on all files
for file in $FILES; do
echo "Running verification on $file"
output=$(python run_yaml_verification.py "submissions/$file")
echo $output >> $GITHUB_STEP_SUMMARY
# get number of errors
#errors_from_output=$(echo "$output" | tail -n 1)
#echo "$errors_from_output errors detected for $file"
# if file results in verification errors add to string files_with_errors
#if [[ "$errors_from_output" -ge 1 ]]; then
# files_with_errors+="$file, $errors_from_output errors. "
#fi
echo "Done verification on $file"
done
echo "files_with_errors=$files_with_errors" >> $GITHUB_ENV
- name: fail if there are errors from verification
run: |
if [ -z "$files_with_errors" ]; then
echo "No errors detected."
echo "No errors detected." >> $GITHUB_STEP_SUMMARY
else
echo "Errors detected: $files_with_errors"
echo "Errors detected: $files_with_errors" >> $GITHUB_STEP_SUMMARY
exit 1
fi