Run tests #529
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run tests | |
on: | |
schedule: | |
- cron: '19 3 * * 1-5' | |
push: | |
pull_request: | |
workflow_call: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python environment | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12.4" | |
- name: Run Black | |
uses: psf/black@stable | |
with: | |
options: "--check --verbose --exclude experimental|illustris_python" | |
jupyter: true | |
- name: Run flake8 | |
uses: py-actions/flake8@v2 | |
with: | |
exclude: experimental,illustris_python | |
- name: Install mypy | |
run: pip install mypy | |
- name: Install types | |
run: mypy --install-types --non-interactive | |
- name: Run mypy | |
run: mypy | |
- name: Install almasim | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
pip install -e . | |
- name: Create kaggle.json from secret | |
env: | |
KAGGLE_JSON_B64: ${{ secrets.KAGGLE_JSON_B64 }} | |
run: | | |
mkdir -p /home/runner/.kaggle | |
echo $KAGGLE_JSON_B64 | base64 --decode > /home/runner/.kaggle/kaggle.json | |
chmod 600 /home/runner/.kaggle/kaggle.json | |
- name: Install required libraries | |
run: | | |
sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 libxcb-shape0 libglib2.0-0 libgl1-mesa-dev | |
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev | |
# start xvfb in the background | |
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 & | |
- name: install packages | |
uses: tlambert03/setup-qt-libs@v1 | |
- name: Set up Headless Environment | |
run: export QT_QPA_PLATFORM=offscreen | |
- name: Run stubtest | |
run: | | |
chmod +x ./run_stubtest | |
./run_stubtest | |
tests: | |
needs: lint | |
#runs-on: ubuntu-latest | |
#strategy: | |
# matrix: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
#fail-fast: true # cancel other jobs immediately if this one fails | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
python-version: ["3.12"] | |
env: | |
DISPLAY: ':99.0' | |
PYTHONPATH: ${{ github.workspace }}/ALMASim # Ensure PYTHONPATH is set | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Qt | |
uses: tlambert03/setup-qt-libs@v1 | |
- name: Install Libraries Ubuntu | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt install -y xvfb x11-utils libxkbcommon-x11-0 python3-qtpy libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 | |
- name: Install dependencies (Ubuntu/MacOS) | |
if: matrix.os != 'windows-latest' | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest pytest-cov pytest-qt | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
if [ -f optional_requirements.txt ]; then pip install -r optional_requirements.txt; fi | |
pip install -e . | |
pip install PyQt6 --upgrade | |
pip install pyqtgraph | |
- name: Install dependencies (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest pytest-cov pytest-qt | |
if (Test-Path requirements.txt) { pip install -r requirements.txt } | |
if (Test-Path optional_requirements.txt) { pip install -r optional_requirements.txt } | |
pip install -e . | |
pip install PyQt6 --upgrade | |
pip install pyqtgraph | |
shell: pwsh | |
- name: Update PATH macos | |
if: matrix.os == 'macos-latest' | |
run: echo "/Users/runner/.local/bin" >> $GITHUB_PATH | |
- name: Update PATH windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
echo "C:\Users\runneradmin\AppData\Roaming\Python\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
shell: pwsh | |
- name: Set up Headless Environment | |
if: matrix.os != 'windows-latest' | |
run: export QT_QPA_PLATFORM=offscreen | |
- name: Create kaggle.json from secret (Linux/MacOS) | |
if: matrix.os != 'windows-latest' | |
env: | |
KAGGLE_JSON_B64: ${{ secrets.KAGGLE_JSON_B64 }} | |
run: | | |
mkdir -p $HOME/.kaggle | |
echo $KAGGLE_JSON_B64 | base64 --decode > $HOME/.kaggle/kaggle.json | |
chmod 600 $HOME/.kaggle/kaggle.json | |
- name: Create kaggle.json from secret (Windows) | |
if: matrix.os == 'windows-latest' | |
env: | |
KAGGLE_JSON_B64: ${{ secrets.KAGGLE_JSON_B64 }} | |
run: | | |
mkdir -p $env:USERPROFILE\.kaggle | |
echo $env:KAGGLE_JSON_B64 | base64 --decode > $env:USERPROFILE\.kaggle\kaggle.json | |
chmod 600 $env:USERPROFILE\.kaggle\kaggle.json | |
- name: Install poetry dependencies (Linux/MacOS) | |
if: matrix.os != 'windows-latest' | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
poetry install | |
- name: Install poetry dependencies (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
curl -sSL https://install.python-poetry.org | python - | |
poetry install | |
shell: pwsh | |
- name: Run unit tests | |
uses: aganders3/headless-gui@v1 | |
with: | |
run: | | |
poetry run python -m pytest --ignore=illustris_python --rootdir ${{ github.workspace }} | |
#- name: Test with pytest | |
# run: | | |
# /usr/bin/xvfb-run --auto-servernum \ | |
# --server-num=1 \ | |
# --server-args="-screen 1 1920x1200x24 -ac +extension GLX" \ | |
# /opt/hostedtoolcache/Python/3.12.4/x64/bin/pytest --ignore=illustris_python --rootdir ${{ github.workspace }} | |
tests-and-coverage: | |
needs: lint | |
runs-on: ubuntu-latest | |
env: | |
DISPLAY: ':99.0' | |
PYTHONPATH: ${{ github.workspace }}/ALMASim # Ensure PYTHONPATH is set | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12.4" | |
- name: Install Qt | |
uses: tlambert03/setup-qt-libs@v1 | |
- name: Install Libraries Ubuntu | |
run: sudo apt install -y xvfb x11-utils libxkbcommon-x11-0 python3-qtpy libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest pytest-cov pytest-qt | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
if [ -f optional_requirements.txt ]; then pip install -r optional_requirements.txt; fi | |
pip install -e . | |
pip install PyQt6 --upgrade | |
pip install pyqtgraph | |
cd .. | |
- name: Set up Headless Environment | |
run: export QT_QPA_PLATFORM=offscreen | |
- name: Create kaggle.json from secret | |
env: | |
KAGGLE_JSON_B64: ${{ secrets.KAGGLE_JSON_B64 }} | |
run: | | |
mkdir -p /home/runner/.kaggle | |
echo $KAGGLE_JSON_B64 | base64 --decode > /home/runner/.kaggle/kaggle.json | |
chmod 600 /home/runner/.kaggle/kaggle.json | |
- name: Install poetry dependencies | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
poetry install | |
#- name: Test with pytest including coverage report | |
# run: | | |
# /usr/bin/xvfb-run --auto-servernum \ | |
# --server-num=1 \ | |
# --server-args="-screen 1 1920x1200x24 -ac +extension GLX" \ | |
# /opt/hostedtoolcache/Python/3.12.4/x64/bin/pytest --ignore=illustris_python --cov=./ --cov-report=xml --rootdir ${{ github.workspace }} | |
- name: Install pytest-cov (if needed) | |
run: poetry add pytest-cov | |
- name: Test with pytest including coverage report | |
uses: aganders3/headless-gui@v1 | |
with: | |
run: | | |
poetry run pytest --ignore=illustris_python --cov=./ --cov-report=xml --rootdir ${{ github.workspace }} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |