Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions .github/scripts/generate_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"Authorization": f"Bearer {os.environ['GH_TOKEN']}"
}

TAG_PATTERN = re.compile(r"^source-v(\d+\.\d+\.\d+)$")
TAG_PATTERN = re.compile(r"^v(\d+\.\d+\.\d+)$")
LABEL_PRIORITY = []


Expand Down Expand Up @@ -53,25 +53,29 @@ def find_previous_source_tag(end_tag):
m = None if end_tag == "HEAD" else TAG_PATTERN.match(end_tag)
end_version = semver.parse(m.group(1)) if m else None

print(f"Finding previous source tag before {end_tag} (version {end_version})")
print(f"Finding previous version tag before {end_tag} (version: {end_version})")
for t in tags:
m = TAG_PATTERN.match(t)
if not m:
continue

v = semver.parse(m.group(1))
if end_version and v >= semver.parse(end_version):
if end_version and v >= end_version:
continue

valid.append((v, t))

print(valid)
if not valid:
raise RuntimeError("No valid source-vX.Y.Z tags found")
raise RuntimeError("No valid vX.Y.Z tags found")

valid.sort(reverse=True)
print(f"Previous source tag found: {valid[0][1]} with version {valid[0][0]}")
return valid[0][1]
previous_source_tag = f"source-{valid[0][1]}"
if not previous_source_tag in tags:
raise RuntimeError(f"Previous source tag {previous_source_tag} for {valid[0][1]} not found in git tags")

print(f"Previous source tag found: {previous_source_tag} with version {valid[0][0]}")
return previous_source_tag


def get_merge_commits(start, end="HEAD"):
Expand All @@ -80,19 +84,23 @@ def get_merge_commits(start, end="HEAD"):
f"{start}..{end}",
"--merges",
"--first-parent",
"--pretty=%s"
"--pretty=%h"
])
print(f"Git log between {start} and {end}:\n{log}")
return log.splitlines()


def extract_pr_numbers(messages):
prs = []
for msg in messages:
m = re.search(r"#(\d+)", msg)
if m:
prs.append(int(m.group(1)))
return prs
def fetch_associated_pr_number(commit):
url = f"{GITHUB_API}/repos/cellml/libcellml/commits/{commit}/pulls"
r = requests.get(url, headers=HEADERS)
r.raise_for_status()
prs = r.json()
if not prs:
print(f"No associated PR found for commit {commit}.")
return None
pr_number = prs[0]["number"]
print(f"Associated PR #{pr_number} found for commit {commit}.")
return pr_number


def fetch_pr(org_repo, pr_number):
Expand Down Expand Up @@ -184,9 +192,14 @@ def process_arguments():
if __name__ == "__main__":
args = process_arguments()
previous_source_tag = find_previous_source_tag(args.tag_end) if args.tag_start == "PREV" else args.tag_start
messages = get_merge_commits(previous_source_tag, 'source-v' + args.tag_end if args.tag_end != "HEAD" else "HEAD")
print(f"Found {len(messages)} merge commits between {previous_source_tag} and {args.tag_end}.")
pr_numbers = extract_pr_numbers(messages)
commits = get_merge_commits(previous_source_tag, 'source-' + args.tag_end if args.tag_end != "HEAD" else "HEAD")
print(f"Found {len(commits)} merge commits between {previous_source_tag} and {args.tag_end}.")

pr_numbers = []
for commit in commits:
pr_number = fetch_associated_pr_number(commit)
if pr_number is not None:
pr_numbers.append(pr_number)
print(f"Extracted {len(pr_numbers)} PR numbers from merge commits.")

summaries = []
Expand All @@ -203,6 +216,6 @@ def process_arguments():
print(f"Extracted summaries for {len(sorted_summaries)} merged PRs.")
print(sorted_summaries)

tag_end_label = "latest" if args.tag_end == "HEAD" else f"v{args.tag_end}"
tag_end_label = "latest" if args.tag_end == "HEAD" else f"{args.tag_end}"
tag_end_label = tag_end_label if args.tag_end_display_name is None else args.tag_end_display_name
write_out_to_changelog_file(sorted_summaries, tag_end=tag_end_label)
6 changes: 3 additions & 3 deletions .github/workflows/release-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

# Extract release tag by removing prefix
tag="${branch#${{ vars.RELEASE_STAGING_BRANCH_STEM }}}"
echo "RELEASE_TAG=$tag" >> "$GITHUB_ENV"
echo "RELEASE_VERSION=$tag" >> "$GITHUB_ENV"

- name: Checkout release staging branch
run: |
Expand All @@ -50,7 +50,7 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
pip install requests packaging
python .github/scripts/generate_changelog.py -p cellml/libcellml PREV ${{ env.RELEASE_TAG }}
python .github/scripts/generate_changelog.py -p cellml/libcellml PREV v${{ env.RELEASE_VERSION }}
mv changelog_*.rst docs/changelogs/
python .github/scripts/clean_and_reindex_changelogs.py .

Expand All @@ -60,5 +60,5 @@ jobs:
git config user.email "github-actions[bot]@users.noreply.github.com"

git add docs/changelogs/changelog_*.rst docs/changelogs/index.rst docs/index.rst
git commit -m "Add changelog for release ${RELEASE_TAG}" || echo "No changes to commit"
git commit -m "Add changelog for release ${RELEASE_VERSION}" || echo "No changes to commit"
git push
27 changes: 16 additions & 11 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ jobs:
ref: release
path: release-repo

- uses: actions/checkout@v6
with:
ref: ${{ inputs.source_branch }}
path: source-repo

- name: Detect active release staging branches (PR-backed)
id: detect_branch
env:
Expand Down Expand Up @@ -65,32 +70,31 @@ jobs:
#branch="${active[0]}"
#echo "release_branch=$branch" >> "$GITHUB_OUTPUT"

- name: Set GitHub Actions bot identity
- name: Set GitHub Actions bot identity (both repos)
run: |
cd release-repo

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- uses: actions/checkout@v6
with:
ref: ${{ inputs.source_branch }}
path: source-repo
cd ../source-repo

- name: Create staging branch
run: |
cd release-repo
git checkout -b ${{ vars.RELEASE_STAGING_BRANCH_STEM }}${{ inputs.version }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Tag source of release
run: |
cd source-repo

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "source-v${{ inputs.version }}" -m "Source tag for release v${{ inputs.version }}"
git push origin "source-v${{ inputs.version }}"

- name: Create staging branch
run: |
cd release-repo

git checkout -b ${{ vars.RELEASE_STAGING_BRANCH_STEM }}${{ inputs.version }}

- name: Copy release changes to release repo
run: |
rsync -avW --delete --exclude='.git' source-repo/ release-repo/
Expand All @@ -105,6 +109,7 @@ jobs:
- name: Push branch
run: |
cd release-repo

git push origin ${{ vars.RELEASE_STAGING_BRANCH_STEM }}${{ inputs.version }}

generate_changelog:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ endif()
set(PROJECT_NAME libCellML)
set(PROJECT_URL https://libcellml.org)
set(_PROJECT_VERSION 0.7.0)
set(PROJECT_DEVELOPER_VERSION -rc.4)
set(PROJECT_DEVELOPER_VERSION )
project(${PROJECT_NAME} VERSION ${_PROJECT_VERSION} LANGUAGES CXX)

# Set policies that affect the build.
Expand Down
106 changes: 106 additions & 0 deletions docs/changelogs/changelog_v0.7.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
libCellML v0.7.0 Changelog
==========================

Analyser
--------

* Improve caching of equivalent variables in analyser model by `@hsorby <https://github.com/hsorby>`_ [`#1389 <https://github.com/cellml/libcellml/pull/1389>`_].
* Analyser: account for an underconstrained NLA system by `@agarny <https://github.com/agarny>`_ [`#1338 <https://github.com/cellml/libcellml/pull/1338>`_].

Bug
---

* Fix bug with litre units by `@hsorby <https://github.com/hsorby>`_ [`#1314 <https://github.com/cellml/libcellml/pull/1314>`_].
* Fix segfault with imports across multiple directories by `@hsorby <https://github.com/hsorby>`_ [`#1304 <https://github.com/cellml/libcellml/pull/1304>`_].

Documentation
-------------

* Fix warnings when building the documentation with Doxygen by `@hsorby <https://github.com/hsorby>`_ [`#1349 <https://github.com/cellml/libcellml/pull/1349>`_].
* Updating citation information for libCellML by `@nickerso <https://github.com/nickerso>`_ [`#1361 <https://github.com/cellml/libcellml/pull/1361>`_].

Generator
---------

* Generator class holds a reference to an analyser model by `@hsorby <https://github.com/hsorby>`_ [`#1439 <https://github.com/cellml/libcellml/pull/1439>`_].
* Generator: fix a couple of issues with the Python profile by `@agarny <https://github.com/agarny>`_ [`#1376 <https://github.com/cellml/libcellml/pull/1376>`_].
* Generator profile: fix `computeComputedConstants()`'s signature by `@agarny <https://github.com/agarny>`_ [`#1364 <https://github.com/cellml/libcellml/pull/1364>`_].
* Add additional overloads to `Generator` class implementationCode and interfaceCode methods by `@hsorby <https://github.com/hsorby>`_ [`#1345 <https://github.com/cellml/libcellml/pull/1345>`_].
* Add a `GeneratorVariableTracker` class to manage un/tracked variables by `@agarny <https://github.com/agarny>`_ [`#1340 <https://github.com/cellml/libcellml/pull/1340>`_].
* Allow a constant, a computed constant, or a state variable (but not an algebraic variable) to be used as an initial value by `@agarny <https://github.com/agarny>`_ [`#1325 <https://github.com/cellml/libcellml/pull/1325>`_].
* Code generator: allow for variables to be tracked/untracked by `@agarny <https://github.com/agarny>`_ [`#1256 <https://github.com/cellml/libcellml/pull/1256>`_].
* Code generator: use different arrays for constants, computed constants, and algebraic variables by `@agarny <https://github.com/agarny>`_ [`#1247 <https://github.com/cellml/libcellml/pull/1247>`_].
* Syntax error in generated Python code by `@agarny <https://github.com/agarny>`_ [`#1334 <https://github.com/cellml/libcellml/pull/1334>`_].
* API: simplify/improve the API for external variables by `@agarny <https://github.com/agarny>`_ [`#1252 <https://github.com/cellml/libcellml/pull/1252>`_].

Infrastructure
--------------

* macOS: support version 14.0 and later by `@agarny <https://github.com/agarny>`_ [`#1447 <https://github.com/cellml/libcellml/pull/1447>`_].
* Output unit test failures to CI logs by `@hsorby <https://github.com/hsorby>`_ [`#1441 <https://github.com/cellml/libcellml/pull/1441>`_].
* Don't push changes to main too early in finalise workflow by `@hsorby <https://github.com/hsorby>`_ [`#1433 <https://github.com/cellml/libcellml/pull/1433>`_].
* Reset working directory when ccloning passed documentation repositories by `@hsorby <https://github.com/hsorby>`_ [`#1432 <https://github.com/cellml/libcellml/pull/1432>`_].
* Revert to windows-2022 to avoid issues with windows-2025 by `@hsorby <https://github.com/hsorby>`_ [`#1431 <https://github.com/cellml/libcellml/pull/1431>`_].
* Try a different approach to setting permissions for make release workflow by `@hsorby <https://github.com/hsorby>`_ [`#1430 <https://github.com/cellml/libcellml/pull/1430>`_].
* Re-instate final fixes to release process workflow overwritten during testing by `@hsorby <https://github.com/hsorby>`_ [`#1428 <https://github.com/cellml/libcellml/pull/1428>`_].
* Perform final sanity check before pushing release changes to main by `@hsorby <https://github.com/hsorby>`_ [`#1427 <https://github.com/cellml/libcellml/pull/1427>`_].
* Correct conditional syntax in finalise release workflow by `@hsorby <https://github.com/hsorby>`_ [`#1426 <https://github.com/cellml/libcellml/pull/1426>`_].
* Skip user documentation update if the documentation tests failed by `@hsorby <https://github.com/hsorby>`_ [`#1425 <https://github.com/cellml/libcellml/pull/1425>`_].
* Fix more references to libcellml/website-src by `@hsorby <https://github.com/hsorby>`_ [`#1424 <https://github.com/cellml/libcellml/pull/1424>`_].
* Fix the way commits for release are pushed to main by `@hsorby <https://github.com/hsorby>`_ [`#1423 <https://github.com/cellml/libcellml/pull/1423>`_].
* Set default summary if documentation checks returns nothing by `@hsorby <https://github.com/hsorby>`_ [`#1422 <https://github.com/cellml/libcellml/pull/1422>`_].
* Fix missing installation of ResolveZLIB.cmake file by `@hsorby <https://github.com/hsorby>`_ [`#1421 <https://github.com/cellml/libcellml/pull/1421>`_].
* Set identity of Git user to github actions bot for tagging release source by `@hsorby <https://github.com/hsorby>`_ [`#1419 <https://github.com/cellml/libcellml/pull/1419>`_].
* Correctly tag source of release by `@hsorby <https://github.com/hsorby>`_ [`#1418 <https://github.com/cellml/libcellml/pull/1418>`_].
* Switch to release branch before committing changelog changes by `@hsorby <https://github.com/hsorby>`_ [`#1416 <https://github.com/cellml/libcellml/pull/1416>`_].
* Remove -v from git tag -a command in release-prepare.yml by `@hsorby <https://github.com/hsorby>`_ [`#1415 <https://github.com/cellml/libcellml/pull/1415>`_].
* Set a source tag and use that to determine which merge commits to consider by `@hsorby <https://github.com/hsorby>`_ [`#1414 <https://github.com/cellml/libcellml/pull/1414>`_].
* Tweaks to release process, investigating changelog creation issue by `@hsorby <https://github.com/hsorby>`_ [`#1412 <https://github.com/cellml/libcellml/pull/1412>`_].
* Adjust finalise release workflow by `@hsorby <https://github.com/hsorby>`_ [`#1411 <https://github.com/cellml/libcellml/pull/1411>`_].
* Release process fixes by `@hsorby <https://github.com/hsorby>`_ [`#1409 <https://github.com/cellml/libcellml/pull/1409>`_].
* Add finalise release workflow by `@hsorby <https://github.com/hsorby>`_ [`#1405 <https://github.com/cellml/libcellml/pull/1405>`_].
* Add make release workflow by `@hsorby <https://github.com/hsorby>`_ [`#1404 <https://github.com/cellml/libcellml/pull/1404>`_].
* Add check release workflow by `@hsorby <https://github.com/hsorby>`_ [`#1403 <https://github.com/cellml/libcellml/pull/1403>`_].
* Add GitHub action to prepare a release by `@hsorby <https://github.com/hsorby>`_ [`#1394 <https://github.com/cellml/libcellml/pull/1394>`_].
* Shift from OpenCMISS dependencies to CMLibs dependencies by `@hsorby <https://github.com/hsorby>`_ [`#1378 <https://github.com/cellml/libcellml/pull/1378>`_].
* GHA: account for the fact that `macos-13` is about to be retired by `@agarny <https://github.com/agarny>`_ [`#1329 <https://github.com/cellml/libcellml/pull/1329>`_].
* CMake: cannot use `DEPENDS` with `add_custom_command(TARGET ...)` by `@agarny <https://github.com/agarny>`_ [`#1319 <https://github.com/cellml/libcellml/pull/1319>`_].
* CI by `@agarny <https://github.com/agarny>`_ [`#1315 <https://github.com/cellml/libcellml/pull/1315>`_].

JavaScript bindings
-------------------

* JavaScript: account for the fact that our JavaScript bindings use a 32-bit address space by `@agarny <https://github.com/agarny>`_ [`#1384 <https://github.com/cellml/libcellml/pull/1384>`_].

Miscellaneous
-------------

* Update C++ standard to version 20 by `@agarny <https://github.com/agarny>`_ [`#1390 <https://github.com/cellml/libcellml/pull/1390>`_].
* Remove all unnecessary headers as guided by Qt Creator on macOS by `@hsorby <https://github.com/hsorby>`_ [`#1346 <https://github.com/cellml/libcellml/pull/1346>`_].
* Remove second definition of AnalyserModelWeakPtr by `@hsorby <https://github.com/hsorby>`_ [`#1343 <https://github.com/cellml/libcellml/pull/1343>`_].

Python bindings
---------------

* Add 3.14 to cibuildwheel builds by `@hsorby <https://github.com/hsorby>`_ [`#1444 <https://github.com/cellml/libcellml/pull/1444>`_].

Validation
----------

* Improve the time taken to validate and analyse large models by `@hsorby <https://github.com/hsorby>`_ [`#1397 <https://github.com/cellml/libcellml/pull/1397>`_].

Contributors
------------

.. image:: https://avatars.githubusercontent.com/u/778048?v=4
:target: https://github.com/hsorby
:height: 32
:width: 32
.. image:: https://avatars.githubusercontent.com/u/602265?v=4
:target: https://github.com/agarny
:height: 32
:width: 32
.. image:: https://avatars.githubusercontent.com/u/811244?v=4
:target: https://github.com/nickerso
:height: 32
:width: 32
2 changes: 1 addition & 1 deletion docs/changelogs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelogs

.. toctree::

changelog_v0.7.0-rc.4
changelog_v0.7.0
changelog_v0.6.3
changelog_v0.6.2
changelog_v0.6.1
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Changelogs

.. toctree::

changelogs/changelog_v0.7.0-rc.4
changelogs/changelog_v0.7.0
changelogs/changelog_v0.6.3
changelogs/changelog_v0.6.2
changelogs/changelog_v0.6.1
Expand Down
12 changes: 12 additions & 0 deletions src/analyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,17 @@ AnalyserInternalVariablePtr Analyser::AnalyserImpl::internalVariable(const Varia
// Find and return, if there is one, the internal variable associated with
// the given variable.

auto rawPtr = reinterpret_cast<uintptr_t>(variable.get());
auto rawPtrIt = mInternalVariableMap.find(rawPtr);

if (rawPtrIt != mInternalVariableMap.end()) {
return rawPtrIt->second;
}

for (const auto &internalVariable : mInternalVariables) {
if (mAnalyserModel->areEquivalentVariables(variable, internalVariable->mVariable)) {
mInternalVariableMap[rawPtr] = internalVariable;

return internalVariable;
}
}
Expand All @@ -416,6 +425,8 @@ AnalyserInternalVariablePtr Analyser::AnalyserImpl::internalVariable(const Varia

mInternalVariables.push_back(res);

mInternalVariableMap[rawPtr] = res;

return res;
}

Expand Down Expand Up @@ -2321,6 +2332,7 @@ void Analyser::AnalyserImpl::analyseModel(const ModelPtr &model)
mAnalyserModel = AnalyserModel::AnalyserModelImpl::create(model);

mInternalVariables.clear();
mInternalVariableMap.clear();
mInternalEquations.clear();

mCiCnUnits.clear();
Expand Down
1 change: 1 addition & 0 deletions src/analyser_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class Analyser::AnalyserImpl: public Logger::LoggerImpl
AnalyserExternalVariablePtrs mExternalVariables;

AnalyserInternalVariablePtrs mInternalVariables;
std::unordered_map<std::uintptr_t, AnalyserInternalVariablePtr> mInternalVariableMap;
AnalyserInternalEquationPtrs mInternalEquations;

GeneratorProfilePtr mGeneratorProfile = GeneratorProfile::create();
Expand Down
Loading