|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a single version of Python |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
| 3 | + |
| 4 | +name: Tests |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ master ] |
| 9 | + pull_request: |
| 10 | + # Schedule daily tests |
| 11 | + schedule: |
| 12 | + - cron: '0 0 * * *' |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + name: ${{ matrix.os }} - Python ${{ matrix.python-version }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + python-version: [3.6, 3.7, 3.8] |
| 22 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 23 | + |
| 24 | + steps: |
| 25 | + # Checkout current git repository |
| 26 | + - name: Checkout |
| 27 | + |
| 28 | + with: |
| 29 | + # fecth all history so that versioneer works |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + # Setup Miniconda |
| 33 | + - name: Setup Miniconda |
| 34 | + |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python-version }} |
| 37 | + channels: conda-forge |
| 38 | + |
| 39 | + # Install GMT and other required dependencies from conda-forge |
| 40 | + - name: Install GMT and required dependencies |
| 41 | + shell: bash -l {0} |
| 42 | + run: | |
| 43 | + requirements_file=full-conda-requirements.txt |
| 44 | + cat requirements.txt requirements-dev.txt > $requirements_file |
| 45 | + cat << EOF >> $requirements_file |
| 46 | + gmt=6.0.0 |
| 47 | + make |
| 48 | + EOF |
| 49 | + conda install --yes --file $requirements_file |
| 50 | +
|
| 51 | + # Show installed pkg information for postmortem diagnostic |
| 52 | + - name: List installed packages |
| 53 | + shell: bash -l {0} |
| 54 | + run: conda list |
| 55 | + |
| 56 | + # Cache the ${HOME}/.gmt directory, for docs and testing |
| 57 | + - name: Cache GMT directory |
| 58 | + uses: actions/cache@v2 |
| 59 | + id: cache |
| 60 | + with: |
| 61 | + path: | |
| 62 | + ~/.gmt/cache |
| 63 | + ~/.gmt/server |
| 64 | + key: cache-gmt-${{ github.ref }}-${{ runner.os }}-20200609 |
| 65 | + restore-keys: cache-gmt-refs/heads/master- |
| 66 | + |
| 67 | + # Workaround for the timeouts of 'gmt which' on Linux and Windows |
| 68 | + - name: Download remote data using wget (Linux & Windows) |
| 69 | + shell: bash -l {0} |
| 70 | + run: | |
| 71 | + if [ "$RUNNER_OS" == "Windows" ]; then choco install wget; fi # install wget on Windows |
| 72 | + mkdir ~/.gmt ~/.gmt/cache ~/.gmt/server |
| 73 | + wget --no-check-certificate https://oceania.generic-mapping-tools.org/gmt_hash_server.txt -P ~/.gmt/server/ |
| 74 | + for data in earth_relief_01d.grd earth_relief_30m.grd earth_relief_10m.grd; do |
| 75 | + wget --no-check-certificate https://oceania.generic-mapping-tools.org/${data} -P ~/.gmt/server/ |
| 76 | + done |
| 77 | + for data in ridge.txt Table_5_11.txt tut_bathy.nc tut_quakes.ngdc tut_ship.xyz usgs_quakes_22.txt; do |
| 78 | + wget --no-check-certificate https://oceania.generic-mapping-tools.org/cache/${data} -P ~/.gmt/cache/ |
| 79 | + done |
| 80 | + if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'macOS' |
| 81 | + |
| 82 | + # Download remote files, if not already cached |
| 83 | + - name: Download remote data (macOS) |
| 84 | + shell: bash -l {0} |
| 85 | + run: gmt which -Gu @earth_relief_01d @earth_relief_30m @earth_relief_10m @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz @usgs_quakes_22.txt |
| 86 | + if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'macOS' |
| 87 | + |
| 88 | + # Install the package that we want to test |
| 89 | + - name: Install the package |
| 90 | + shell: bash -l {0} |
| 91 | + run: | |
| 92 | + python setup.py sdist --formats=zip |
| 93 | + pip install dist/* |
| 94 | +
|
| 95 | + # Run the tests |
| 96 | + - name: Test with pytest |
| 97 | + shell: bash -l {0} |
| 98 | + run: make test PYTEST_EXTRA="-r P" |
0 commit comments