-
Notifications
You must be signed in to change notification settings - Fork 170
82 lines (70 loc) · 2.07 KB
/
run_tests.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
name: Run Tests
on:
workflow_dispatch:
push:
branches: [main]
pull_request: { }
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
with:
path: './'
- name: Parse info.json
run: |
jq -e '.' info.json || {
echo "Syntax Error in info.json"
exit 1
}
- name: Evaluate info.json
run: |
jq '.[-1]' info.json > userinfo.json
jq '.name, .gh_username, .place, .current_pos, .bio' -e userinfo.json || {
echo "All fields are not present!"
exit 1
}
# Check length of all fields
jq '.name | length <= 30' -e userinfo.json || {
echo "name length should be less than 30!"
exit 1
}
jq '.place | length <= 30' -e userinfo.json || {
echo "place length should be less than 30!"
exit 1
}
jq '.current_pos | length <= 58' -e userinfo.json || {
echo "current_pos length should be less than 30!"
exit 1
}
jq '.bio | length <= 150' -e userinfo.json || {
echo "bio length should be less than 150!"
exit 1
}
# Check whether image is present
jq '.image' userinfo.json > userimage
if grep -q "null" ./userimage ; then
echo "Image file not required"
else
if [ -f "./images/$(cat ./userimage | cut -d \" -f2)" ]; then
echo "image verified!"
size=$(du -k "./images/$(cat ./userimage | cut -d \" -f2)" | cut -f1)
if [ "$size" -lt "200" ]; then
echo "image size verified!"
else
echo "image size greater than 200!"
exit 1
fi
else
echo "image file not found"
exit 1
fi
fi
- name: Cleanup
run: |
rm userinfo.json
rm userimage