add GH action tests
Browse files
.github/workflows/ci-testing.yml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: CI CPU testing
|
2 |
+
|
3 |
+
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
|
4 |
+
on: [push, pull_request]
|
5 |
+
|
6 |
+
jobs:
|
7 |
+
pytest:
|
8 |
+
|
9 |
+
runs-on: ${{ matrix.os }}
|
10 |
+
strategy:
|
11 |
+
fail-fast: false
|
12 |
+
matrix:
|
13 |
+
os: [ubuntu-18.04, windows-2019, macOS-10.15]
|
14 |
+
python-version: [3.7, 3.8]
|
15 |
+
|
16 |
+
# Timeout: https://stackoverflow.com/a/59076067/4521646
|
17 |
+
steps:
|
18 |
+
- uses: actions/checkout@v2
|
19 |
+
- name: Set up Python ${{ matrix.python-version }}
|
20 |
+
uses: actions/setup-python@v2
|
21 |
+
with:
|
22 |
+
python-version: ${{ matrix.python-version }}
|
23 |
+
|
24 |
+
# Note: This uses an internal pip API and may not always work
|
25 |
+
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
|
26 |
+
- name: Get pip cache
|
27 |
+
id: pip-cache
|
28 |
+
run: |
|
29 |
+
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
|
30 |
+
|
31 |
+
- name: Cache pip
|
32 |
+
uses: actions/cache@v1
|
33 |
+
with:
|
34 |
+
path: ${{ steps.pip-cache.outputs.dir }}
|
35 |
+
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-pip-${{ hashFiles('requirements.txt') }}
|
36 |
+
restore-keys: |
|
37 |
+
${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-pip-
|
38 |
+
|
39 |
+
- name: Install dependencies
|
40 |
+
run: |
|
41 |
+
# python -m pip install --upgrade --user pip
|
42 |
+
pip install -qr requirements.txt onnx
|
43 |
+
python --version
|
44 |
+
pip --version
|
45 |
+
pip list
|
46 |
+
shell: bash
|
47 |
+
|
48 |
+
- name: Download data
|
49 |
+
run: |
|
50 |
+
python3 -c "from utils.google_utils import *; gdrive_download('1n_oKgR81BJtqk75b00eAjdv03qVCQn2f', 'coco128.zip')" && mv ./coco128 ../
|
51 |
+
|
52 |
+
- name: Tests
|
53 |
+
run: |
|
54 |
+
for x in yolov5s yolov5m yolov5l yolov5x # models
|
55 |
+
do
|
56 |
+
python train.py --weights $x.pt --cfg $x.yaml --epochs 3 --img 320 --device 0,1 # train
|
57 |
+
di=cpu # inference devices
|
58 |
+
python detect.py --weights $x.pt --device $di # detect official
|
59 |
+
python detect.py --weights runs/exp0/weights/last.pt --device $di # detect custom
|
60 |
+
python test.py --weights $x.pt --device $di # test official
|
61 |
+
python test.py --weights runs/exp0/weights/last.pt --device $di # test custom
|
62 |
+
python models/yolo.py --cfg $x.yaml # inspect
|
63 |
+
python models/export.py --weights $x.pt --img 640 --batch 1 # export
|
64 |
+
done
|
65 |
+
shell: bash
|