Skip to content

Commit

Permalink
Merge pull request #385 from hakonanes/prepare-release-v0.10
Browse files Browse the repository at this point in the history
Merge develop into main for release v0.10.0
  • Loading branch information
hakonanes authored Sep 22, 2022
2 parents 14639a1 + e8cc412 commit f33153f
Show file tree
Hide file tree
Showing 144 changed files with 9,771 additions and 5,758 deletions.
41 changes: 35 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,31 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
- uses: actions/setup-python@v2
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]

- name: Check code style of Jupyter notebooks
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/setup-python@v2

- name: Install dependencies
run: pip install manifix

- name: Check MANIFEST.in file
run: python setup.py manifix

Expand All @@ -32,34 +47,48 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.9, '3.10']
python-version: [3.9, "3.10"]
include:
- os: ubuntu-latest
python-version: 3.6
python-version: 3.7
OLDEST_SUPPORTED_VERSION: true
DEPENDENCIES: diffpy.structure==3 matplotlib==3.3
LABEL: -oldest
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
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]'

- name: Install oldest supported version
if: ${{ matrix.OLDEST_SUPPORTED_VERSION }}
run: pip install ${{ matrix.DEPENDENCIES }}

- name: Display package versions
run: pip list

- name: Run docstring tests
if: ${{ matrix.os == 'ubuntu-latest' }}
continue-on-error: true
run: |
pytest --doctest-modules --ignore-glob=orix/tests orix/*.py
- name: Run tests
run: pytest --cov=orix --pyargs orix

- name: Generate line coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
run: coverage report --show-missing

- name: Upload coverage to Coveralls
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: AndreMiras/coveralls-python-action@develop
Expand All @@ -70,7 +99,7 @@ jobs:
needs: build-with-pip
runs-on: ubuntu-latest
steps:
- name: Coveralls finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
- name: Coveralls finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
55 changes: 55 additions & 0 deletions .github/workflows/perhaps_make_a_tagged_release_draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Perhaps make a tagged release

# Trigger workflow when commits to the main branch contain a change in the
# orix/__init__.py file. This is because this workflow should only run when a
# tagged release draft is to be made.

on:
push:
branches:
- main
paths:
- "orix/__init__.py"

jobs:
make-tagged-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-pandoc@v1

- name: Set up Python ${{ runner.python-version }}
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install outdated
- name: Check whether a tagged release draft should be made
run: |
cd .github/workflows
eval x=($(python perhaps_make_tagged_release_draft.py))
echo "MAKE_RELEASE=${x[0]}" >> $GITHUB_ENV
echo "PYPI_VERSION=${x[1]}" >> $GITHUB_ENV
echo "BRANCH_VERSION=${x[2]}" >> $GITHUB_ENV
- name: Make tagged release draft body from changelog
if: ${{ env.MAKE_RELEASE == 'true' }}
run: pandoc .github/workflows/release_part_in_changelog.rst -f rst -t markdown -o release_part_in_changelog.md --wrap=none

- name: Make tagged release draft
if: ${{ env.MAKE_RELEASE == 'true' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: v${{ env.BRANCH_VERSION }}
release_name: orix ${{ env.BRANCH_VERSION }}
commitish: main
body_path: release_part_in_changelog.md
prerelease: false
85 changes: 85 additions & 0 deletions .github/workflows/perhaps_make_tagged_release_draft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright 2019-2022 The orix developers
#
# This file is part of orix.
#
# kikuchipy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# kikuchipy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with orix. If not, see <http://www.gnu.org/licenses/>.

import re

from outdated import check_outdated
from packaging.version import Version

with open("../../orix/__init__.py") as fid:
for line in fid:
if line.startswith("__version__"):
branch_version_str = line.strip().split(" = ")[-1][1:-1]
break

# Within a try/except because we don't want to throw the error if a new
# tagged release draft is to be made, we just want to know if the branch
# version is different (hopefully always newer if different) from the
# PyPI version
try:
make_release, pypi_version_str = check_outdated("orix", branch_version_str)
except ValueError as err:
pattern = re.compile(r"([\d.]+)") # Any "word" with decimal digits and dots
matches = []
for line in err.args[0].split(" "):
if pattern.match(line) is not None:
matches.append(line)
pypi_version_str = matches[-1]
make_release = True

# Don't make a release if the version is a development version
branch_version = Version(branch_version_str)
pypi_version = Version(pypi_version_str)
if branch_version.is_devrelease:
make_release = False

if make_release:
# Determine which type of release this is (major, minor, patch?)
if branch_version.major > pypi_version.major:
release_type = "major"
elif branch_version.minor > pypi_version.minor:
release_type = "minor"
else:
release_type = "patch"

# Write the relevant part of the changelog to a new file to be used
# by the publish workflow
with open("../../CHANGELOG.rst", mode="r") as f:
content = f.readlines()
changelog_start = 0
changelog_end = 0
for i, line in enumerate(content):
if branch_version.base_version in line:
changelog_start = i + 3
elif pypi_version.base_version in line:
changelog_end = i - 1
break
if changelog_start == 0:
changelog_end = 0
with open("release_part_in_changelog.rst", mode="w") as f:
f.write(
f"orix {branch_version_str} is a {release_type} release of orix, an open-source Python library for handling orientations, rotations and crystal symmetry.\n\n"
f"See below, the `changelog <https://orix.readthedocs.io/en/stable/changelog.html>`_ or the `GitHub changelog <https://github.com/pyxem/orix/compare/v{pypi_version_str}...v{branch_version_str}>`_ for all updates from the previous release.\n\n"
)
for line in content[changelog_start:changelog_end]:
f.write(line)

# These three prints are collected by a bash script using `eval` and
# passed to the publish workflow environment variables
print(make_release)
print(pypi_version_str)
print(branch_version_str)
5 changes: 5 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
python -m build
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_documentation_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ jobs:
MPLBACKEND: agg
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'

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

- name: Install dependencies and package
shell: bash
run: |
pip install -U -e .'[tests, doc]'
pip install nbval
- name: Test documentation notebooks
run: |
pytest -v --nbval doc
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ instance/

# Sphinx documentation
doc/_build/
doc/build/
doc/examples/
doc/reference/generated/
doc/source/_autosummary/

# PyBuilder
Expand Down
16 changes: 14 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
repos:
- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args:
[
"--profile",
"black",
"--filter-files",
"--force-sort-within-sections",
]
13 changes: 9 additions & 4 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
{
"name": "Ben Martineau"
},
{
"name": "Phillip Crout",
"orcid": "0000-0001-5754-0938"
},
{
"name": "Paddy Harrison",
"orcid": "0000-0001-9798-8710",
"affiliation": "SIMaP, Grenoble INP"
},
{
"name": "Phillip Crout",
"orcid": "0000-0001-5754-0938"
},
{
"name": "Duncan Johnstone",
"orcid": "0000-0003-3663-3793"
Expand All @@ -25,6 +25,11 @@
"name": "Niels Cautaerts",
"orcid": "0000-0002-6402-9879"
},
{
"name": "Austin Gerlt",
"orcid": "0000-0002-2204-2055",
"affiliation": "The Ohio State University"
},
{
"name": "Simon Høgås"
}
Expand Down
Loading

0 comments on commit f33153f

Please sign in to comment.