Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autobuild: Improve and reorganize git/Changelog scripts (re-submission of #2584) #2656

Merged
merged 6 commits into from
Jun 19, 2022

Conversation

hoffie
Copy link
Member

@hoffie hoffie commented Jun 18, 2022

Short description of changes
#2584 was already supposed and documented to contain these changes, but didn't (probably due to a bad rebase). Therefore, I'm re-submitting it and will edit the old PR to match what was actually merged.

  • Autobuild: Don't hardcode python path in analyse_git_reference.py

  • Autobuild: Move Changelog generation to the workflow
    Previously, the autobuild changelog (autoLatestChangelog.md) which is used for the Github release body, was generated as part of the "analyse_git_reference.py" script. It does not seem logical for an analysis script to have a side effect of producing a Changelog file. Also, the file name (autoLatestChangelog.md) was hardcoded in two places and had to match (workflow + script).

    With this commit, the changelog generation call (.github/actions_scripts/getChangelog.pl) is moved to the workflow. This follows the principle of least surprise and moves the output file name usage to a single file (the workflow).

    Fixes: Autobuild: Make Changelog generation an extra step #2480

  • Autobuild: Improve variable naming/coding style in analyse_git_reference.py

  • Autobuild: Move .github/action_scripts to .github/autobuild
    This also renames the two scripts to better reflect what they do.

  • Autobuild: Use a variable instead of hardcoding the release changelog path twice
    Related: Autobuild: Make Changelog generation an extra step #2480

CHANGELOG: Autobuild: Improved and reorganized git/Changelog scripts
(to be condensed with the other entries)

Context: Fixes an issue?
Fixes: #2480

Does this change need documentation? What needs to be documented and how?
No.

Status of this Pull Request
Ready for review.

What is missing until this pull request can be merged?

Reviews.

Checklist


def get_build_version(jamulus_pro_version):
def get_build_version():
jamulus_pro_version = get_version_from_jamulus_pro()
if "dev" in jamulus_pro_version:
Copy link
Collaborator

@pljones pljones Jun 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on logging in this function. I'd rather it returned a tuple of the type and version and the caller could choose to log or not.

def get_build_type_version():
    jamulus_pro_version = get_version_from_jamulus_pro()
    type = "release"
    version = jamulus_pro_version
    if "dev" in jamulus_pro_version:
        type = "dev"
        version = "{}-{}".format(version, get_git_hash())
    return type, version
build_type, build_version = get_build_type_version()
print(f"building a {build_type} version: {build_version}")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly about that and I think I've just taken what was there.
I have now (mostly) applied your suggestion.

Copy link
Collaborator

@pljones pljones Jun 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep wasn't fussed as it was already there. But as it was potentially useful information (i.e. build type), it might as well be exposed to the caller.

On which note - is the check for dev here the consistent check now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On which note - is the check for dev here the consistent check now?

Sorry, I missed that part -- Github doesn't send notifications for edits.
Can you elaborate on what you mean here?

@hoffie hoffie requested a review from ann0see June 18, 2022 17:35
id: get-build-vars

- name: Extract Changelog for the Github release body
if: steps.get-build-vars.outputs.PUBLISH_TO_RELEASE == 'true'
run: ./.github/autobuild/extractVersionChangelog.pl ChangeLog $(grep -oP 'VERSION = \K\w[^\s\\]*' Jamulus.pro) > ${{ env.release_changelog_path }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that happy with a regex and grep of the version here. Don't we have the version somewhere else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's rather why I was wondering if returning the release type from get_version_from_jamulus_pro() might help elsewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, personally, I'd prefer this since it feels cleaner.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, updated and re-tested on my fork (updated the link in the PR description).

hoffie added 2 commits June 18, 2022 22:50
Previously, the autobuild changelog (autoLatestChangelog.md) which is
used for the Github release body, was generated as part of the
"analyse_git_reference.py" script. It does not seem logical for an
analysis script to have a side effect of producing a Changelog file.
Also, the file name (autoLatestChangelog.md) was hardcoded in two places
and had to match (workflow + script).

With this commit, the changelog generation call (.github/actions_scripts/getChangelog.pl)
is moved to the workflow. This follows the principle of least surprise
and moves the output file name usage to a single file (the workflow).

Fixes: jamulussoftware#2480
@hoffie hoffie force-pushed the autobuild-action-scripts-redone branch from 4df0df3 to 9060f2c Compare June 18, 2022 20:57
Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Just another comment:

.github/workflows/autobuild.yml Show resolved Hide resolved
This also renames the two scripts to better reflect what they do.
@hoffie hoffie force-pushed the autobuild-action-scripts-redone branch from 9060f2c to 1d10c31 Compare June 18, 2022 21:03
@hoffie hoffie force-pushed the autobuild-action-scripts-redone branch from 1d10c31 to e97d32d Compare June 18, 2022 21:09
build_version = get_build_version(jamulus_pro_version)
set_github_variable("JAMULUS_PRO_VERSION", jamulus_pro_version)
build_type, build_version = get_build_version(jamulus_pro_version)
print(f'building a version of type "{build_type}": {build_version}')

fullref = os.environ['GITHUB_REF']
publish_to_release = bool(re.match(r'^refs/tags/r\d+_\d+_\d+\S*$', fullref))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, can we either do this or do what line 36 (if "dev" in jamulus_pro_version:) does, rather than have both ways in use.

I guess, ideally that means another function get_release_type() that just returns whether this is a release or not. It can be boolean, to allow the caller to decide how to use the result - but if we're using the tag (as here) to drive what gets triggered in the automation, then the scripts (that get triggered) should also just use the tag.

So

  • do we need to differentiate between GITHUB_REF version and Jamulus.pro version?
  • if so, we should be consistent and use GITHUB_REF at least to drive whether a build is a release or not
  • if not, we should be completely consistent and use one or other - everywhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, can we either do this or do what line 36 (if "dev" in jamulus_pro_version:) does, rather than have both ways in use.

I don't quite see yet how one could replace the other.

I guess, ideally that means another function get_release_type() that just returns whether this is a release or not. It can be boolean, to allow the caller to decide how to use the result

That would be possible, for sure.

but if we're using the tag (as here) to drive what gets triggered in the automation, then the scripts (that get triggered) should also just use the tag.

  • do we need to differentiate between GITHUB_REF version and Jamulus.pro version?

With the current design, assumptions and constraints, we have to differentiate, I think. GITHUB_REF(= tag) might be different (e.g. for pre-releases) or not existing at all (branches/master).

  • if so, we should be consistent and use GITHUB_REF at least to drive whether a build is a release or not

I think this should be the case already. We use the workflow variable PUBLISH_TO_RELEASE to drive the build. This variable is solely driven by GITHUB_REF.

  • if not, we should be completely consistent and use one or other - everywhere

I think there's certainly room for improvement, but it needs thorough checking to avoid breaking existing use cases (such as local builds). In addition, I don't think this PR introduces any additional inconsistencies. It might make existing strangeness more obvious (which is a good thing, IMO). Therefore, I'm a bit hesitant to squeeze in additional larger changes here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is get_build_version() uses a different value. The tag, Jamulus.pro and ChangeLog could all have different versions.

Given we have three sources for the version, we really need automation to make sure they're aligned, at least: i.e. error out if things look wrong. But I agree, that's not in scope here. For that, it sounds like (and I don't fully understand how this works):

  • If the tag is set, we should use that to determine build type and version and that source should overrule others.
  • ChangeLog and Jamulus.pro "target" versions should match - and, if set, match the tag build type and version.
  • If the tag wasn't set, build type and version can then come from ChangeLog and Jamulus.pro, as needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I've split that out into #2662 to track that.

@hoffie hoffie merged commit 42916f7 into jamulussoftware:master Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autobuild: Make Changelog generation an extra step
3 participants