Skip to content

Commit

Permalink
Merge pull request #1 from ericpre/add_github_actions
Browse files Browse the repository at this point in the history
Add GitHub actions and templates
  • Loading branch information
ericpre committed Oct 28, 2023
2 parents 4db9651 + 6acf5a1 commit 7c056f3
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'type: bug'

---

#### Describe the bug
A clear and concise description of what the bug is.

#### To Reproduce
Steps to reproduce the behavior:
```
Minimum working example of code
```

#### Expected behavior
A clear and concise description of what you expected to happen.

#### Python environement:
- exSpy version: 0.x.x
- HyperSpy version: 1.x.x
- Python version: 3.x

#### Additional context
Add any other context about the problem here. If necessary, add screenshots to help explain your problem.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
---


17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'type: feature request'
assignees: ''

---

#### Describe the functionality you would like to see.
A clear and concise description of what you would like to do.

#### Describe the context
Do you want to extend existing functionalities, what types of signals should it apply to, etc.

#### Additional information
Add any other context or screenshots about the feature request here.
30 changes: 30 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Requirements
* Read the [contributing guidelines](https://github.com/hyperspy/exspy/blob/main/CONTRIBUTING.rst).
* Fill out the template; it helps the review process and it is useful to summarise the PR.
* This template can be updated during the progression of the PR to summarise its status.

*You can delete this section after you read it.*

### Description of the change
A few sentences and/or a bulleted list to describe and motivate the change:
- Change A.
- Change B.
- etc.

### Progress of the PR
- [ ] Change implemented (can be split into several points),
- [ ] docstring updated (if appropriate),
- [ ] update user guide (if appropriate),
- [ ] added tests,
- [ ] added line to CHANGES.rst,
- [ ] ready for review.

### Minimal example of the bug fix or the new feature
```python
import exspy
import numpy as np
s = exspy.signals.EELSSpectrum(np.arange(100).reshape(10,10))
# Your new feature...
```


11 changes: 11 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: psf/black@stable
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build

on: [push, pull_request]

jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
PYTHON_VERSION: '3.11'
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Display version
run: |
python --version
pip --version
- name: Install pypa/build
run: |
pip install build
- name: Build a binary wheel and a source tarball
run: |
python -m build
- name: Display content dist folder
run: |
ls -l dist/
- uses: actions/upload-artifact@v3
with:
path: ./dist/*
name: dist

test:
name: Test Packaging
needs: build
runs-on: ubuntu-latest
env:
PYTHON_VERSION: '3.11'
steps:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: ${{ env.PYTHON_VERSION }}

- uses: actions/download-artifact@v3

- name: Display content working folder
run: |
ls -R
- name: Install distribution
run: |
pip install --pre --find-links dist exspy[tests]
- name: Test distribution
run: |
pytest --pyargs exspy
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release

# This workflow builds the wheels "on tag".
# If run from the hyperspy/hyperspy repository, the wheels will be uploaded to pypi ;
# otherwise, the wheels will be available as a github artifact.
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
build_wheels:
name: Build wheels
runs-on: ubuntu-latest
env:
CIBW_TEST_COMMAND: "pytest --pyargs exspy"
CIBW_TEST_EXTRAS: "tests"

steps:
- uses: actions/checkout@v3

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
if-no-files-found: error

make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

upload_to_pypi:
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- name: Download wheels
uses: actions/download-artifact@v3
with:
name: wheels
path: dist

- name: Display structure of downloaded files
run: ls -R
working-directory: dist

- uses: pypa/gh-action-pypi-publish@release/v1
if: github.repository_owner == 'hyperspy'
# See https://docs.pypi.org/trusted-publishers/using-a-publisher/

create_release:
# TODO: once we are happy with the workflow
# setup zenodo to create a DOI automatically
needs: upload_to_pypi
permissions:
contents: write
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create Release
id: create_release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Tests

on: [push, pull_request]

jobs:
run_test_site:
name: ${{ matrix.os }}-py${{ matrix.PYTHON_VERSION }}${{ matrix.LABEL }}
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 30
env:
MPLBACKEND: agg
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
PYTHON_VERSION: ['3.9', '3.10']
LABEL: ['']
include:
- os: ubuntu
PYTHON_VERSION: '3.8'
- os: ubuntu
PYTHON_VERSION: '3.11'

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: ${{ matrix.PYTHON_VERSION }}

- name: Display version
run: |
python --version
pip --version
- name: Install
shell: bash
run: |
pip install -e .[tests]
- name: Pip list
run: |
pip list
- name: Run test suite
run: |
pytest --pyargs exspy
- name: Upload coverage to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v3
24 changes: 20 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
# https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies

extra_feature_requirements = {
"gui-jupyter": [
"hyperspy_gui_ipywidgets @ git+https://github.com/ericpre/[email protected]",
],
"gui-traitsui": [
"hyperspy_gui_traitsui @ git+https://github.com/ericpre/[email protected]",
],
"doc": [
"numpydoc",
"pydata-sphinx-theme>=0.13",
Expand All @@ -36,6 +42,7 @@
],
"tests": [
"pytest >= 5.0",
"pytest-mpl",
"pytest-cov >= 2.8.1",
],
"dev": ["black", "pre-commit >=1.16"],
Expand All @@ -58,10 +65,10 @@
],
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
Expand All @@ -76,10 +83,19 @@
package_dir={"exspy": "exspy"},
extras_require=extra_feature_requirements,
install_requires=[
"hyperspy_gui_ipywidgets @ git+https://github.com/ericpre/[email protected]",
"hyperspy_gui_traitsui @ git+https://github.com/ericpre/[email protected]",
"dask[array]",
"hyperspy @ git+https://github.com/hyperspy/hyperspy@RELEASE_next_major",
"matplotlib",
"numexpr",
"numpy",
"pint",
"pooch",
"prettytable",
"requests",
"scipy",
"traits",
],
python_requires=">=3.7",
python_requires="~=3.8",
package_data={
"": ["LICENSE", "README.rst"],
"exspy": [
Expand Down

0 comments on commit 7c056f3

Please sign in to comment.