-
Notifications
You must be signed in to change notification settings - Fork 428
135 lines (117 loc) · 4.5 KB
/
tests-xv4.yaml
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
# This workflow will install Python dependencies, run tests and lint with some versions of Python
# Based on: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Conduct xV4 and comm CI tests
on:
pull_request:
push:
branches:
- master
paths:
- tests/**
- '**.py'
- .github/**
permissions:
contents: read
jobs:
ubuntu-tests-xv4:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-latest]
python-version: ["3.8", "3.10"]
# No need to test any python version on multiple Ubuntu versions, the Ubuntu version is
# only to provide best matching environment for the Python.
exclude:
- os: ubuntu-latest
python-version: "3.8"
- os: ubuntu-20.04
python-version: "3.10"
env:
working-directory: dji-firmware-tools
defaults:
run:
# All "run" actions will start in this subdirectory
working-directory: ${{ env.working-directory }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: dji-firmware-tools
- name: Checkout pyelftools
# These are neccessary to convert BIN back to ELF, and in turn for all hardcoders
uses: actions/checkout@v3
with:
repository: mefistotelis/pyelftools
path: pyelftools
- name: Checkout mkbootimg
# We use `unpackbootimg` from there to extract some generic Android images
uses: actions/checkout@v3
with:
repository: osm0sis/mkbootimg
path: dji-firmware-tools/mkbootimg
- name: Checkout rkflashtool
# We use `rkunpack` from there to extract some Rockchip Android images
uses: actions/checkout@v3
with:
repository: linux-rockchip/rkflashtool
path: dji-firmware-tools/rkflashtool
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libusb-1.0-0-dev # required to build rkflashtool
sudo apt-get install -y binutils-arm-none-eabi # required to test bin2elf
python -m pip install --upgrade pip
pip install pyserial # required to test comm_* tools
pip install lz4 # required to extract compressed files within the FW modules
pip install pycryptodome # required to test FW package extraction
pip install capstone keystone-engine # required to test hardcoders
pip install flake8 pytest pytest-cov pytest-order
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build mkbootimg
run: |
cd mkbootimg
make
cd -
- name: Build rkflashtool
run: |
cd rkflashtool
make
cd -
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 ./*.py --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./*.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test communication tools - Run pyTest
run: |
# use --durations=0 to get execution time for all unit tests
pytest tests -m comm --log-cli-level=INFO --durations=0
- name: Test xV4 format - Download firmware package files
# Instead of the usual actions/download-artifact, we are downloading from Mega
uses: Difegue/action-megacmd@master
with:
args: get https://mega.nz/file/cd0zCBYY#QNzUepD_8iia5uy6hMBTM1dv48yO7iQhSCPXkMr2p6c ${{ env.GITHUB_WORKSPACE }}
- name: Test xV4 format - Set ownership for downloaded files
# downloaded files are owned by root; unzip has no permission
run: |
sudo chown -cR $(id -u):$(id -g) ../fw_packages-*.zip
- name: Test xV4 format - Extract downloaded files
run: |
mkdir -p fw_packages
unzip -q ../fw_packages-xv4-selected-ci-v1.zip -d fw_packages
rm ../fw_packages-*.zip
- name: Test xV4 format - Run pyTest
run: |
# use --durations=0 to get execution time for all unit tests
pytest tests -m fw_xv4 --log-cli-level=INFO --durations=0 --rm-repacks
- name: Test xV4 format - Cleanup
run: |
rm -rf ./fw_packages/*
rm -rf ./out/*