-
Notifications
You must be signed in to change notification settings - Fork 54
133 lines (127 loc) · 6.46 KB
/
tests.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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
code_style:
runs-on: ubuntu-latest
steps:
- name: Checkout Ghidrathon
uses: actions/checkout@v4
- name: Configure Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Configure Python
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Lint with isort
run: |
pip install isort
isort --profile black --length-sort --line-width 120 -c .
- name: Lint with black
run: |
pip install black
black -l 120 --check .
- name: Lint with google-java-format
run: |
mkdir ../tmp
wget https://github.com/google/google-java-format/releases/download/v1.19.2/google-java-format-1.19.2-all-deps.jar -O ../tmp/google-java-format.jar
find . -name "*.java" -type f -print | xargs java -jar ../tmp/google-java-format.jar --dry-run --set-exit-if-changed
tests:
name: Tests in ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: code_style
strategy:
fail-fast: false
matrix:
ghidra-release-url: ["https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.3.2_build/ghidra_10.3.2_PUBLIC_20230711.zip", "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.0_build/ghidra_11.0_PUBLIC_20231222.zip"]
jep-jar-release-url: ["https://github.com/ninia/jep/releases/download/v4.2.0/jep-4.2.0.jar"]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.12"]
include:
- os: ubuntu-latest
ghidrathon-save-path: "/tmp/"
- os: windows-latest
ghidrathon-save-path: "C:\\Temp\\"
- os: macos-latest
ghidrathon-save-path: "/tmp/"
steps:
- name: Checkout Ghidrathon
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: "7.3"
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Configure temp folder
run: mkdir ../tmp
- name: Install Python requirements
run: |
pip install -r util/requirements.txt
pip install -r data/python/tests/requirements.txt
python -c "import importlib.util;import pathlib;print(pathlib.Path(importlib.util.find_spec('jep').origin).parent)"
- name: Download dependencies Linux/macOS
if : ${{ matrix.os != 'windows-latest' }}
run: |
wget ${{ matrix.ghidra-release-url }} -O ../tmp/ghidra.zip
unzip ../tmp/ghidra.zip -d ../tmp/ghidra
mv ../tmp/ghidra/$(ls ../tmp/ghidra) ../tmp/ghidra/ghidra_PUBLIC
wget ${{ matrix.jep-jar-release-url }} -O ./lib/jep-4.2.0.jar
- name: Download dependencies Windows
if : ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
Invoke-WebRequest -URI "${{ matrix.ghidra-release-url }}" -OutFile "../tmp/ghidra.zip"
mkdir ../tmp/ghidra
tar -xf ../tmp/ghidra.zip -C ../tmp/ghidra
Rename-Item -Path "../tmp/ghidra/$((Get-ChildItem -Path "../tmp/ghidra").Name)" -NewName "ghidra_PUBLIC"
Invoke-WebRequest -URI "${{ matrix.jep-jar-release-url }}" -OutFile "./lib/jep-4.2.0.jar"
- name: Build Ghidrathon
run: gradle -PGHIDRA_INSTALL_DIR=${{ github.workspace }}/../tmp/ghidra/ghidra_PUBLIC
- name: Install Ghidrathon Linux/macOS
if : ${{ matrix.os != 'windows-latest' }}
run: |
unzip ./dist/$(ls ./dist) -d ../tmp/ghidra/ghidra_PUBLIC/Ghidra/Extensions/
- name: Install Ghidrathon Windows
if : ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
Rename-Item -Path "./dist/$((Get-ChildItem -Path "./dist").Name)" -NewName "Ghidrathon.zip"
tar -xf ./dist/Ghidrathon.zip -C ../tmp/ghidra/ghidra_PUBLIC/Ghidra/Extensions/
# test Ghidrathon when GHIDRATHON_SAVE_PATH is unset
- name: Set Ghidrathon Python interpreter (GHIDRATHON_SAVE_PATH is unset)
run: python util/ghidrathon_configure.py ../tmp/ghidra/ghidra_PUBLIC -d
- name: Run tests (GHIDRATHON_SAVE_PATH is unset)
run: | # the -overwrite flag ensures that an existing project file that conflicts with an import file is overwritten
../tmp/ghidra/ghidra_PUBLIC/support/analyzeHeadless ${{ github.workspace }}/../tmp/ghidra test -Import ${{ github.workspace }}/../tmp/ghidra/ghidra_PUBLIC/GPL/DemanglerGnu/os/linux_x86_64/demangler_gnu_v2_24 -overwrite -PostScript ${{ github.workspace }}/data/python/tests/hello.py -PostScript ${{ github.workspace }}/data/python/tests/runall.py > ../tmp/log.txt
- name: Check tests (GHIDRATHON_SAVE_PATH is unset)
run: |
python -c "import pathlib, sys;log_text=pathlib.Path('../tmp/log.txt').read_text(encoding='utf-8');print(log_text);sys.exit(0 if 'runall.py called exit with code 0' in log_text else -1)"
python -c "import pathlib, sys; sys.exit(0 if pathlib.Path('hello.txt').exists() else -1)"
# test Ghidrathon when GHIDRATHON_SAVE_PATH is set
- name: Set Ghidrathon Python interpreter (GHIDRATHON_SAVE_PATH is set)
env:
GHIDRATHON_SAVE_PATH: ${{ matrix.ghidrathon-save-path }}
run: python util/ghidrathon_configure.py ../tmp/ghidra/ghidra_PUBLIC -d
- name: Run tests (GHIDRATHON_SAVE_PATH is set)
env:
GHIDRATHON_SAVE_PATH: ${{ matrix.ghidrathon-save-path }}
run: | # the -overwrite flag ensures that an existing project file that conflicts with an import file is overwritten
../tmp/ghidra/ghidra_PUBLIC/support/analyzeHeadless ${{ github.workspace }}/../tmp/ghidra test -Import ${{ github.workspace }}/../tmp/ghidra/ghidra_PUBLIC/GPL/DemanglerGnu/os/linux_x86_64/demangler_gnu_v2_24 -overwrite -PostScript ${{ github.workspace }}/data/python/tests/hello.py -PostScript ${{ github.workspace }}/data/python/tests/runall.py > ../tmp/log.txt
- name: Check tests (GHIDRATHON_SAVE_PATH is set)
run: |
python -c "import pathlib, sys;log_text=pathlib.Path('../tmp/log.txt').read_text(encoding='utf-8');print(log_text);sys.exit(0 if 'runall.py called exit with code 0' in log_text else -1)"
python -c "import pathlib, sys; sys.exit(0 if pathlib.Path('hello.txt').exists() else -1)"