-
Notifications
You must be signed in to change notification settings - Fork 228
Run Continuous Integration tests on Github Actions #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4c0fd39
31340ee
9a4e7bc
51472dc
9c2e393
2220702
6936b3c
6906426
d2ce09b
e407081
841f937
9fd73f0
1a23b55
0ba3d7e
c744db9
3a06afc
05c225f
8bd8a66
d4408c0
c12cfff
9179bc2
8662be0
a806efa
895e871
e0c79e6
4d271c0
0c1ba71
80c6508
bf2126f
9c97722
37f2a53
8ff30d9
1b947d3
cd7d7da
098e03d
b4c7492
b6445d0
b731f0c
5b65455
36fa209
a5af2dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
weiji14 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Schedule daily tests | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
test: | ||
name: ${{ matrix.os }} - Python ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8] | ||
os: [ubuntu-latest, macOS-latest, windows-latest] | ||
|
||
steps: | ||
# Checkout current git repository | ||
- name: Checkout | ||
uses: actions/checkout@v2.3.1 | ||
with: | ||
# fecth all history so that versioneer works | ||
fetch-depth: 0 | ||
|
||
# Setup Miniconda | ||
- name: Setup Miniconda | ||
uses: goanpeca/setup-miniconda@v1.6.0 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
channels: conda-forge | ||
|
||
# Install GMT and other required dependencies from conda-forge | ||
- name: Install GMT and required dependencies | ||
shell: bash -l {0} | ||
run: | | ||
requirements_file=full-conda-requirements.txt | ||
cat requirements.txt requirements-dev.txt > $requirements_file | ||
cat << EOF >> $requirements_file | ||
gmt=6.0.0 | ||
make | ||
EOF | ||
conda install --yes --file $requirements_file | ||
Comment on lines
+32
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can speed up the dependency install using caching too, see https://github.com/goanpeca/setup-miniconda#caching. I've used it for one of my projects, the relevant commit is at weiji14/deepicedrain@391632b. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I saw that. But I'm not sure how the caches are updated. For example, we may cache numpy v1.18.0 now. When new numpy versions are released, conda will download and install the latest version (e.g., numpy v1.19.0). What will happen to the caches? Do the caches contains the tarballs of numpy v1.18.0, v1.19.0 or both? Do we have to manually update the cache key? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cache would hash the |
||
|
||
# Show installed pkg information for postmortem diagnostic | ||
- name: List installed packages | ||
shell: bash -l {0} | ||
run: conda list | ||
|
||
# Cache the ${HOME}/.gmt directory, for docs and testing | ||
- name: Cache GMT directory | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: | | ||
~/.gmt/cache | ||
~/.gmt/server | ||
key: cache-gmt-${{ github.ref }}-${{ runner.os }}-20200609 | ||
restore-keys: cache-gmt-refs/heads/master- | ||
|
||
# Workaround for the timeouts of 'gmt which' on Linux and Windows | ||
- name: Download remote data using wget (Linux & Windows) | ||
shell: bash -l {0} | ||
run: | | ||
if [ "$RUNNER_OS" == "Windows" ]; then choco install wget; fi # install wget on Windows | ||
mkdir ~/.gmt ~/.gmt/cache ~/.gmt/server | ||
wget --no-check-certificate https://oceania.generic-mapping-tools.org/gmt_hash_server.txt -P ~/.gmt/server/ | ||
for data in earth_relief_01d.grd earth_relief_30m.grd earth_relief_10m.grd; do | ||
wget --no-check-certificate https://oceania.generic-mapping-tools.org/${data} -P ~/.gmt/server/ | ||
done | ||
Comment on lines
+70
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to change these lines when bumping to 6.1. In 6.1, the earth relief data are stored in |
||
for data in ridge.txt Table_5_11.txt tut_bathy.nc tut_quakes.ngdc tut_ship.xyz usgs_quakes_22.txt; do | ||
wget --no-check-certificate https://oceania.generic-mapping-tools.org/cache/${data} -P ~/.gmt/cache/ | ||
done | ||
if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'macOS' | ||
|
||
# Download remote files, if not already cached | ||
- name: Download remote data (macOS) | ||
shell: bash -l {0} | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to change |
||
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'macOS' | ||
|
||
# Install the package that we want to test | ||
- name: Install the package | ||
shell: bash -l {0} | ||
run: | | ||
python setup.py sdist --formats=zip | ||
pip install dist/* | ||
|
||
# Run the tests | ||
- name: Test with pytest | ||
shell: bash -l {0} | ||
run: make test PYTEST_EXTRA="-r P" | ||
seisman marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Build, package, test, and clean | ||
PROJECT=pygmt | ||
TESTDIR=tmp-test-dir-with-unique-name | ||
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --mpl --mpl-results-path=results --pyargs | ||
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --mpl --mpl-results-path=results --pyargs ${PYTEST_EXTRA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't work, because we didn't declare the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it works. It doesn't have to be an environmental variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now although the tests all pass, we actually can see more "errors" by using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it because the CI (Travis and GH Actions) still uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Look at the captured stderr above:
This is a GMT error message, but I believe it's already corrected captured in the pygmt test. I believe the initial idea of PYTEST_EXTRA is that, when we or other users run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then we don't actually need to change the Makefile. You'll see that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
and
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I think I get it now. It wasn't working properly before, but now it does. |
||
BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples | ||
FLAKE8_FILES=$(PROJECT) setup.py | ||
LINT_FILES=$(PROJECT) setup.py | ||
|
Uh oh!
There was an error while loading. Please reload this page.