-
Notifications
You must be signed in to change notification settings - Fork 27
129 lines (124 loc) · 6.21 KB
/
ci.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
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
name: "CI"
on:
pull_request:
branches:
- "*"
push:
branches:
- "main"
- "master"
jobs:
test:
runs-on: "ubuntu-22.04"
steps:
- uses: "actions/checkout@v2"
- name: "Set up Python 3.10"
uses: "actions/setup-python@v1"
with:
python-version: "3.10"
- name: "Install dependencies"
run: |
pip3 install flake8 black Flask==3.0.3
pip3 install -e .[brotli]
- name: "Lint code base"
run: |
flake8 .
black --check .
- name: "Run test suite for gzip and brotli"
run: |
cd tests/example_app
export FLASK_APP=example.app
ls -laR example/static/ | wc -l \
| grep -q "26" \
&& (echo "File count before compiling test (index): pass" && exit 0) \
|| (echo "File count before compiling test (index): fail" && exit 1)
ls -laR example/about/static/ | wc -l \
| grep -q "5" \
&& (echo "File count before compiling test (about): pass" && exit 0) \
|| (echo "File count before compiling test (about): fail" && exit 1)
ls -laR example/contact/static/ | wc -l \
| grep -q "5" \
&& (echo "File count before compiling test (contact): pass" && exit 0) \
|| (echo "File count before compiling test (contact): fail" && exit 1)
ls -laR example/about/team/static/ | wc -l \
| grep -q "5" \
&& (echo "File count before compiling test (team): pass" && exit 0) \
|| (echo "File count before compiling test (team): fail" && exit 1)
flask digest compile \
&& ls -laR example/static/ | wc -l \
| grep -q "42" \
&& (echo "File count after compiling test (index): pass" && exit 0) \
|| (echo "File count after compiling test (index): fail" && exit 1)
ls -laR example/about/static/ | wc -l \
| grep -q "11" \
&& (echo "File count after compiling test (about): pass" && exit 0) \
|| (echo "File count after compiling test (about): fail" && exit 1)
ls -laR example/contact/static/ | wc -l \
| grep -q "11" \
&& (echo "File count after compiling test (contact): pass" && exit 0) \
|| (echo "File count after compiling test (contact): fail" && exit 1)
ls -laR example/about/team/static/ | wc -l \
| grep -q "11" \
&& (echo "File count after compiling test (team): pass" && exit 0) \
|| (echo "File count after compiling test (team): fail" && exit 1)
find . -type f | grep ".gz$" | wc -l \
| grep -q "14" \
&& (echo "Check for gzip asset creation: pass" && exit 0) \
|| (echo "Check for gzip asset creation: pass: fail" && exit 1)
find . -type f | grep ".br$" | wc -l \
| grep -q "14" \
&& (echo "Check for brotli asset creation: pass" && exit 0) \
|| (echo "Check for brotli asset creation: pass: fail" && exit 1)
grep -q "js/modules/hello.js" example/static/cache_manifest.json \
&& (echo "Cache manifest has nested file test: pass" && exit 0) \
|| (echo "Cache manifest has nested file test: fail" && exit 1)
grep -q "js/modules/hello-d41d8cd98f00b204e9800998ecf8427e.js" example/static/cache_manifest.json \
&& (echo "Cache manifest has digested file test: pass" && exit 0) \
|| (echo "Cache manifest has digested file test: fail" && exit 1)
grep -q "js/modules/hello.js" example/static/cache_manifest.json \
&& (echo "Cache manifest has nested file test: pass" && exit 0) \
|| (echo "Cache manifest has nested file test: fail" && exit 1)
flask run &
sleep 5 \
&& curl http://localhost:5000 \
| grep -q 'https://cdn.example.com/static/css/app-d41d8cd98f00b204e9800998ecf8427e.css' \
&& (echo 'Stylesheet is md5 tagged test (index): pass' && exit 0) \
|| (echo 'Stylesheet is md5 tagged test (index): fail' && exit 1)
curl http://localhost:5000/about/ \
| grep -q 'https://cdn.example.com/about/static/app-297c671953f6c24f1354214b3f706e0b.css' \
&& (echo 'Stylesheet is md5 tagged test (about): pass' && exit 0) \
|| (echo 'Stylesheet is md5 tagged test (about): fail' && exit 1)
curl http://localhost:5000/contact \
| grep -q 'https://cdn.example.com/contact/static/app-b71c3f4f5d026dd5198163b655228776.css' \
&& (echo 'Stylesheet is md5 tagged test (contact): pass' && exit 0) \
|| (echo 'Stylesheet is md5 tagged test (contact): fail' && exit 1)
curl http://localhost:5000/about/team \
| grep -q 'https://cdn.example.com/about/static/team/app-023f768653c556fc2fcaf338b408c464.css' \
&& (echo 'Stylesheet is md5 tagged test (team): pass' && exit 0) \
|| (echo 'Stylesheet is md5 tagged test (team): fail' && exit 1)
kill $!
flask digest clean \
&& ls -laR example/static/ | wc -l \
| grep -q "26" \
&& (echo "File count after cleaning test (index): pass" && exit 0) \
|| (echo "File count after cleaning test (index): fail" && exit 1)
ls -laR example/about/static/ | wc -l \
| grep -q "5" \
&& (echo "File count after cleaning test (about): pass" && exit 0) \
|| (echo "File count after cleaning test (about): fail" && exit 1)
ls -laR example/contact/static/ | wc -l \
| grep -q "5" \
&& (echo "File count after cleaning test (contact): pass" && exit 0) \
|| (echo "File count after cleaning test (contact): fail" && exit 1)
ls -laR example/about/team/static/ | wc -l \
| grep -q "5" \
&& (echo "File count after cleaning test (team): pass" && exit 0) \
|| (echo "File count after cleaning test (team): fail" && exit 1)
flask run &
sleep 5 \
&& curl http://localhost:5000 \
| grep -q 'https://cdn.example.com/static/js/app.js' \
&& (echo 'Javascript is not md5 tagged test: pass' && exit 0) \
|| (echo 'Javascript is not md5 tagged test: fail' && exit 1)
flask digest clean
kill $!