-
Notifications
You must be signed in to change notification settings - Fork 428
116 lines (101 loc) · 4.03 KB
/
tests-imah2-pt2.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
# 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 IMaH v2 CI tests part2
on:
pull_request:
push:
branches:
- master
paths:
- tests/**
- '**.py'
- .github/**
permissions:
contents: read
jobs:
ubuntu-tests-imahv2-pt2:
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 sdat2img
# We use `sdat2img.py` from there to consolidate sparse Android data images
uses: actions/checkout@v3
with:
repository: xpirt/sdat2img
path: dji-firmware-tools/sdat2img
- name: Checkout ext4 extractor
# We use `ext4_cp.py` from there to extract Linux Ext filesystems
uses: actions/checkout@v3
with:
repository: mefistotelis/ext4
path: dji-firmware-tools/ext4
- 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 binutils-arm-none-eabi # required to test bin2elf
python -m pip install --upgrade pip
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 pytest pytest-cov pytest-order
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test IMaH v2 format - Download firmware package files [1/2]
# Instead of the usual actions/download-artifact, we are downloading from Mega
uses: Difegue/action-megacmd@master
with:
args: get https://mega.nz/file/EFUmnDqK#jfWnmmNbutnSQ08v624tQKDzyslYVwds1vVKncMFOLk ${{ env.GITHUB_WORKSPACE }}
- name: Test IMaH v2 format - Download firmware package files [2/2]
# Instead of the usual actions/download-artifact, we are downloading from Mega
uses: Difegue/action-megacmd@master
with:
args: get https://mega.nz/file/kVlhEKqA#_RL44RV0p0jmrr2iyuDMa6ElaayAoC8TeU6RZDftIEg ${{ env.GITHUB_WORKSPACE }}
- name: Test IMaH v2 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 IMaH v2 format - Extract downloaded files
run: |
mkdir -p fw_packages
unzip -q ../fw_packages-imah2-selected-ci-p3-v1.zip -d fw_packages
unzip -q ../fw_packages-imah2-selected-ci-p4-v1.zip -d fw_packages
rm ../fw_packages-*.zip
- name: Test IMaH v2 format - Run pyTest
run: |
# use --durations=0 to get execution time for all unit tests
pytest tests -m fw_imah_v2 --log-cli-level=INFO --durations=0 --rm-repacks
- name: Test IMaH v2 format - Cleanup
run: |
rm -rf ./fw_packages/*
rm -rf ./out/*