Skip to content

Commit 158ef09

Browse files
weiji14seisman
andauthored
Run Continuous Integration tests on Github Actions (#475)
* Install pytest and other dev dependencies * Don't fail-fast and cancel all jobs * Cache GMT tutorial files in ${{ github.workspace }}/.gmt on 20200605 * Add a cron job for daily tests * Let conda install packages listed in requirements.txt * Single conda command to install all packages * Set fetch-depth to 0 * Disable Azure Pipeline CI on Windows and macOS, but keep Style Checks on * Add the status badge to README * Test Python 3.6-3.8 * Let the github actions run in all PRs * Use PYTEST_EXTRA in Makefile Co-authored-by: Dongdong Tian <[email protected]>
1 parent bedb48d commit 158ef09

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

.azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
########################################################################################
7070
- job:
7171
displayName: 'Mac'
72+
condition: False
7273

7374
pool:
7475
vmImage: 'macOS-10.14'
@@ -171,6 +172,7 @@ jobs:
171172
########################################################################################
172173
- job:
173174
displayName: 'Windows'
175+
condition: False
174176

175177
pool:
176178
vmImage: 'vs2017-win2016'

.github/workflows/ci_tests.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
uses: actions/[email protected]
28+
with:
29+
# fecth all history so that versioneer works
30+
fetch-depth: 0
31+
32+
# Setup Miniconda
33+
- name: Setup Miniconda
34+
uses: goanpeca/[email protected]
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"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Build, package, test, and clean
22
PROJECT=pygmt
33
TESTDIR=tmp-test-dir-with-unique-name
4-
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --mpl --mpl-results-path=results --pyargs
4+
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --mpl --mpl-results-path=results --pyargs ${PYTEST_EXTRA}
55
BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples
66
FLAKE8_FILES=$(PROJECT) setup.py
77
LINT_FILES=$(PROJECT) setup.py

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ PyGMT
1515
.. image:: https://img.shields.io/azure-devops/build/GenericMappingTools/7682ad4e-76bb-4775-849e-7c4f8dce4e1a/3/master.svg?label=Mac|Windows&style=flat-square
1616
:alt: Azure Pipelines build status
1717
:target: https://dev.azure.com/GenericMappingTools/PyGMT/_build
18+
.. image:: https://github.com/GenericMappingTools/pygmt/workflows/Tests/badge.svg
19+
:alt: GitHub Actions build status
20+
:target: https://github.com/GenericMappingTools/pygmt/actions
1821
.. image:: https://img.shields.io/codecov/c/github/GenericMappingTools/pygmt/master.svg?style=flat-square
1922
:alt: Test coverage status
2023
:target: https://codecov.io/gh/GenericMappingTools/pygmt

0 commit comments

Comments
 (0)