From dbb0e812ca837a8a0f528d30077b61ad8aa08bcc Mon Sep 17 00:00:00 2001 From: alexamici Date: Tue, 17 Nov 2020 16:53:13 +0100 Subject: [PATCH 1/5] Initall add githug actions --- .github/workflows/python-package-conda.yml | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 0000000..1567e18 --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,31 @@ +name: Python Package using Conda + +on: [push] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + $CONDA/bin/conda env update --file environment.yml --name base + - name: Lint with flake8 + run: | + $CONDA/bin/conda install flake8 + # stop the build if there are Python syntax errors or undefined names + $CONDA/bin/flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + $CONDA/bin/flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + $CONDA/bin/pytest From 5781b0e5eb810acc856839d46f0856c85876e1ea Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Tue, 17 Nov 2020 16:57:33 +0100 Subject: [PATCH 2/5] Sync with cfgrib --- .github/workflows/on-push.yml | 60 ++++++++++++++++++++++ .github/workflows/python-package-conda.yml | 31 ----------- 2 files changed, 60 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/on-push.yml delete mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml new file mode 100644 index 0000000..41008fd --- /dev/null +++ b/.github/workflows/on-push.yml @@ -0,0 +1,60 @@ +name: on-push + +on: [push] + +jobs: + unit-tests: + runs-on: ${{ matrix.os }}-latest + strategy: + max-parallel: 5 + matrix: + os: [ubuntu] + python: [3.6, 3.7, 3.8] + include: + - os: macos + python: 3.8 + - os: windows + python: 3.8 + + steps: + - uses: actions/checkout@v2 + - uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python }} + activate-environment: ${{ matrix.os }}-${{ matrix.python }} + environment-file: tests/environment-${{ matrix.os }}-${{ matrix.python }}.yml + - name: Test with pytest + shell: bash -l {0} + run: | + conda install pytest pytest-cov + python -m pip install --no-deps -e . + pytest -v --cov=. --cov-report=xml --cov-branch . + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + + code-quality: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Lint with flake8 + run: | + $CONDA/bin/conda install flake8 + # stop the build if there are Python syntax errors or undefined names + $CONDA/bin/flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + $CONDA/bin/flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + code-style: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Check code style with black + run: | + $CONDA/bin/conda install black + $CONDA/bin/black --check --line-length 99 . + - name: Check code style with isort + run: | + $CONDA/bin/conda install isort + $CONDA/bin/isort . diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml deleted file mode 100644 index 1567e18..0000000 --- a/.github/workflows/python-package-conda.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Python Package using Conda - -on: [push] - -jobs: - build-linux: - runs-on: ubuntu-latest - strategy: - max-parallel: 5 - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install dependencies - run: | - # $CONDA is an environment variable pointing to the root of the miniconda directory - $CONDA/bin/conda env update --file environment.yml --name base - - name: Lint with flake8 - run: | - $CONDA/bin/conda install flake8 - # stop the build if there are Python syntax errors or undefined names - $CONDA/bin/flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - $CONDA/bin/flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - conda install pytest - $CONDA/bin/pytest From 463c64797ec31625168d1942688827cd7209fbd1 Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Tue, 17 Nov 2020 17:01:53 +0100 Subject: [PATCH 3/5] Simplify testing --- .github/workflows/on-push.yml | 3 ++- tests/environment.yml | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/environment.yml diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 41008fd..a69d685 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -22,7 +22,8 @@ jobs: with: python-version: ${{ matrix.python }} activate-environment: ${{ matrix.os }}-${{ matrix.python }} - environment-file: tests/environment-${{ matrix.os }}-${{ matrix.python }}.yml +# environment-file: tests/environment-${{ matrix.os }}-${{ matrix.python }}.yml + environment-file: tests/environment.yml - name: Test with pytest shell: bash -l {0} run: | diff --git a/tests/environment.yml b/tests/environment.yml new file mode 100644 index 0000000..33aeb45 --- /dev/null +++ b/tests/environment.yml @@ -0,0 +1,8 @@ +channels: + - defaults + - conda-forge +dependencies: + - attrs>=19.2 + - cffi + - eccodes=>2.19.0 + - numpy From 6dcadee517d008ea706c33e7fa6bbefedaf9d8d1 Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Tue, 17 Nov 2020 17:04:38 +0100 Subject: [PATCH 4/5] Remove options form black --- .github/workflows/on-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index a69d685..9d7ffbf 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -54,7 +54,7 @@ jobs: - name: Check code style with black run: | $CONDA/bin/conda install black - $CONDA/bin/black --check --line-length 99 . + $CONDA/bin/black --check . - name: Check code style with isort run: | $CONDA/bin/conda install isort From 5227b00a5c464c1a7b09b10fc829548853f98225 Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Tue, 17 Nov 2020 17:12:44 +0100 Subject: [PATCH 5/5] Fix windows parsing. --- gribapi/bindings.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gribapi/bindings.py b/gribapi/bindings.py index 1d7c762..ca77938 100644 --- a/gribapi/bindings.py +++ b/gribapi/bindings.py @@ -29,10 +29,9 @@ from ._bindings import ffi, lib except ModuleNotFoundError: ffi = cffi.FFI() - ffi.cdef( - pkgutil.get_data(__name__, "grib_api.h").decode("utf-8") - + pkgutil.get_data(__name__, "eccodes.h").decode("utf-8") - ) + CDEF = pkgutil.get_data(__name__, "grib_api.h") + CDEF += pkgutil.get_data(__name__, "eccodes.h") + ffi.cdef(CDEF.decode("utf-8").replace("\r", "\n")) LIBNAMES = ["eccodes", "libeccodes.so", "libeccodes"]