Skip to content

Commit 6f7057e

Browse files
Split add() into dedicated methods for experiment creation (#86)
* Refactor ExperimentFactory and Experiments classes for improved argument handling and creation methods * Refactor Experiment initialization across tutorials to follow new API * Refactor functional tests to follow new API * Refactor unit tests to follow new API * Remove unused pytest import * Prevents building font cache info in docs build * Refines workflow name for clarity * Renames workflow for clarity and purpose * Removes Pixi validation workflow. The user specific validation is in another workflow. * More fixes for the functional tests * Automates tutorial script conversion and deployment * Update checkout action to version 5 in GitHub workflows * Updates release workflow to use enhanced actions * Enhances checkout action for full history fetching * Streamlines GitHub Actions YAML syntax * Removes push and pull_request triggers * Removes feature branch from CI config * Adds ID to draft release notes step * Refines experiment documentation to follow new API * Adds manual trigger to draft release notes workflow * Restricts GitHub Actions to master and develop branches * Simplifies experiment doc headings and clarifications * Refactors test workflow and adds cron trigger * Enables GitHub token for tutorial scripts * Removes branch-specific logic from workflows * Add tests for ExperimentFactory argument validation * Bump dependencies
1 parent 5eb1f8f commit 6f7057e

File tree

63 files changed

+1130
-971
lines changed

Some content is hidden

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

63 files changed

+1130
-971
lines changed

.github/workflows/build-docs.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ on:
66
# Selected branches
77
branches: [master, develop, docs, patch]
88
# Runs on creating a new tag starting with 'v', e.g. 'v1.0.3'
9-
tags:
10-
- 'v*'
9+
tags: ['v*']
1110
# Allows you to run this workflow manually from the Actions tab
1211
workflow_dispatch:
1312

@@ -41,7 +40,7 @@ jobs:
4140

4241
steps:
4342
- name: Check-out repository
44-
uses: actions/checkout@v4
43+
uses: actions/checkout@v5
4544
with:
4645
fetch-depth: 0 # full history + tags. needed to get the latest release version
4746

@@ -92,6 +91,12 @@ jobs:
9291
- name: Convert tutorial scripts to notebooks
9392
run: pixi run notebook-prepare
9493

94+
# The following step is needed to avoid the following message during the build:
95+
# "Matplotlib is building the font cache; this may take a moment"
96+
- name: Pre-build site step
97+
run: pixi run python -c "import easydiffraction"
98+
99+
# Run the notebooks to generate the output cells using multiple cores
95100
- name: Run notebooks
96101
run: pixi run notebook-exec
97102

.github/workflows/draft-release-notes.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
# Runs on pushes targeting the default branch (updates the real draft release)
88
push:
99
branches: [master]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
1012

1113
jobs:
1214
draft-release-notes:
@@ -17,9 +19,34 @@ jobs:
1719
runs-on: ubuntu-latest
1820

1921
steps:
20-
- name: Drafts the next release notes
21-
uses: enhantica/drafterino@v1
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
with:
25+
fetch-depth: 0 # full history with tags to get the version number by drafterino
26+
27+
- name: Set up pixi
28+
uses: prefix-dev/[email protected]
29+
with:
30+
environments: >-
31+
default
32+
activate-environment: default
33+
run-install: true
34+
frozen: true
35+
cache: false
36+
post-cleanup: false
37+
38+
- name: Convert tutorial scripts to notebooks
39+
run: pixi run notebook-prepare
40+
41+
- name: Clean up unnecessary script files
42+
run: rm -rf tutorials/*.py
2243

44+
- name: Zip the tutorials directory
45+
run: zip -9 -r tutorials.zip tutorials
46+
47+
- name: Drafts the next release notes
48+
id: draft
49+
uses: enhantica/drafterino@v2
2350
with:
2451
config: |
2552
title: 'easydiffraction $COMPUTED_VERSION'
@@ -43,3 +70,15 @@ jobs:
4370
4471
env:
4572
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
- name: Create GitHub draft release
75+
uses: softprops/action-gh-release@v2
76+
with:
77+
draft: true
78+
tag_name: ${{ steps.draft.outputs.tag_name }}
79+
name: ${{ steps.draft.outputs.release_name }}
80+
body: ${{ steps.draft.outputs.release_notes }}
81+
files: |
82+
tutorials.zip
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-pypi.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ name: Publish to PyPI
66
on:
77
# Runs on creating a new tag starting with 'v', e.g. 'v1.0.3'
88
push:
9-
tags:
10-
- 'v*'
9+
tags: ['v*']
1110
# Allows you to run this workflow manually from the Actions tab
1211
workflow_dispatch:
1312

@@ -17,7 +16,7 @@ jobs:
1716

1817
steps:
1918
- name: Check-out repository
20-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2120
with:
2221
fetch-depth: '0' # full history with tags to get the version number by versioningit
2322

.github/workflows/scan-security.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ name: Scan security (static analysis)
77
on:
88
# Trigger the workflow on pull request
99
pull_request:
10-
branches:
11-
- '**'
10+
branches: ['**']
1211
# Allows you to run this workflow manually from the Actions tab
1312
workflow_dispatch:
1413

@@ -20,7 +19,7 @@ jobs:
2019

2120
steps:
2221
- name: Checkout repository
23-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2423
with:
2524
# We must fetch at least the immediate parents so that if this is
2625
# a pull request then we can checkout the head.

.github/workflows/test-code.yaml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# - Check code linting
77
# - Check code formatting
88
# - Check formatting of Markdown, YAML, TOML, etc. files
9-
# 2. run-tests:
9+
# 2. test-source:
1010
# - Test the code base against the latest code in the repository
1111
# - Create the Python package
1212
# - Upload the Python package for the next job
@@ -21,16 +21,13 @@ on:
2121
# Trigger the workflow on push
2222
push:
2323
# Every branch
24-
branches:
25-
- '**'
24+
branches: ['**']
2625
# But do not run this workflow on creating a new tag starting with
2726
# 'v', e.g. 'v1.0.3' (see publish-pypi.yml)
28-
tags-ignore:
29-
- 'v*'
27+
tags-ignore: ['v*']
3028
# Trigger the workflow on pull request
3129
pull_request:
32-
branches:
33-
- '**'
30+
branches: ['**']
3431
# Allows you to run this workflow manually from the Actions tab
3532
workflow_dispatch:
3633

@@ -57,9 +54,21 @@ jobs:
5754

5855
runs-on: ${{ matrix.os }}
5956

57+
outputs:
58+
pytest-marks: ${{ steps.set-mark.outputs.pytest_marks }}
59+
6060
steps:
61+
- name: Set mark for functional tests
62+
id: set-mark
63+
run: |
64+
if [[ "${{ env.CI_BRANCH }}" != "master" && "${{ env.CI_BRANCH }}" != "develop" ]]; then
65+
echo "pytest_marks=-m 'fast'" >> $GITHUB_OUTPUT
66+
else
67+
echo "pytest_marks=" >> $GITHUB_OUTPUT
68+
fi
69+
6170
- name: Checkout repository
62-
uses: actions/checkout@v4
71+
uses: actions/checkout@v5
6372

6473
- name: Set up pixi (incl. environments and dependencies)
6574
uses: prefix-dev/[email protected]
@@ -136,7 +145,7 @@ jobs:
136145

137146
# Job 2: Test code
138147
# TODO: Add coverage reporting with upload to Codecov?
139-
run-tests:
148+
test-source:
140149
needs: code-quality # previous job needs to be finished first
141150

142151
strategy:
@@ -151,7 +160,7 @@ jobs:
151160

152161
steps:
153162
- name: Checkout repository
154-
uses: actions/checkout@v4
163+
uses: actions/checkout@v5
155164
with:
156165
fetch-depth: '0' # full history with tags to get the version number by versioningit
157166

@@ -172,12 +181,13 @@ jobs:
172181
pixi run -e $env unit-tests
173182
done
174183
175-
- name: Run functional tests
184+
- name:
185+
Run functional tests ${{ needs.code-quality.outputs.pytest-marks }}
176186
shell: bash
177187
run: |
178188
for env in ${{ env.PIXI_ENVS }}; do
179189
echo "🔹🔸🔹🔸🔹 Current env: $env 🔹🔸🔹🔸🔹"
180-
pixi run -e $env func-tests
190+
pixi run -e $env func-tests "${{ needs.code-quality.outputs.pytest-marks }}"
181191
done
182192
183193
# Delete all local tags when not on a tagged commit to force versioningit
@@ -215,7 +225,7 @@ jobs:
215225

216226
# Job 3: Test the package
217227
test-package:
218-
needs: run-tests # the previous job needs to be finished first
228+
needs: test-source # the previous job needs to be finished first
219229

220230
strategy:
221231
fail-fast: false
@@ -260,18 +270,19 @@ jobs:
260270
pixi run -e $env easydiffraction version
261271
done
262272
263-
- name: Run unit tests (using built package from previous job)
273+
- name: Run unit tests
264274
shell: bash
265275
run: |
266276
for env in ${{ env.PIXI_ENVS }}; do
267277
echo "🔹🔸🔹🔸🔹 Current env: $env 🔹🔸🔹🔸🔹"
268278
pixi run -e $env unit-tests
269279
done
270280
271-
- name: Run functional tests (using built package from previous job)
281+
- name:
282+
Run functional tests ${{ needs.code-quality.outputs.pytest-marks }}
272283
shell: bash
273284
run: |
274285
for env in ${{ env.PIXI_ENVS }}; do
275286
echo "🔹🔸🔹🔸🔹 Current env: $env 🔹🔸🔹🔸🔹"
276-
pixi run -e $env func-tests
287+
pixi run -e $env func-tests "${{ needs.code-quality.outputs.pytest-marks }}"
277288
done

.github/workflows/test-package-pypi.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test unpinned package from PyPI
1+
name: Test unpinned PyPI package
22

33
on:
44
# Run daily, at 00:00.
@@ -52,11 +52,13 @@ jobs:
5252
- name: Run functional tests to verify the installation
5353
run: pixi run func-tests
5454

55-
- name: List the available EasyDiffraction tutorials
56-
run: pixi run tutorials-list
57-
58-
- name: Fetch the EasyDiffraction tutorials
59-
run: pixi run tutorials-fetch
55+
# Github token to avoid hitting the unauthenticated API rate limit
56+
- name: List and fetch the EasyDiffraction tutorials
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: |
60+
pixi run tutorials-list
61+
pixi run tutorials-fetch
6062
6163
- name: Test tutorials as notebooks
6264
run: pixi run notebook-tests

.github/workflows/test-tutorials-colab.yaml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
name: Test tutorials on Colab
22

33
on:
4-
# Trigger the workflow on push
5-
#push:
6-
# # Every branch
7-
# branches:
8-
# - '**'
9-
# # But do not run this workflow on creating a new tag starting with 'v', e.g. 'v1.0.3' (see publish-pypi.yml)
10-
# tags-ignore:
11-
# - 'v*'
12-
# Trigger the workflow on pull request
13-
#pull_request:
14-
# branches:
15-
# - '**'
164
# Allows you to run this workflow manually from the Actions tab
175
workflow_dispatch:
186

@@ -37,7 +25,7 @@ jobs:
3725

3826
steps:
3927
- name: Checkout repository
40-
uses: actions/checkout@v4
28+
uses: actions/checkout@v5
4129

4230
- name: Set up Python ${{ matrix.python-version }}
4331
uses: actions/setup-python@v5

.github/workflows/test-tutorials.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@ name: Test tutorials
33
on:
44
# Trigger the workflow on push
55
push:
6-
# Every branch
7-
branches:
8-
- '**'
9-
# But do not run this workflow on creating a new tag starting with
10-
# 'v', e.g. 'v1.0.3' (see publish-pypi.yml)
11-
tags-ignore:
12-
- 'v*'
6+
# Selected branches
7+
branches: [master, develop]
138
# Trigger the workflow on pull request
149
pull_request:
15-
branches:
16-
- '**'
10+
branches: ['**']
1711
# Trigger the workflow on workflow_call (to be called from other workflows)
1812
# Needed, as standard schedule triggers the master branch only, but we want
1913
# to run this workflow on develop branch.
@@ -39,7 +33,7 @@ jobs:
3933

4034
steps:
4135
- name: Checkout repository
42-
uses: actions/checkout@v4
36+
uses: actions/checkout@v5
4337

4438
- name: Set up pixi
4539
uses: prefix-dev/[email protected]
@@ -82,7 +76,7 @@ jobs:
8276

8377
steps:
8478
- name: Checkout repository
85-
uses: actions/checkout@v4
79+
uses: actions/checkout@v5
8680

8781
- name: Set up pixi
8882
uses: prefix-dev/[email protected]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Trigger scheduled test code
2+
3+
on:
4+
# Run daily, at 00:00.
5+
schedule:
6+
- cron: '0 0 * * *'
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
jobs:
11+
trigger-test-tutorials:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout develop branch
16+
uses: actions/checkout@v5
17+
with:
18+
ref: develop
19+
20+
- name: Trigger test-tutorials workflow
21+
uses: actions/github-script@v7
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
script: |
25+
await github.rest.actions.createWorkflowDispatch({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
workflow_id: "test-code.yaml",
29+
ref: "develop"
30+
});

.github/workflows/test-tutorials-nightly.yaml renamed to .github/workflows/trigger-test-tutorials.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test tutorials nightly (develop)
1+
name: Trigger scheduled test tutorials
22

33
on:
44
# Run daily, at 00:00.
@@ -8,12 +8,12 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
call-tutorials:
11+
trigger-test-tutorials:
1212
runs-on: ubuntu-latest
1313

1414
steps:
1515
- name: Checkout develop branch
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v5
1717
with:
1818
ref: develop
1919

0 commit comments

Comments
 (0)