-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
76 lines (69 loc) · 1.93 KB
/
.gitlab-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
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PYTHONDEVMODE: "1"
PIP_ROOT_USER_ACTION: "ignore"
cache:
paths:
- "$CI_PROJECT_DIR/.cache/pip"
- "$CI_PROJECT_DIR/.cache/apt"
# TODO isolate venvs, don't install all locales
test-generic:
stage: test
image: python:3
before_script:
- 'mkdir -p "$CI_PROJECT_DIR/.cache/apt/partial"'
- "rm -f /etc/apt/apt.conf.d/docker-clean"
- 'echo "Dir::Cache::Archives \"$CI_PROJECT_DIR/.cache/apt\";" >> /etc/apt/apt.conf'
- 'echo "Binary::apt::APT::Keep-Downloaded-Packages \"true\";" >> /etc/apt/apt.conf'
- 'echo "APT::Install-Recommends \"false\";" >> /etc/apt/apt.conf'
script: |
set -eu
apt update
apt-get install -y locales-all # for sort-with-numbers
apt install -y sqlite3 # for *sqlite*
pip install pytest || exit 1
err=1
for f in "$CI_PROJECT_DIR"/*/test.py "$CI_PROJECT_DIR"/*/test.sh
do
echo "Testing $f" >&2
dir=$(dirname "$f")
cd "$dir"
if [ -f requirements.txt ]
then
pip install -r requirements.txt
fi >&2
if grep -q "env pytest" "$f"
then
"$f" --junitxml="$CI_PROJECT_DIR/testreport-${dir##*/}".xml >&2 || echo "FAILED for $f"
else
"$f" >&2 || echo "FAILED for $f"
fi
done | grep FAILED || err=0
exit $err
artifacts:
reports:
junit: testreport-*.xml
lint-shellcheck:
stage: test
image: docker.io/pipelinecomponents/shellcheck
script: |
err=1
set -eu
grep -r -l '^# shellcheck enable=' "$CI_PROJECT_DIR"/* | while read file
do
shellcheck "$file"
done | grep . || err=0
exit $err
lint-python:
stage: test
image: python:3
script: |
err=1
set -eu
pip install flake8
find -name '*.py' -exec flake8 --select E999 '{}' +
grep -r -l '^#!/usr/bin/env python3' "$CI_PROJECT_DIR"/* | while read file
do
flake8 --select E999 "$file"
done | grep . || err=0
exit $err