Skip to content

Commit d51f565

Browse files
Merge pull request #61 from easyscience/develop
New release
2 parents 3d1cd03 + e1c6afe commit d51f565

File tree

239 files changed

+129324
-3158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+129324
-3158
lines changed

.github/release-drafter.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This file is used to configure the Release Drafter GitHub Action
2+
# https://github.com/marketplace/actions/release-drafter
3+
4+
name-template: 'easydiffraction $RESOLVED_VERSION'
5+
tag-template: 'v$RESOLVED_VERSION'
6+
categories:
7+
- title: 'Added'
8+
labels: # Labels to use to categorize a pull request as a feature
9+
- '[scope] significant'
10+
- '[scope] enhancement'
11+
- '[scope] documentation'
12+
- title: 'Fixed'
13+
labels: # Labels to use to categorize a pull request as a bug fix
14+
- '[scope] bug'
15+
- title: 'Changed'
16+
labels: # Labels to use to categorize a pull request as a maintenance task
17+
- '[scope] maintenance'
18+
change-template: '- $TITLE (#$NUMBER)'
19+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
20+
version-resolver:
21+
major:
22+
labels:
23+
- '[scope] significant'
24+
minor:
25+
labels:
26+
- '[scope] enhancement'
27+
patch:
28+
labels:
29+
- '[scope] bug'
30+
- '[scope] maintenance'
31+
- '[scope] documentation'
32+
default: patch
33+
template: |
34+
$CHANGES

.github/workflows/build-docs.yml

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
name: Build and deploy docs
2+
3+
on:
4+
# Trigger the workflow on push
5+
push:
6+
# Selected branches
7+
branches: [develop, master, docs]
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Allow only one concurrent workflow, skipping runs queued between the run
12+
# in-progress and latest queued. And cancel in-progress runs.
13+
concurrency:
14+
group:
15+
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
env:
19+
# Set the environment variables to be used in all jobs defined in this workflow
20+
# Set the CI_BRANCH environment variable to be the branch name
21+
# Set the NOTEBOOKS_DIR environment variable to be the directory containing the Jupyter notebooks
22+
CI_BRANCH: ${{ github.head_ref || github.ref_name }}
23+
NOTEBOOKS_DIR: tutorials
24+
25+
jobs:
26+
# Job 1: Build the static files for the documentation site
27+
build-docs:
28+
strategy:
29+
matrix:
30+
os: [macos-14] # Use macOS to switch to dark mode for Plotly charts
31+
python-version: ['3.13']
32+
33+
runs-on: ${{ matrix.os }}
34+
35+
steps:
36+
# Without this step, GITHUB_REPOSITORY is not accessible from mkdocs.yml
37+
- name: Get GitHub repository
38+
run: echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" >> $GITHUB_ENV
39+
40+
# Save the latest release version of easyscience/diffraction-lib to RELEASE_VERSION
41+
# RELEASE_VERSION is used in the mkdocs.yml file to set release_version.
42+
# The release_version is then needed to display the latest release version in the index.md file
43+
- name: Get the latest release version of easydiffraction library
44+
run: |
45+
git clone --depth 1 https://github.com/easyscience/${{ github.event.repository.name }} .
46+
git fetch --tags
47+
echo "RELEASE_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
48+
49+
# Activate dark mode to create documentation with Plotly charts in dark mode
50+
# Need a better solution to automatically switch the chart colour theme based on the mkdocs material switcher
51+
# Something similar to mkdocs_plotly_plugin https://haoda-li.github.io/mkdocs-plotly-plugin/,
52+
# but for generating documentation from notepads
53+
#- name: Activate dark mode
54+
# run: |
55+
# brew install dark-mode
56+
# dark-mode status
57+
# dark-mode on
58+
# dark-mode status
59+
60+
- name: Check-out repository
61+
uses: actions/checkout@v4
62+
63+
- name: Set up Python ${{ matrix.python-version }}
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: ${{ matrix.python-version }}
67+
68+
- name: Upgrade package installer for Python
69+
shell: bash
70+
run: python -m pip install --upgrade pip
71+
72+
# Install EasyDiffraction Library to run Jupyter notebooks
73+
# Install with the 'docs' and 'visualization' extras
74+
- name: Install EasyDiffraction Library and its dependencies
75+
run: python -m pip install .'[dev,docs,visualization]'
76+
77+
# Clone assets extra from:
78+
# - easyscience/assets-docs
79+
# - easyscience/assets-branding
80+
- name: Clone easyscience/assets-docs and easyscience/assets-branding
81+
run: |
82+
cd ..
83+
git clone https://github.com/easyscience/assets-docs.git
84+
git clone https://github.com/easyscience/assets-branding.git
85+
86+
# Add the extra files from the easyscience/assets-docs repository
87+
- name: Add files from easyscience/assets-docs files
88+
run: |
89+
cp -R ../assets-docs/docs/assets/ docs/assets/
90+
cp -R ../assets-docs/includes/ includes/
91+
cp -R ../assets-docs/overrides/ overrides/
92+
93+
# Add the extra files from the easyscience/assets-branding repository
94+
- name: Add files from easyscience/assets-branding files
95+
run: |
96+
mkdir -p docs/assets/images/
97+
cp ../assets-branding/easydiffraction/hero/dark.png docs/assets/images/hero_dark.png
98+
cp ../assets-branding/easydiffraction/hero/light.png docs/assets/images/hero_light.png
99+
cp ../assets-branding/easydiffraction/logos/dark.svg docs/assets/images/logo_dark.svg
100+
cp ../assets-branding/easydiffraction/logos/light.svg docs/assets/images/logo_light.svg
101+
cp ../assets-branding/easydiffraction/icons/color.png docs/assets/images/favicon.png
102+
mkdir -p overrides/.icons/
103+
cp ../assets-branding/easydiffraction/icons/bw.svg overrides/.icons/easydiffraction.svg
104+
cp ../assets-branding/easyscience-org/icons/eso-icon_bw.svg overrides/.icons/easyscience.svg
105+
106+
# Convert python scripts in the notebooks directory to Jupyter notebooks
107+
# Strip output from the notebooks and simpify cell ids
108+
# The notebooks are used to generate the documentation
109+
- name:
110+
Convert ${{ env.NOTEBOOKS_DIR }}/*.py to docs/${{env.NOTEBOOKS_DIR
111+
}}/*.ipynb
112+
run: |
113+
cp -R ${{ env.NOTEBOOKS_DIR }}/data docs/${{ env.NOTEBOOKS_DIR }}/
114+
jupytext ${{ env.NOTEBOOKS_DIR }}/*.py --from py:percent --to ipynb
115+
nbstripout ${{ env.NOTEBOOKS_DIR }}/*.ipynb
116+
mv ${{ env.NOTEBOOKS_DIR }}/*.ipynb docs/${{ env.NOTEBOOKS_DIR }}/
117+
118+
# The following step is needed to avoid the following message during the build:
119+
# "Matplotlib is building the font cache; this may take a moment"
120+
- name: Pre-build site step
121+
run: |
122+
export PYTHONPATH="$(pwd)/src${PYTHONPATH:+:$PYTHONPATH}"
123+
python -c "import easydiffraction"
124+
125+
# Create the mkdocs.yml configuration file
126+
# The file is created by merging two files:
127+
# - assets-docs/mkdocs.yml - the common configuration (theme, plugins, etc.)
128+
# - docs/mkdocs.yml - the project-specific configuration (project name, TOC, etc.)
129+
- name: Create mkdocs.yml file
130+
run: python tools/create_mkdocs-yml.py
131+
132+
# Build the static files
133+
# Input: docs/ directory containing the Markdown files
134+
# Output: site/ directory containing the generated HTML files
135+
- name: Build site with MkDocs
136+
run: |
137+
export JUPYTER_PLATFORM_DIRS=1
138+
export PYTHONWARNINGS="ignore::RuntimeWarning"
139+
export PYTHONPATH="$(pwd)/src${PYTHONPATH:+:$PYTHONPATH}"
140+
mkdocs build
141+
142+
# Set up the Pages action to configure the static files to be deployed
143+
# NOTE: The repository must have GitHub Pages enabled and configured to build using GitHub Actions
144+
# This can be done via https://github.com/easyscience/diffraction-lib/settings/pages
145+
# Select: Build and deploy - Source - GitHub Actions
146+
- name: Setup GitHub Pages
147+
uses: actions/configure-pages@v5
148+
149+
# Upload the static files from the site/ directory to be used in the next job
150+
# This artifact is named github-pages and is a single gzip archive containing a single tar file
151+
# The artifact is then used in the next job by actions/deploy-pages to deploy the static files to GitHub Pages
152+
# Unfortunately, the artifact is not available for download, so extra steps below are needed to do similar things
153+
- name:
154+
Upload built site as artifact for easyscience.github.io/${{
155+
github.event.repository.name }} (all branches)
156+
uses: actions/upload-pages-artifact@v3
157+
with:
158+
path: site/
159+
160+
# Upload the static files from the site/ directory to be used in the next job
161+
# This extra step is needed to allow the download of the artifact in the next job
162+
# for pushing its content to the branch named 'gh_pages'
163+
- name: Upload built site as artifact for gh_pages (master branch)
164+
if: ${{ env.CI_BRANCH == 'master' }}
165+
uses: actions/upload-artifact@v4
166+
with:
167+
name: artifact # name of the artifact (without the extension zip)
168+
path: site/
169+
if-no-files-found: 'error'
170+
compression-level: 0
171+
172+
# Job 2: Deploy the static files
173+
deploy-docs:
174+
needs: build-docs # previous job 'build-docs' need to be finished first
175+
176+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
177+
permissions:
178+
contents: read
179+
pages: write # to deploy to Pages
180+
id-token: write # to verify the deployment, originates from an appropriate source
181+
182+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
183+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
184+
concurrency:
185+
group: 'pages'
186+
cancel-in-progress: false
187+
188+
# Deploy to the github-pages environment
189+
environment:
190+
name: github-pages # Artifact name
191+
url: ${{ steps.deployment.outputs.page_url }}
192+
193+
runs-on: ubuntu-latest
194+
195+
steps:
196+
# Deploy the static files created in the previous job to GitHub Pages
197+
# To allow the deployment of the static files to GitHub Pages, no
198+
# restrictions on the branch name need to be set for desired branches on
199+
# https://github.com/easyscience/diffraction-lib/settings/environments
200+
# Currently, only develop and master branches are allowed to deploy to GitHub Pages
201+
# Deployed pages are available at https://easyscience.github.io/diffraction-lib
202+
- name:
203+
Deploy to easyscience.github.io/${{ github.event.repository.name }}
204+
(all branches)
205+
uses: actions/deploy-pages@v4
206+
207+
# Download built site as artifact from a previous job for gh_pages (master branch)
208+
- name: Download built site from previous job (master branch)
209+
if: ${{ env.CI_BRANCH == 'master' }}
210+
uses: actions/download-artifact@v4
211+
with: # name or path are taken from the upload step of the previous job
212+
name: artifact
213+
path: site/ # directory to extract downloaded zipped artifacts
214+
215+
# Push the site files created in the previous job to the gh_pages branch
216+
# To be able to push to the gh_pages branch, the personal GitHub API access
217+
# token GH_API_PERSONAL_ACCSESS_TOKEN must be set for this repository via
218+
# https://github.com/easyscience/diffraction-lib/settings/secrets/actions
219+
# This branch is used to deploy the site to the custom domain.
220+
# Deploying is done with a webhook:
221+
# https://github.com/easyscience/diffraction-lib/settings/hooks
222+
# This is done for the gh_pages branch when the site is tested with a step above
223+
- name:
224+
Deploy to gh_pages branch to trigger deployment to custom domain
225+
(master branch)
226+
if: ${{ env.CI_BRANCH == 'master' }}
227+
uses: s0/git-publish-subdir-action@develop
228+
env:
229+
GITHUB_TOKEN: ${{ secrets.GH_API_PERSONAL_ACCSESS_TOKEN }}
230+
REPO: self
231+
BRANCH: gh_pages
232+
FOLDER: site
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# This workflow will delete old workflow runs based on the input
2+
# parameters.
3+
# https://github.com/Mattraks/delete-workflow-runs
4+
5+
name: Delete old workflow runs
6+
7+
on:
8+
# Run monthly, at 00:00 on the 1st day of month.
9+
schedule:
10+
- cron: '0 0 1 * *'
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
inputs:
15+
days:
16+
description: 'Number of days.'
17+
required: true
18+
default: 30
19+
minimum_runs:
20+
description: 'The minimum runs to keep for each workflow.'
21+
required: true
22+
default: 6
23+
delete_workflow_pattern:
24+
description:
25+
'The name or filename of the workflow. if not set then it will target
26+
all workflows.'
27+
required: false
28+
delete_workflow_by_state_pattern:
29+
description:
30+
'Remove workflow by state: active, deleted, disabled_fork,
31+
disabled_inactivity, disabled_manually'
32+
required: true
33+
default: 'All'
34+
type: choice
35+
options:
36+
- 'All'
37+
- active
38+
- deleted
39+
- disabled_inactivity
40+
- disabled_manually
41+
delete_run_by_conclusion_pattern:
42+
description:
43+
'Remove workflow by conclusion: action_required, cancelled, failure,
44+
skipped, success'
45+
required: true
46+
default: 'All'
47+
type: choice
48+
options:
49+
- 'All'
50+
- action_required
51+
- cancelled
52+
- failure
53+
- skipped
54+
- success
55+
dry_run:
56+
description: 'Only log actions, do not perform any delete operations.'
57+
required: false
58+
59+
jobs:
60+
del-runs:
61+
runs-on: ubuntu-latest
62+
63+
permissions:
64+
actions: write
65+
66+
steps:
67+
- name: Delete workflow runs
68+
uses: Mattraks/delete-workflow-runs@v2
69+
with:
70+
token: ${{ github.token }}
71+
repository: ${{ github.repository }}
72+
retain_days: ${{ github.event.inputs.days }}
73+
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
74+
delete_workflow_pattern:
75+
${{ github.event.inputs.delete_workflow_pattern }}
76+
delete_workflow_by_state_pattern:
77+
${{ github.event.inputs.delete_workflow_by_state_pattern }}
78+
delete_run_by_conclusion_pattern:
79+
${{ github.event.inputs.delete_run_by_conclusion_pattern }}
80+
dry_run: ${{ github.event.inputs.dry_run }}

.github/workflows/publish-pypi.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Builds a Python package and publish it to PyPI when a new tag is
2+
# created.
3+
4+
name: Publish to PyPI
5+
6+
on:
7+
# Runs on creating a new tag starting with 'v', e.g. 'v1.0.3'
8+
push:
9+
tags:
10+
- 'v*'
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
jobs:
15+
pypi-publish:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Check-out repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: '0' # full history with tags to get the version number by versioningit
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.12'
28+
29+
- name: Upgrade package installer for Python
30+
run: pip install --upgrade pip
31+
32+
- name: Install Python dependencies
33+
run: pip install '.[dev]'
34+
35+
- name: Create Python package
36+
run: python -m build
37+
38+
- name: Publish distribution 📦 to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
password: ${{ secrets.PYPI_PASSWORD }}

0 commit comments

Comments
 (0)