Add netcdf step #742
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
# (C) Copyright 2021 ECMWF. | |
# | |
# This software is licensed under the terms of the Apache Licence Version 2.0 | |
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | |
# In applying this licence, ECMWF does not waive the privileges and immunities | |
# granted to it by virtue of its status as an intergovernmental organisation | |
# nor does it submit to any jurisdiction. | |
# | |
name: Tests and release | |
on: | |
workflow_dispatch: {} | |
# schedule: | |
# # Every day at 3:07am | |
# # on the "default" branch set in github (currently is develop) | |
# - cron: '07 3 * * *' | |
release: | |
types: [created] | |
push: | |
branches: | |
- "*" | |
repository_dispatch: | |
types: | |
- cdsapi-updated | |
- magics-python-updated | |
- ecmwf-api-client-updated | |
jobs: | |
quality: | |
name: Code QA | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: pip install black flake8 isort | |
- run: black --version | |
- run: isort --version | |
- run: flake8 --version | |
- run: isort --check . | |
- run: black --check . | |
- run: flake8 . | |
# test_build_doc: | |
# name: Test building documentation | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: Install packages needed to build the documentation | |
# run: | | |
# pip install sphinx | |
# pip install -r docs/requirements.txt | |
# sudo apt-get install pandoc | |
# pip freeze | |
# - name: Documentation | |
# run: | | |
# make clean | |
# make html | |
# # make linkcheck (don't run yet) | |
# working-directory: docs | |
download-test-data: | |
name: Download test data | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Tokens | |
shell: python | |
env: | |
ECMWFAPIRC: ${{ secrets.ECMWFAPIRC }} | |
CDSAPIRC: ${{ secrets.CDSAPIRC }} | |
run: | | |
import os | |
# for n in ('ECMWFAPIRC', 'CDSAPIRC'): | |
n = 'ECMWFAPIRC' | |
m = os.path.expanduser("~/." + n.lower()) | |
if os.environ[n]: | |
with open(m, "w") as f: | |
print(os.environ[n], file=f) | |
- run: mkdir test-data | |
- run: echo "dataA" > test-data/dataA.txt | |
- run: echo "dataB" > test-data/dataB.txt | |
- run: cat test-data/dataA.txt | |
- name: Tar files | |
run: tar -cvf test-data.tar test-data | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-data | |
path: test-data.tar | |
tests-with-external-download: | |
if: github.event_name == 'release' && github.event.action == 'created' | |
strategy: | |
fail-fast: true | |
matrix: | |
platform: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
python-version: ["3.10"] | |
name: Long tests with external downloads Python ${{ matrix.python-version }} ${{ matrix.platform }} | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Tokens | |
shell: python | |
env: | |
ECMWFAPIRC: ${{ secrets.ECMWFAPIRC }} | |
CDSAPIRC: ${{ secrets.CDSAPIRC }} | |
run: | | |
import os | |
# for n in ('ECMWFAPIRC', 'CDSAPIRC'): | |
n = 'ECMWFAPIRC' | |
m = os.path.expanduser("~/." + n.lower()) | |
if os.environ[n]: | |
with open(m, "w") as f: | |
print(os.environ[n], file=f) | |
- name: Install climetlab | |
run: pip install -e . # run: pip install .[interactive,tensorflow,zarr] | |
- run: climetlab versions | |
- name: Install test tools | |
run: | | |
pip install pytest | |
pip freeze | |
- name: Long Tests | |
run: pytest --durations=0 -E release -k 'not test_notebooks' | |
tests-notebooks: | |
if: github.event_name == 'release' && github.event.action == 'created' | |
strategy: | |
matrix: | |
platform: ["ubuntu-latest"] | |
python-version: ["3.9"] | |
name: Tests notebooks Python ${{ matrix.python-version }} ${{ matrix.platform }} | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Tokens | |
shell: python | |
env: | |
ECMWFAPIRC: ${{ secrets.ECMWFAPIRC }} | |
CDSAPIRC: ${{ secrets.CDSAPIRC }} | |
run: | | |
import os | |
# for n in ('ECMWFAPIRC', 'CDSAPIRC'): | |
n = 'ECMWFAPIRC' | |
m = os.path.expanduser("~/." + n.lower()) | |
if os.environ[n]: | |
with open(m, "w") as f: | |
print(os.environ[n], file=f) | |
- name: Install climetlab | |
run: pip install -e . # run: pip install .[interactive,tensorflow,zarr] | |
- run: climetlab versions | |
- name: Install test tools | |
run: | | |
pip install pytest | |
pip freeze | |
- name: Tests notebooks | |
run: pytest tests/documentation/test_notebooks.py | |
short-tests: | |
# if: (github.event_name == 'release' && github.event.action == 'created') || github.ref == 'refs/heads/main' | |
# if: github.event_name == 'release' && github.event.action == 'created' | |
# if: github.ref == 'refs/heads/main' | |
needs: [download-test-data] | |
strategy: | |
matrix: | |
platform: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
python-version: ["3.8", "3.9", "3.10"] | |
# platform: ["ubuntu-latest"] | |
# python-version: ["3.10"] | |
name: Short tests Python ${{ matrix.python-version }} ${{ matrix.platform }} | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Download test-data | |
uses: actions/download-artifact@v3 | |
with: | |
name: test-data | |
- run: tar xvf test-data.tar | |
- run: cat test-data/dataA.txt | |
- name: Tokens | |
# (this should be removed when tests are refactored) | |
shell: python | |
env: | |
ECMWFAPIRC: ${{ secrets.ECMWFAPIRC }} | |
CDSAPIRC: ${{ secrets.CDSAPIRC }} | |
run: | | |
import os | |
# for n in ('ECMWFAPIRC', 'CDSAPIRC'): | |
n = 'ECMWFAPIRC' | |
m = os.path.expanduser("~/." + n.lower()) | |
if os.environ[n]: | |
with open(m, "w") as f: | |
print(os.environ[n], file=f) | |
- name: Install climetlab | |
run: pip install -e . | |
- run: climetlab versions | |
- name: Install test tools | |
run: | | |
pip install pytest | |
pip freeze | |
- name: Check imports | |
run: | | |
pytest tests/test_imports.py | |
env: | |
SKIP_TEST_IMPORTS: 0 | |
- name: Tests | |
run: | | |
# -E flag is defined in conftest.py | |
# notebooks need more dependencies | |
# pytest --durations=0 -E release -k 'not test_notebooks' | |
pytest --durations=10 -vv -E short | |
# - name: Install climetlab full | |
# run: | | |
# pip install .[interactive,tensorflow,zarr] | |
# pip freeze | |
# - name: Tests with dependencies | |
# run: | | |
# pytest --durations=10 -vv -E short | |
check-version-tag: | |
if: github.event_name == 'release' && github.event.action == 'created' | |
name: Check versions and tags | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8" | |
- name: Check that tag version matches package version | |
run: | | |
tag=${GITHUB_REF#refs/tags/} | |
version=$(python setup.py --version) | |
echo 'tag='$tag | |
echo "version file="$version | |
test "$tag" == "$version" | |
deploy: | |
name: Upload to Pypi and release | |
needs: [check-version-tag, short-tests, quality, tests-with-external-download, tests-notebooks] | |
# needs: [check-version-tag, short-tests, quality, test_build_doc, tests-with-external-download, tests-notebooks] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Build pip package | |
run: python setup.py sdist | |
- name: Publish | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: twine upload --verbose dist/* |