Skip to content

Commit

Permalink
GUI unit test on Unix systems (#64)
Browse files Browse the repository at this point in the history
Able to launch GUI unit tests in the Actions for Ubuntu and macOS.
  • Loading branch information
dbouget authored Oct 31, 2023
1 parent 6b6840b commit ec0f85c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 52 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
with:
python-version: "3.8"

- name: Setup OpenGL
run: brew install mesa-glu libxrender libxi libxkbcommon

- name: Download ANTs
uses: robinraju/release-downloader@main
with:
Expand Down Expand Up @@ -53,12 +56,18 @@ jobs:
mkdir tmp_dependencies
pyinstaller --log-level INFO --noconfirm --clean assets/main.spec
# - name: Test executable
# run: QT_QPA_PLATFORM="offscreen" ./dist/Raidionics/Raidionics & sleep 5; kill -INT %+
# shell: bash
#
# - name: Test GUI startup
# run: cd ${{github.workspace}}/tests && python software_launch_test.py
- name: Test executable
env:
DISPLAY: ':1'
run: QT_QPA_PLATFORM="offscreen" ./dist/Raidionics/Raidionics & sleep 5; kill -INT %+
shell: bash

- name: Test GUI startup
env:
DISPLAY: ':1'
run: |
export QT_QPA_PLATFORM="offscreen"
cd ${{github.workspace}}/tests && python software_launch_test.py
- name: Make installer
run: |
Expand Down
29 changes: 4 additions & 25 deletions .github/workflows/build_macos_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@ jobs:
pip install urllib3==1.26.6
deactivate
# - name: Install cmake
# run: |
# brew update
# brew install cmake ninja
# ninja --version
# cmake --version
#
# - name: Build ANTs
# run: |
# cd ${{github.workspace}}
# mkdir ANTs
# cd ANTs
# git clone https://github.com/ANTsX/ANTs.git source
# mkdir build
# cd build
# cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/ANTs/install ../source
# make -j4
# cd ANTS-build
# make install
# cp -R ${{github.workspace}}/ANTs/source/Scripts ${{github.workspace}}/ANTs/install/

- name: Download ANTs
uses: robinraju/release-downloader@main
with:
Expand All @@ -79,17 +58,17 @@ jobs:
pyinstaller --log-level INFO --noconfirm --clean assets/main_arm.spec
- name: Test executable
run: QT_QPA_PLATFORM="offscreen" ./dist/Raidionics/Raidionics & sleep 5; kill -INT %+
run: ./dist/Raidionics/Raidionics & sleep 5; kill -INT %+
shell: bash

- name: Test GUI startup
run: cd ${{github.workspace}}/tests && python software_launch_test.py
run: cd ${{github.workspace}}/tests && python3 software_launch_test.py

- name: Make installer
run: |
git clone https://github.com/dbouget/quickpkg.git
quickpkg/quickpkg dist/Raidionics.app --output Raidionics-1.2.1-macOS.pkg
cp -r Raidionics-1.2.1-macOS.pkg dist/Raidionics-1.2.1-macOS-arm64.pkg
quickpkg/quickpkg dist/Raidionics.app --output Raidionics-1.2.2-macOS.pkg
cp -r Raidionics-1.2.2-macOS.pkg dist/Raidionics-1.2.2-macOS-arm64.pkg
- name: Upload package
uses: actions/upload-artifact@v3
Expand Down
53 changes: 34 additions & 19 deletions .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ jobs:
with:
python-version: "3.8"

- name: Free Up GitHub Actions Ubuntu Runner Disk Space
uses: dbouget/free-disk-space@main
with:
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false

# All of these default to true, but feel free to set to "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true

- name: Install CL dependencies
run: |
apt update && apt install -y sudo
Expand All @@ -32,23 +45,13 @@ jobs:
sudo apt-get install -y pocl-opencl-icd
- name: Setup OpenGL
run: sudo apt-get install -y libopengl0
run: sudo apt install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev

- name: Debug clinfo
run: clinfo

- name: Free Up GitHub Actions Ubuntu Runner Disk Space
uses: dbouget/free-disk-space@main
with:
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false

# All of these default to true, but feel free to set to "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
- name: Setup X virtual framebuffer
run: sudo apt-get install -y xvfb

- name: Download ANTs
uses: robinraju/release-downloader@main
Expand Down Expand Up @@ -80,12 +83,24 @@ jobs:
mkdir tmp_dependencies
pyinstaller --log-level INFO --noconfirm --clean assets/main.spec
# - name: Test executable
# run: QT_QPA_PLATFORM="offscreen" ./dist/Raidionics/Raidionics & sleep 5; kill -INT %+
# shell: bash
#
# - name: Test GUI startup
# run: cd ${{github.workspace}}/tests && python software_launch_test.py
- name: Test executable xvfb
env:
DISPLAY: ':1'
run: xvfb-run ./dist/Raidionics/Raidionics & sleep 5; kill -INT %+
shell: bash

- name: Test executable
env:
DISPLAY: ':1'
run: QT_QPA_PLATFORM="offscreen" ./dist/Raidionics/Raidionics & sleep 5; kill -INT %+
shell: bash

- name: Test GUI startup
env:
DISPLAY: ':1'
run: |
export QT_QPA_PLATFORM="offscreen"
cd ${{github.workspace}}/tests && python software_launch_test.py
- name: Make installer
run: |
Expand Down
5 changes: 3 additions & 2 deletions tests/software_launch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def software_launch_test():
proc.send_signal(signal.CTRL_BREAK_EVENT)
proc.kill()
else:
proc = subprocess.Popen([os.path.join(build_executable_path, 'Raidionics')], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, preexec_fn=os.setsid)
os.environ['QT_QPA_PLATFORM'] = "offscreen"
proc = subprocess.Popen([os.path.join(build_executable_path, 'Raidionics')],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=os.setsid)
time.sleep(10)
stdout = proc.stdout
stderr = proc.stderr
Expand Down

0 comments on commit ec0f85c

Please sign in to comment.