Skip to content

Commit

Permalink
Merge pull request #190 from ericpre/simplify_workflow
Browse files Browse the repository at this point in the history
Simplify GitHub CI workflows by using reusable workflow
  • Loading branch information
ericpre authored Dec 2, 2023
2 parents 68606cf + b2b80bf commit db3ca53
Show file tree
Hide file tree
Showing 66 changed files with 46 additions and 201 deletions.
86 changes: 0 additions & 86 deletions .github/workflows/build.yml

This file was deleted.

118 changes: 14 additions & 104 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,21 @@
name: Docs
name: Documentation

on: [push, pull_request]

jobs:
build_docs:
# This build is to make PR comments for the sphinx warning and check if
# web links are not broken
name: Check links and make PR comments
runs-on: ubuntu-latest
env:
DOCS_PATH: ./docs/_build/html/
steps:
- uses: actions/checkout@v4

- name: Fetch tags upstream
# Needs to fetch the tags from upstream to get the
# correct version with setuptools_scm
run: |
git remote add upstream https://github.com/hyperspy/rosettasciio.git
git fetch --prune --unshallow
git fetch upstream --tags
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.11'

- name: Install RosettaSciIO
shell: bash -l {0}
run: |
pip install .'[all, docs]'
- name: Update packages list
shell: bash -l {0}
run: |
# python generate_supported_format_table.py
echo "Table of Supported Format"
echo "========================="
cat ./docs/user_guide/supported_formats/supported_formats.rst
# Add sphinx warnings as PR comments
- uses: sphinx-doc/sphinx-problem-matcher@master

- name: Build docs
shell: bash -l {0}
run: |
cd docs
make SPHINXOPTS="-W --keep-going" html
- uses: actions/upload-artifact@v3
with:
path: ${{ env.DOCS_PATH }}
name: docs_html

- name: Check links
shell: bash -l {0}
run: |
cd docs
make linkcheck
push_docs:
# This build is to push changes to gh-pages branch (https://hyperspy.org/rosettasciio)
needs: build_docs
name: Push to gh-pages
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' && github.repository == 'hyperspy/rosettasciio' }}
Build:
# Use the "reusable workflow" from the hyperspy organisation
uses: hyperspy/.github/.github/workflows/doc.yml@main
with:
doc_path: ./doc
doc_build_path: ./doc/_build/html/
pip_extra_doc: all,doc

Push:
needs: Build
if: ${{ github.event_name != 'pull_request' && github.repository_owner == 'hyperspy' }}
permissions:
# needs write permission to push the docs to gh-pages
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: gh-pages

- uses: actions/download-artifact@v3
with:
name: docs_html
path: .

- name: list files
run: |
ls
- name: Git status
run: |
git status
git status -s
if [[ $(git status -s) ]]; then
HAS_CHANGES='true'
else
HAS_CHANGES='false'
fi
echo "HAS_CHANGES=${HAS_CHANGES}" >> $GITHUB_ENV
- name: Commit files
# Skip when there is nothing to commit
if: ${{ env.HAS_CHANGES == 'true' }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "Update docs build" -a
- name: Push changes
if: ${{ env.HAS_CHANGES == 'true' }}
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
# Use the "reusable workflow" from the hyperspy organisation
uses: hyperspy/.github/.github/workflows/push_doc.yml@main
11 changes: 11 additions & 0 deletions .github/workflows/package_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Package & Test

on: [push, pull_request]

jobs:
package_and_test:
name: Package and Test
# Use the "reusable workflow" from the hyperspy organisation
uses: hyperspy/.github/.github/workflows/package_and_test.yml@main
with:
module_name: rsciio
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: get repository name
shell: bash
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Fetch tags upstream
if: ${{ github.repository_owner != 'hyperspy' }}
# Needs to fetch the tags from upstream to get the
# correct version with setuptools_scm
run: |
git remote add upstream https://github.com/hyperspy/rosettasciio.git
git fetch --prune --unshallow
git remote add upstream https://github.com/hyperspy/${{ env.REPOSITORY_NAME }}.git
git fetch upstream --tags
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/docs/_build/*
/doc/_build/*
/build/*
/dist/*
/RosettaSciIO.egg-info/*
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build:

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
configuration: doc/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats:
Expand All @@ -28,4 +28,4 @@ python:
path: .
extra_requirements:
- all
- docs
- doc
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ https://rosettasciio.readthedocs.io/en/latest/changes.html

.. towncrier release notes start
.. _changes_0.2:

0.2 (2023-11-09)
================

Expand Down Expand Up @@ -50,6 +52,7 @@ Maintenance
- Update the test suite and the CI workflows to work with and without exspy installed (`#176 <https://github.com/hyperspy/rosettasciio/issues/176>`_)
- Add badges that became available after first release (`#177 <https://github.com/hyperspy/rosettasciio/issues/177>`_)

.. _changes_0.1:

0.1 (2023-06-06)
================
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ information.

**Documentation** should be added both as **docstring**, as well as to the **user guide**,
for which a corresponding ``spamandeggs.rst`` file should be created in the directory
``docs/supported_formats/`` and the format added to the lists in
``docs/supported_formats/index.rst`` and ``docs/supported_formats/supported_formats.rst``.
``doc/user_guide/supported_formats/`` and the format added to the lists in
``doc/user_guide/supported_formats/index.rst`` and ``doc/user_guide/supported_formats/supported_formats.rst``.

A few standard *docstring* components are provided by ``rsciio._docstrings.py`` and should
be used (see existing plugins).
Expand All @@ -159,7 +159,7 @@ The *docstrings* are automatically added in the *user guide* using the following
The *docstrings* follow `Numpy docstring style <https://numpydoc.readthedocs.io>`_. The
links to RosettaSciIO API and other Sphinx documented API are checked when building the documentation
and broken links will raise warnings. In order to identify potentially broken links during pull
request review, the `Docs <https://github.com/hyperspy/rosettasciio/actions/workflows/docs.yml>`_
request review, the `Documentation <https://github.com/hyperspy/rosettasciio/actions/workflows/Documentation.yml>`_
GitHub CI workflow is set to fail when the doc build raises warnings.

.. Note ::
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/user_guide/install.rst → doc/user_guide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The list of *extras*:
And for development, the following *extras* are available (see ``pyproject.toml`` for more information):

- tests
- docs
- doc
- dev

.. _install-with-conda:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ tests = [
"pytest-cov",
"setuptools_scm",
]
docs = [
doc = [
"numpydoc",
"pooch",
"pydata-sphinx-theme>=0.13",
Expand All @@ -86,7 +86,7 @@ all = [
]
dev = [
"black",
"rosettasciio[docs]",
"rosettasciio[doc]",
"rosettasciio[all]",
"rosettasciio[tests]"
]
Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/190.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simplify GitHub CI workflows by using reusable workflow

0 comments on commit db3ca53

Please sign in to comment.