Skip to content

update tests

update tests #372

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: build
on:
workflow_dispatch: {}
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
release:
types: [created]
jobs:
quality:
name: Code QA
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: pip install black flake8 isort
- run: isort --version
- run: black --version
- run: isort --check .
- run: black --check .
- run: flake8 .
checks:
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-latest"]
python-version: ["3.8"]
#platform: ["ubuntu-latest", "macos-latest", "windows-latest"]
#python-version: ["3.6", "3.7", "3.8", "3.9"]
name: Python ${{ matrix.python-version }} on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
needs: quality
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Updating pip
run: |
python -m pip install --upgrade pip
pip debug --verbose
- run: pip install climetlab
- name: Installing climetlab_s2s_ai_challenge
run: pip install -e .
- name: Setup test environment
run: |
pip install pytest
pip freeze
# pytest -k 'not test_notebooks' # does not work on github actions
pip install zarr s3fs # dependencies for test/test_read_zarr.py
- run: TEST_FAST=TRUE pytest tests/test_benchmarks.py
- run: TEST_FAST=TRUE pytest tests/test_info.py
# - run: TEST_FAST=TRUE pytest tests/test_notebooks.py
- run: TEST_FAST=TRUE pytest tests/test_read.py
- run: TEST_FAST=TRUE pytest tests/test_cfconventions.py
# - run: TEST_FAST=TRUE pytest tests/test_long_observations.py # too long on github
- run: TEST_FAST=TRUE pytest tests/test_merge.py
- run: TEST_FAST=TRUE pytest tests/test_observations.py
- run: TEST_FAST=TRUE pytest tests/test_read_zarr.py
- name: Setup test environment for notebooks
run: |
pip install nbformat nbconvert ipykernel # dependencies for test/test_notebooks.py
pip freeze
- run: TEST_FAST=TRUE pytest tests/test_notebooks.py
deploy:
if: ${{ github.event_name == 'release' }}
name: Upload to Pypi
needs: checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Check version
run: |
release=${GITHUB_REF##*/}
version=$(python setup.py --version)
test "$release" == "$version"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist --verbose
twine upload dist/* --verbose