Skip to content

Commit

Permalink
Merge pull request #686 from grahamgower/ci
Browse files Browse the repository at this point in the history
transition to github actions
  • Loading branch information
grahamgower committed Nov 10, 2020
2 parents 78bef56 + 8a52782 commit addf08b
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 63 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
tests:
runs-on: ${{ matrix.os }}
defaults:
run:
# Use a login shell, so that ~/.bash_profile is executed and
# the conda environment gets initialised.
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, windows-2019, macos-10.15]
python: [3.6, 3.9]
env:
SLIM_TAG: 3.4
CONDA_ENV_NAME: stdpopsim

steps:
- name: cancel previous runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}

- name: checkout
uses: actions/checkout@v2

- name: find conda
id: find-conda
run: |
echo "::set-output name=CONDA::$CONDA"
- name: fix conda permissions
if: runner.os == 'macOS'
run: |
# Fix incorrect conda permissions on mac that prevent cache restore.
sudo chown -R $USER:staff $CONDA
- name: cache conda
id: cache
uses: actions/cache@v2
env:
# Increase this to reset the cache if the key hasn't changed.
CACHE_NUM: 0
with:
path: |
${{ steps.find-conda.outputs.CONDA }}/envs/${{ env.CONDA_ENV_NAME }}
~/.bash_profile
key: ${{ runner.os }}-${{ matrix.python }}-conda-${{ hashFiles('requirements/CI/*') }}-${{ env.SLIM_TAG }}-${{ env.CACHE_NUM }}

- name: install conda
uses: conda-incubator/setup-miniconda@v2
if: steps.cache.outputs.cache-hit != 'true'
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
python-version: ${{ matrix.python }}
channels: conda-forge
channel-priority: strict
auto-update-conda: true
use-only-tar-bz2: true

- name: move profile
if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
run: |
# The setup-miniconda action leaves different shell init files for
# different OSes. Bash gives priority to ~/.bash_profile, so here we
# ensure that's used for all platforms.
mv ~/.profile ~/.bash_profile
- name: install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
conda install --yes --file=requirements/CI/conda.txt
if [ "$RUNNER_OS" != "Windows" ]; then
conda install --yes slim==${{ env.SLIM_TAG }}
fi
pip install -r requirements/CI/requirements.txt
- name: run test suite
run: |
nosetests -v --with-coverage --cover-package stdpopsim tests
coverage report -m
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

25 changes: 0 additions & 25 deletions appveyor.yml

This file was deleted.

2 changes: 2 additions & 0 deletions requirements/CI/conda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
msprime==0.7.4
numcodecs==0.7.2
6 changes: 4 additions & 2 deletions tests/test_slim_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ def test_script_generation(self):

def test_simulate(self):
saved_slim_env = os.environ.get("SLIM")
slim_path = os.environ.get("SLIM", "slim")
with tempfile.NamedTemporaryFile(mode="w") as f:
self.docmd(f"--slim-path slim HomSap -o {f.name}")
self.docmd(f"--slim-path {slim_path} HomSap -o {f.name}")
ts = tskit.load(f.name)
self.assertEqual(ts.num_samples, 10)
self.assertTrue(all(tree.num_roots == 1 for tree in ts.trees()))
Expand Down Expand Up @@ -267,7 +268,8 @@ def test_dry_run(self, _mocked_get_version):
with tempfile.NamedTemporaryFile(mode="w") as f:
self.docmd(f"HomSap --dry-run -o {f.name}")
mocked_popen.assert_called_once()
self.assertTrue("slim" in mocked_popen.call_args[0][0])
slim_path = os.environ.get("SLIM", "slim")
self.assertTrue(slim_path in mocked_popen.call_args[0][0])
with tempfile.NamedTemporaryFile(mode="w") as f:
self.docmd(f"HomSap --dry-run -o {f.name}")
self.assertEqual(os.stat(f.name).st_size, 0)
Expand Down

0 comments on commit addf08b

Please sign in to comment.