Skip to content

Commit

Permalink
Run tests in parallel on GitHub Actions
Browse files Browse the repository at this point in the history
Signed-off-by: Håkon Wiik Ånes <[email protected]>
  • Loading branch information
hakonanes committed Jan 30, 2023
1 parent 286a68a commit 7faaacc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
64 changes: 42 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,64 @@
name: build

on: [push, pull_request]
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
workflow_dispatch:
workflow: '*'

env:
MPLBACKEND: agg

jobs:
code:
name: code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: psf/black@stable
- uses: actions/setup-python@v2

- uses: actions/setup-python@v4
with:
python-version: 3.9

- uses: isort/isort-action@master
with:
configuration: --profile black --filter-files --force-sort-within-sections --check-only --diff

- name: Install Black with Jupyter extension
run: pip install black[jupyter]
run: |
pip install black[jupyter]
- name: Check code style of Jupyter notebooks
run: black doc/**/*.ipynb --check
run: |
black doc/**/*.ipynb --check
# Make sure all necessary files will be included in a release
manifest:
name: check manifest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4

- name: Install dependencies
run: pip install manifix
run: |
pip install manifix
- name: Check MANIFEST.in file
run: python setup.py manifix
run: |
python setup.py manifix
build-with-pip:
name: ${{ matrix.os }}-py${{ matrix.python-version }}${{ matrix.LABEL }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
env:
MPLBACKEND: agg
strategy:
fail-fast: false
matrix:
Expand All @@ -55,26 +71,28 @@ jobs:
DEPENDENCIES: diffpy.structure==3 matplotlib==3.3
LABEL: -oldest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Display Python and pip versions
run: python -V; pip -V

- name: Install depedencies and package
shell: bash
run: pip install -U -e .'[doc, tests]'
run: |
pip install -U -e .'[doc, tests]'
- name: Install oldest supported version
if: ${{ matrix.OLDEST_SUPPORTED_VERSION }}
run: pip install ${{ matrix.DEPENDENCIES }}
run: |
pip install ${{ matrix.DEPENDENCIES }}
- name: Display package versions
run: pip list
- name: Display Python, pip and package versions
run: |
python -V
pip -V
pip list
- name: Run docstring tests
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand All @@ -83,11 +101,13 @@ jobs:
pytest --doctest-modules --ignore-glob=orix/tests orix/*.py
- name: Run tests
run: pytest --cov=orix --pyargs orix
run: |
pytest -n 2 --cov=orix --pyargs orix
- name: Generate line coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
run: coverage report --show-missing
run: |
coverage report --show-missing
- name: Upload coverage to Coveralls
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down
5 changes: 5 additions & 0 deletions orix/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def rotations():
return Rotation([(2, 4, 6, 8), (-1, -3, -5, -7)])


@pytest.fixture()
def eu():
return np.random.rand(10, 3)


ANGFILE_TSL_HEADER = (
"# TEM_PIXperUM 1.000000\n"
"# x-star 0.413900\n"
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"numpydoc",
"pytest >= 5.4",
"pytest-cov >= 2.8.1",
"pytest-xdist",
],
}
extra_feature_requirements["dev"] = [
Expand Down

0 comments on commit 7faaacc

Please sign in to comment.