github actionでPyQt5を使ったアプリをテストするも、qt.qpa.xcb could not connect to display
でエラーになってしまった。
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
start.sh: line 40: 2323 Aborted (core dumped) python3 game_manager/game_manager.py --game_time ${GAME_TIME} --seed ${RANDOM_SEED} --obstacle_height ${OBSTACLE_HEIGHT} --obstacle_probability ${OBSTACLE_PROBABILITY} --drop_speed ${DROP_SPEED} --manual ${IS_MANUAL_CONTROLL} --use_sample ${IS_SAMPLE_CONTROLL}
Error: Process completed with exit code 134.
以下の通り、workflow上で環境変数追加と、xvfb
をインストールして解決。
# 環境変数
env:
DISPLAY: ':99'
- name: Xvfb install and run
run: |
sudo apt-get install -y xvfb
Xvfb -ac ${{ env.DISPLAY }} -screen 0 1280x780x24 &
以下は今回作成した.yaml
ファイルの全体、ご参考。
.github/workflows/test.yaml
name: Python package
on: [push]
# 環境変数
env:
DISPLAY: ':99'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
sudo apt-get install -y python3-pip
pip3 install --upgrade pip
pip3 install numpy
pip3 install PyQt5
sudo apt-get install -y python3-pyqt5
sudo apt-get install -y git
sudo apt-get install -y jq
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Display Python version
run: python -c "import sys; print(sys.version)"
# xvfbのインストールと起動
- name: Xvfb install and run
run: |
sudo apt-get install -y xvfb
Xvfb -ac ${{ env.DISPLAY }} -screen 0 1280x780x24 &
- name: tetris_game
run: |
git clone https://github.com/seigot/tetris_game
cd tetris_game
bash start.sh -s y -t 3