Skip to content

Commit e9f7d8e

Browse files
Merge pull request #109 from easyscience/develop
Release: merge develop into master
2 parents 52262f7 + 07ae323 commit e9f7d8e

File tree

339 files changed

+37168
-59499
lines changed

Some content is hidden

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

339 files changed

+37168
-59499
lines changed

.badgery.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ cards:
5252
- group: Coverage
5353
type: codecov
5454
title: Unit test coverage (Codecov)
55+
flag: unittests
5556
enabled: true
5657

5758
- group: Coverage
Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
# This workflow creates a backmerge PR from DEFAULT_BRANCH into `develop`
2-
# whenever a new version tag is pushed (v*).
1+
# This workflow creates a backmerge PR into `develop` whenever a new version tag is pushed (v*).
32
#
4-
# Usage:
5-
# - Triggered automatically on tag push (v*).
6-
# - Creates a PR titled "Backmerge: DEFAULT_BRANCH into develop".
7-
# - Adds the label "[maintainer] auto-pull-request" so it is excluded from changelogs.
3+
# Key points:
4+
# - The PR head is a temporary branch that points at the *tag commit* (refs/tags/vX.Y.Z).
5+
# After merging, `develop` can `git describe` as vX.Y.Z-... because the tag commit becomes an ancestor.
6+
# - The PR is auto-merged using a MERGE COMMIT (not squash) via a GitHub App token.
7+
# The GitHub App must be added to the develop ruleset bypass list.
8+
#
9+
# Required repo config:
10+
# - Actions secret: ES_BACKMERGE_PRIVATE_KEY (GitHub App private key PEM)
11+
# - Actions variable: ES_BACKMERGE_APP_ID (GitHub App ID)
812

9-
name: Backmerge PR creation
13+
name: Backmerge PR (tag -> develop)
1014

1115
on:
1216
push:
@@ -17,28 +21,76 @@ permissions:
1721
contents: write
1822
pull-requests: write
1923

20-
# Set the environment variables to be used in all jobs defined in this workflow
21-
env:
22-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
23-
2424
jobs:
2525
create-backmerge-pr:
2626
runs-on: ubuntu-latest
27+
2728
steps:
28-
- name: Checkout ${{ env.DEFAULT_BRANCH }} branch
29+
- name: Create GitHub App installation token
30+
id: app-token
31+
uses: actions/create-github-app-token@v2
32+
with:
33+
app-id: ${{ vars.ES_BACKMERGE_APP_ID }}
34+
private-key: ${{ secrets.ES_BACKMERGE_PRIVATE_KEY }}
35+
36+
- name: Checkout tag commit
2937
uses: actions/checkout@v5
3038
with:
31-
ref: ${{ env.DEFAULT_BRANCH }}
39+
ref: ${{ github.ref }} # refs/tags/vX.Y.Z
40+
fetch-depth: 0
41+
token: ${{ steps.app-token.outputs.token }}
42+
43+
- name: Create and push backmerge branch at tag
44+
id: vars
45+
run: |
46+
set -euo pipefail
47+
48+
TAG='${{ github.ref_name }}'
49+
BRANCH="backmerge/${TAG}"
50+
51+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
52+
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
53+
54+
git config user.name "github-actions[bot]"
55+
git config user.email "github-actions[bot]@users.noreply.github.com"
56+
57+
# Create/move branch to point exactly at the tag commit
58+
git checkout -B "$BRANCH"
59+
60+
# Push (force makes re-runs idempotent for the same tag)
61+
git push --force --set-upstream origin "$BRANCH"
62+
env:
63+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
64+
65+
- name:
66+
Create PR from tag backmerge branch to develop (or reuse if exists)
67+
run: |
68+
set -euo pipefail
69+
70+
TITLE="Backmerge: ${{ steps.vars.outputs.tag }} into develop"
71+
72+
BODY="⚠️ This PR is created automatically for backmerge of a new release tag commit \`${{ steps.vars.outputs.tag }}\` into \`develop\`.
73+
74+
It is labeled '[maintainer] auto-pull-request' and is excluded from release notes and version bump logic."
75+
76+
if gh pr view --repo "${{ github.repository }}" --head "${{ steps.vars.outputs.branch }}" >/dev/null 2>&1; then
77+
echo "PR already exists for head=${{ steps.vars.outputs.branch }}"
78+
else
79+
gh pr create \
80+
--repo "${{ github.repository }}" \
81+
--base develop \
82+
--head "${{ steps.vars.outputs.branch }}" \
83+
--title "$TITLE" \
84+
--label "[maintainer] auto-pull-request" \
85+
--body "$BODY"
86+
fi
87+
env:
88+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3289

33-
- name: Create PR from ${{ env.DEFAULT_BRANCH }} to develop
90+
- name: Enable auto-merge using MERGE COMMIT
3491
run: |
35-
gh pr create \
36-
--base develop \
37-
--head ${{ env.DEFAULT_BRANCH }} \
38-
--title "Backmerge: ${{ env.DEFAULT_BRANCH }} into develop" \
39-
--label "[maintainer] auto-pull-request" \
40-
--body "⚠️ This PR is created automatically for backmerges changes from \`${{ env.DEFAULT_BRANCH }}\` into \`develop\`, following a new release tag push.
41-
42-
It is labeled \`[maintainer] auto-pull-request\` and is excluded from release notes and version bump logic."
92+
set -euo pipefail
93+
# Merge the PR identified by its head branch.
94+
gh pr merge --repo "${{ github.repository }}" --merge --auto "${{ steps.vars.outputs.branch }}"
4395
env:
44-
GITHUB_TOKEN: ${{ secrets.GH_API_PERSONAL_ACCESS_TOKEN }}
96+
GH_TOKEN: ${{ steps.app-token.outputs.token }}

.github/workflows/coverage.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ jobs:
8686
verbose: true
8787
token: ${{ secrets.CODECOV_TOKEN }}
8888

89-
# Job 2: Run functional tests with coverage and upload to Codecov
90-
func-tests-coverage:
89+
# Job 2: Run integration tests with coverage and upload to Codecov
90+
integration-tests-coverage:
9191
runs-on: ubuntu-latest
9292

9393
steps:
@@ -108,23 +108,25 @@ jobs:
108108
shell: bash
109109
run: pixi run dev
110110

111-
- name: Run functional tests with coverage
112-
run: pixi run func-tests-coverage --cov-report=xml:coverage-func.xml
111+
- name: Run integration tests with coverage
112+
run:
113+
pixi run integration-tests-coverage
114+
--cov-report=xml:coverage-integration.xml
113115

114-
- name: Upload functional tests coverage to Codecov
116+
- name: Upload integration tests coverage to Codecov
115117
if: ${{ !cancelled() }}
116118
uses: codecov/codecov-action@v5
117119
with:
118-
name: func-tests-job
119-
flags: functional
120-
files: ./coverage-func.xml
120+
name: integration-tests-job
121+
flags: integration
122+
files: ./coverage-integration.xml
121123
fail_ci_if_error: true
122124
verbose: true
123125
token: ${{ secrets.CODECOV_TOKEN }}
124126

125127
# Job 4: Trigger dashboard build
126128
dashboard-build-trigger:
127-
needs: [docstring-coverage, unit-tests-coverage, func-tests-coverage] # depend on the previous jobs
129+
needs: [docstring-coverage, unit-tests-coverage, integration-tests-coverage] # depend on the previous jobs
128130

129131
runs-on: ubuntu-latest
130132

.github/workflows/dashboard.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,34 @@ jobs:
4141

4242
- name: Install and setup development dependencies
4343
shell: bash
44-
run: pixi run dev
44+
run: |
45+
pixi run dev
46+
pixi add --pypi --git https://github.com/enhantica/badgery badgery
4547
4648
- name: Run docstring coverage and code complexity/maintainability checks
4749
run: |
4850
for BRANCH in ${{ env.DEFAULT_BRANCH }} ${{ env.DEVELOP_BRANCH }} ${{ env.CI_BRANCH }}; do
4951
echo "=== Processing branch $BRANCH ==="
50-
if [ -d "../worktree-$BRANCH" ]; then
52+
if [ -d "../$BRANCH" ]; then
5153
echo "Branch $BRANCH already processed, skipping"
5254
continue
5355
fi
54-
git worktree add ../worktree-$BRANCH origin/$BRANCH
56+
git worktree add ../$BRANCH origin/$BRANCH
5557
mkdir -p reports/$BRANCH
5658
echo "Docstring coverage for branch $BRANCH"
57-
pixi run interrogate -c pyproject.toml --fail-under=0 ../worktree-$BRANCH/src > reports/$BRANCH/coverage-docstring.txt
59+
pixi run interrogate -c pyproject.toml --fail-under=0 ../$BRANCH/src > reports/$BRANCH/coverage-docstring.txt
5860
echo "Cyclomatic complexity for branch $BRANCH"
59-
pixi run radon cc -s -j ../worktree-$BRANCH/src --exclude ../worktree-$BRANCH/src/easydiffraction/crystallography/space_group_lookup_table.py > reports/$BRANCH/cyclomatic-complexity.json
61+
pixi run radon cc -s -j ../$BRANCH/src > reports/$BRANCH/cyclomatic-complexity.json
6062
echo "Maintainability index for branch $BRANCH"
61-
pixi run radon mi -j ../worktree-$BRANCH/src --exclude ../worktree-$BRANCH/src/easydiffraction/crystallography/space_group_lookup_table.py > reports/$BRANCH/maintainability-index.json
63+
pixi run radon mi -j ../$BRANCH/src > reports/$BRANCH/maintainability-index.json
6264
echo "Raw metrics for branch $BRANCH"
63-
pixi run radon raw -s -j ../worktree-$BRANCH/src --exclude ../worktree-$BRANCH/src/easydiffraction/crystallography/space_group_lookup_table.py > reports/$BRANCH/raw-metrics.json
65+
pixi run radon raw -s -j ../$BRANCH/src > reports/$BRANCH/raw-metrics.json
6466
done
6567
6668
- name: Generate dashboard HTML
67-
run: |
68-
pixi add --pypi --git https://github.com/enhantica/badgery badgery
69-
pixi run pip show badgery
70-
pixi run python -m badgery --config .badgery.yaml --repo ${{ github.repository }} --branch ${{ env.CI_BRANCH }} --output index.html
69+
run: >
70+
pixi run python -m badgery --config .badgery.yaml --repo ${{
71+
github.repository }} --branch ${{ env.CI_BRANCH }} --output index.html
7172
7273
- name: Prepare publish directory
7374
run: |

.github/workflows/docs.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ jobs:
137137
# Input: docs/ directory containing the Markdown files
138138
# Output: site/ directory containing the generated HTML files
139139
- name: Build site with MkDocs
140-
run: pixi run docs-build
140+
run: |
141+
if [[ "${CI_BRANCH}" == "develop" || "${CI_BRANCH}" == "master" || "${CI_BRANCH}" == "main" ]]; then
142+
echo "📘 Building production docs for ${CI_BRANCH}"
143+
pixi run docs-build
144+
else
145+
echo "📗 Building local docs for ${CI_BRANCH}"
146+
pixi run docs-local
147+
fi
141148
142149
# Set up the Pages action to configure the static files to be deployed
143150
# NOTE: The repository must have GitHub Pages enabled and configured to build using GitHub Actions

.github/workflows/pypi-test.yaml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ env:
2020
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
2121

2222
jobs:
23+
# Job 1: Test installation from PyPI on multiple OS
2324
pypi-package-tests:
2425
strategy:
2526
matrix:
@@ -54,24 +55,45 @@ jobs:
5455
- name: Create the environment and install dependencies
5556
run: pixi install
5657

57-
- name: Install package from PyPI with dev and visualization extras
58-
run: |
59-
pixi add --pypi "easydiffraction[dev,visualization]"
60-
pixi run easydiffraction --version
58+
- name: Install package from PyPI with all extras
59+
run: pixi add --pypi "easydiffraction[all]"
6160

6261
- name: Run unit tests to verify the installation
6362
run: pixi run unit-tests
6463

65-
- name: Run functional tests to verify the installation
66-
run: pixi run func-tests
64+
- name: Run integration tests to verify the installation
65+
run: pixi run integration-tests
6766

6867
# Github token to avoid hitting the unauthenticated API rate limit
6968
- name: List and fetch the EasyDiffraction tutorials
7069
env:
7170
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7271
run: |
73-
pixi run tutorials-list
74-
pixi run tutorials-fetch
72+
pixi run easydiffraction --version
73+
pixi run easydiffraction list-tutorials
74+
pixi run easydiffraction fetch-tutorials
7575
7676
- name: Test tutorials as notebooks
7777
run: pixi run notebook-tests
78+
79+
# Job 2: Trigger dashboard build
80+
dashboard-build-trigger:
81+
needs: pypi-package-tests
82+
83+
runs-on: ubuntu-latest
84+
85+
steps:
86+
- name: Check-out repository
87+
uses: actions/checkout@v5
88+
89+
- name: Trigger dashboard build
90+
uses: actions/github-script@v7
91+
with:
92+
github-token: ${{ secrets.GITHUB_TOKEN }}
93+
script: |
94+
await github.rest.actions.createWorkflowDispatch({
95+
owner: context.repo.owner,
96+
repo: context.repo.repo,
97+
workflow_id: "dashboard.yaml",
98+
ref: "${{ env.CI_BRANCH }}"
99+
});

.github/workflows/test.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ jobs:
5656
pytest-marks: ${{ steps.set-mark.outputs.pytest_marks }}
5757

5858
steps:
59-
# Determine if functional tests should be run fully or only the fast ones
59+
# Determine if integration tests should be run fully or only the fast ones
6060
# (to save time on branches other than master and develop)
61-
- name: Set mark for functional tests
61+
- name: Set mark for integration tests
6262
id: set-mark
6363
run: |
6464
if [[ "${{ env.CI_BRANCH }}" == "master" || "${{ env.CI_BRANCH }}" == "develop" ]]; then
6565
echo "pytest_marks=" >> $GITHUB_OUTPUT
6666
else
67-
echo "pytest_marks=-m 'fast'" >> $GITHUB_OUTPUT
67+
echo "pytest_marks=-m fast" >> $GITHUB_OUTPUT
6868
fi
6969
7070
# Job 2: Test code
@@ -115,12 +115,13 @@ jobs:
115115
pixi run --environment $env unit-tests
116116
done
117117
118-
- name: Run functional tests ${{ needs.env-prepare.outputs.pytest-marks }}
118+
- name:
119+
Run integration tests ${{ needs.env-prepare.outputs.pytest-marks }}
119120
shell: bash
120121
run: |
121122
for env in ${{ env.PIXI_ENVS }}; do
122123
echo "🔹🔸🔹🔸🔹 Current env: $env 🔹🔸🔹🔸🔹"
123-
pixi run --environment $env func-tests "${{ needs.env-prepare.outputs.pytest-marks }}"
124+
pixi run --environment $env integration-tests ${{ needs.env-prepare.outputs.pytest-marks }}
124125
done
125126
126127
# Delete all local tags when not on a tagged commit to force versioningit
@@ -147,6 +148,10 @@ jobs:
147148
shell: bash
148149
run: pixi remove --pypi easydiffraction
149150

151+
- name: Remove Python cache files before uploading
152+
shell: bash
153+
run: pixi run clean-pycache
154+
150155
# More than one file/dir need to be specified in 'path', to preserve the
151156
# structure of the dist/ directory, not only its contents.
152157
- name: Upload Python package for the next job
@@ -156,6 +161,7 @@ jobs:
156161
path: |
157162
dist/
158163
tests/
164+
pytest.ini
159165
pixi.toml
160166
pixi.lock
161167
if-no-files-found: 'error'
@@ -221,12 +227,13 @@ jobs:
221227
pixi run --environment $env unit-tests
222228
done
223229
224-
- name: Run functional tests ${{ needs.env-prepare.outputs.pytest-marks }}
230+
- name:
231+
Run integration tests ${{ needs.env-prepare.outputs.pytest-marks }}
225232
shell: bash
226233
run: |
227234
for env in ${{ env.PIXI_ENVS }}; do
228235
echo "🔹🔸🔹🔸🔹 Current env: $env 🔹🔸🔹🔸🔹"
229-
pixi run --environment $env func-tests "${{ needs.env-prepare.outputs.pytest-marks }}"
236+
pixi run --environment $env integration-tests ${{ needs.env-prepare.outputs.pytest-marks }}
230237
done
231238
232239
# Job 4: Trigger dashboard build

0 commit comments

Comments
 (0)