-
Notifications
You must be signed in to change notification settings - Fork 39
161 lines (137 loc) · 4.94 KB
/
build-and-test.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Build NAV and run full test suite
on: [push, pull_request]
jobs:
build-and-test:
name: "Test on Python ${{ matrix.python-version}}"
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v3
- name: "Cache pip packages"
uses: actions/cache@v3
id: pip-cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: "Cache tox environments"
uses: actions/cache@v3
id: tox-cache
with:
path: .tox
key: ${{ runner.os }}-tox-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt', '**/requirements/*.txt', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-tox-${{ matrix.python-version }}-
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: "Set environment variables"
run: |
echo "WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "PGHOST=localhost" >> $GITHUB_ENV
echo "PGUSER=nav" >> $GITHUB_ENV
echo "PGPASSWORD=password" >> $GITHUB_ENV
- name: "Update APT package lists"
run: |
sudo apt-get update -y
- name: "Install test runner dependencies"
run: |
set -xe
python -m pip install --upgrade 'pip==23.1.0' setuptools wheel 'tox<4' tox-gh-actions coverage virtualenv snmpsim 'pyasn1<0.5.0'
sudo apt-get install -y nbtscan
# virtualenv seems to currently be embedding a broken version of
# setuptools (2022-03-31). this ensures these embedded wheels are always
# up to date, but can potentially be removed again down the road.
- name: "Upgrade embedded virtualenv wheels"
run: |
virtualenv --upgrade-embed-wheel
- name: "Install libraries needed to build external dependencies"
run: |
set -xe
sudo apt-get install -y libldap2-dev libsasl2-dev libtidy5deb1 libsnmp40
- uses: browser-actions/setup-chrome@latest
- run: chrome --version
- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: '115.0.5790.170' # https://github.com/nanasess/setup-chromedriver/issues/200
- name: "Set up PostgreSQL"
uses: harmon758/postgresql-action@v1
with:
postgresql version: '9.6' # minimum NAV requirement
postgresql user: $PGUSER
postgresql password: $PGPASSWORD
- name: "Run tests"
run: |
export DISPLAY=:99
ulimit -c unlimited
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t
python -m tox
- name: Upload Selenium driver logs (${{ matrix.python-version }})
if: always()
uses: actions/upload-artifact@v3
with:
name: pytest-logs
path: |
/tmp/pytest-of-runner
- name: "Upload coverage to Codecov"
if: "github.repository_owner == 'Uninett'"
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
- name: Upload test reports (${{ matrix.python-version }})
if: always()
uses: actions/upload-artifact@v3
with:
name: test-reports
path: |
reports/**/*
- name: Upload core dumps (${{ matrix.python-version }})
if: failure()
uses: actions/upload-artifact@v3
with:
name: core-dumps
path: |
/tmp/core-*
- name: Print stack traces of core dumps (${{ matrix.python-version }})
if: failure()
run: |
sudo apt-get install -y gdb
set -x
for core in /tmp/core-*; do
echo "===== CORE: $core ====="
file "$core"
program=$(gdb -ex quit -c "$core" | grep -o "generated by.*" | awk '{print $3}' | tr -d '`')
gdb -ex bt "$program" "$core"
echo
done
javascript:
name: "Test Javascript code"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: browser-actions/setup-chrome@latest
- uses: browser-actions/setup-firefox@latest
- run: chrome --version
- uses: actions/setup-node@v3
with:
node-version: 16
- name: npm install
run: |
cd python/nav/web/static/js
npm ci
- name: npm test
run: xvfb-run -a npm test
working-directory: ./python/nav/web/static/js
- name: Upload JavaScript test reports
if: always()
uses: actions/upload-artifact@v3
with:
name: javascript-test-reports
path: |
reports/**/*