-
Notifications
You must be signed in to change notification settings - Fork 360
86 lines (75 loc) · 2.35 KB
/
samples.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
name: Validate samples
on:
pull_request:
types: [opened, synchronize] # new, updates
jobs:
update-python-list:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Get Changed Files
id: changed_files
uses: tj-actions/changed-files@v44
with:
files: |
samples/*.py
- name: Check Python samples
env:
NEW_FILES: ${{ steps.changed_files.outputs.all_modified_files }}
README: samples/README.md
run: |
#!/bin/bash
for file in ${NEW_FILES}; do
echo "Testing $file"
name=$(basename $file)
if [[ -f ${file} ]]; then
# File exists, so needs to be listed.
if ! grep -q $name ${README}; then
echo "Error: Sample not listed in README ($name)"
exit 1
fi
else
# File does not exist, ensure it's not listed
if grep -q $name ${README}; then
echo "Error: Sample should not be listed in README ($name)"
exit 1
fi
fi
done
update-rest-list:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Get Changed Files
id: changed_files
uses: tj-actions/changed-files@v44
with:
files: |
samples/rest/*.sh
- name: Check REST samples
env:
NEW_FILES: ${{ steps.changed_files.outputs.all_modified_files }}
README: samples/rest/README.md
run: |
#!/bin/bash
for file in ${NEW_FILES}; do
echo "Testing $file"
if [[ -f ${file} ]]; then
# File exists, so needs to be listed.
echo $(basename $file)
name=$(basename $file)
if ! grep -q $name ${README}; then
echo "Error: Sample not listed in README ($name)"
exit 1
fi
else
# File does not exist, ensure it's not listed
name=$(basename $file)
if grep -q $name ${README}; then
echo "Error: Sample should not be listed in README ($name)"
exit 1
fi
fi
done